Session Management in Web Applications



Similar documents
Criteria for web application security check. Version

Check list for web developers

What is Web Security? Motivation

Using Foundstone CookieDigger to Analyze Web Session Management

Table of Contents. Open-Xchange Authentication & Session Handling. 1.Introduction...3

Where every interaction matters.

An Insight into Cookie Security

Lecture 11 Web Application Security (part 1)

Web application security

Web Application Report

FINAL DoIT v.8 APPLICATION SECURITY PROCEDURE

FileCloud Security FAQ

HTTP. Internet Engineering. Fall Bahador Bakhshi CE & IT Department, Amirkabir University of Technology

Auditing a Web Application. Brad Ruppert. SANS Technology Institute GWAS Presentation 1

Chapter 7 Transport-Level Security

Is Drupal secure? A high-level perspective on web vulnerabilities, Drupal s solutions, and how to maintain site security

3. Broken Account and Session Management. 4. Cross-Site Scripting (XSS) Flaws. Web browsers execute code sent from websites. Account Management

Certified Secure Web Application Security Test Checklist

FINAL DoIT v.4 PAYMENT CARD INDUSTRY DATA SECURITY STANDARDS APPLICATION DEVELOPMENT AND MAINTENANCE PROCEDURES

WHITE PAPER. FortiWeb and the OWASP Top 10 Mitigating the most dangerous application security threats

Application Security Testing. Generic Test Strategy

Application Security Policy

Web Application Security Guidelines for Hosting Dynamic Websites on NIC Servers

Internet Banking System Web Application Penetration Test Report

TELE 301 Network Management. Lecture 17: File Transfer & Web Caching

VPN Client User s Guide Issue 2

Xerox DocuShare Security Features. Security White Paper

Is your data safe out there? -A white Paper on Online Security

Web Application Security Considerations

Installation and configuration guide

CA Performance Center

1. Introduction. 2. Web Application. 3. Components. 4. Common Vulnerabilities. 5. Improving security in Web applications

Protecting Web Applications and Users

Sichere Software- Entwicklung für Java Entwickler

Apache Server Implementation Guide

Web Application Firewall on SonicWALL SRA

Certified Secure Web Application Secure Development Checklist

DEPLOYMENT GUIDE DEPLOYING F5 WITH SAP NETWEAVER AND ENTERPRISE SOA

Borderware Firewall Server Version 7.1. VPN Authentication Configuration Guide. Copyright 2005 CRYPTOCard Corporation All Rights Reserved

By Jan De Clercq. Understanding. and Leveraging SSL-TLS. for Secure Communications

Installation and configuration guide

Tableau Server Security. Version 8.0

Chapter 1 Load Balancing 99

Web Application Penetration Testing

CS5008: Internet Computing

Web Security Testing Cookbook*

Web Application Firewall on SonicWALL SSL VPN

One-Time Cookies: Preventing Session Hijacking Attacks with Disposable Credentials

Thick Client Application Security

Application Layer Encryption: Protecting against Application Logic and Session Theft Attacks. Whitepaper

Webmail Using the Hush Encryption Engine

Layered security in authentication. An effective defense against Phishing and Pharming

Setting Up Scan to SMB on TaskALFA series MFP s.

APPLICATION SECURITY AND ITS IMPORTANCE

ProxySG TechBrief Enabling Transparent Authentication

DEPLOYMENT GUIDE CONFIGURING THE BIG-IP LTM SYSTEM WITH FIREPASS CONTROLLERS FOR LOAD BALANCING AND SSL OFFLOAD


BlackShield ID Agent for Remote Web Workplace

CONTENT of this CHAPTER

CA SiteMinder. SAML Affiliate Agent Guide. 6.x QMR 6

BlackShield ID Agent for Terminal Services Web and Remote Desktop Web

Gateway Apps - Security Summary SECURITY SUMMARY

Introducing the BIG-IP and SharePoint Portal Server 2003 configuration

Transport Layer Security Protocols

How to Configure Dynamic DNS on a Virtual Access Router

Online Data Services. Security Guidelines. Online Data Services by Esri UK. Security Best Practice

How To Set Up The Barclaycard Epdq Cardholder Payment Interface (Cpi) On Papercut (Barclay Card) On A Microsoft Card (For A Credit Card) With A Creditcard (For An Account)

Web and Security 1 / 40

Web Application Security

Cross Site Scripting in Joomla Acajoom Component

Reparing HTTP authentication for Web security

Designing a CA Single Sign-On Architecture for Enhanced Security

How to Configure Captive Portal

GravityLab Multimedia Inc. Windows Media Authentication Administration Guide

Access Gateway Guide Access Manager 4.0 SP1

Network Security Essentials Chapter 5

Secure Web Application Coding Team Introductory Meeting December 1, :00 2:00PM Bits & Pieces Room, Sansom West Room 306 Agenda

Ajera 8 Installation Guide

Web Application Guidelines

Last update: February 23, 2004

WEB SECURITY. Oriana Kondakciu Software Engineering 4C03 Project

Owner of the content within this article is Written by Marc Grote

NetBrain Security Guidance

Client Side Filter Enhancement using Web Proxy

INUVIKA OPEN VIRTUAL DESKTOP ENTERPRISE

Evolution of the WWW. Communication in the WWW. WWW, HTML, URL and HTTP. HTTP Abstract Message Format. The Client/Server model is used:

RemotelyAnywhere Getting Started Guide

Web Application Security

Project 2: Web Security Pitfalls

MIGRATIONWIZ SECURITY OVERVIEW

Login with Amazon. Developer Guide for Websites

OWASP Top Ten Tools and Tactics

A Server and Browser-Transparent CSRF Defense for Web 2.0 Applications. Slides by Connor Schnaith

Web Security (SSL) Tecniche di Sicurezza dei Sistemi 1

How to break in. Tecniche avanzate di pen testing in ambito Web Application, Internal Network and Social Engineering

Fireware How To Authentication

Web applications. Web security: web basics. HTTP requests. URLs. GET request. Myrto Arapinis School of Informatics University of Edinburgh

Transcription:

Session Management in Web Applications Author: EUROSEC GmbH Chiffriertechnik & Sicherheit Tel: 06173 / 60850, www.eurosec.com EUROSEC GmbH Chiffriertechnik & Sicherheit, 2005

What is Web-based Session Management user authentication management user preferences management site history of previously seen contents authorization and status information (e.g. valid customer, shopping basket items, etc.) trust delegation within (distributed) web applications (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 2

Usual Technical Solutions (Overview) Cookies URL-encoding Forms with Hidden Field HTTP Referrer Fields HTTP Basic/Digest Authentication Client Certificate (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 3

Neglected Security Requirements Session time-out after a certain amount of time prevention/detection of brute force attacks and/or password guessing prevention of unauthorized manipulation of session data prevention of theft of sensitive session tokens and user credentials servers should be able to terminate sessions in case of necessity (independent from client session token validity) translates to: session logout mechanisms that delete (overwrite) the browser`s session cookie in case of necessity: use of strong (pseudo-) random numbers sufficient session ID randomness sufficient session ID length use different session identifiers when shifting between secure and insecure contents (i.e. authenticated vs. non-authenticated, http vs. https, sensitive application areas vs. nonsensitive, etc.) limited trust delegation reauthentication prior to sensitive actions (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 4

Popular Problems secret user credentials are transmitted in the clear server-generated authentication data can be forged (weak crypto, exhaustive search, simple-to-guess numbering or mechanism) stealing of secret user credentials no account logout... (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 5

Active and Passive Attack Scenarios Session Hijacking Eavesdropping Session Fixation Cross-Site Scripting Exhaustive Search Intelligent Manipulation of Session Data Network Manipulation (e.g. change of DNS entries) etc. (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 6

URL-based Solutions The session token is part of the URL and will be transmitted to the web server through HTTP GET requests Example: http://www.blabla.com/buy.asp?article=27781;sessionid=ie5579901578 This mechanism works even in case of user client security restrictions (if, for example, no cookies are allowed). Thus, it can serve as a fallback mechanism if the server detects problems with other mechanisms like cookies or JavaScript Problems: All information contained in the URL might be stored in firewall or proxy log files Also, it could simply be printed out with the web page on a shared printer Moreover, the URL, including potentially sensitive data, can be sent in the HTTP referrer field to other web servers. This implies a high risk of sensitive session data being disclosed to unauthorized third parties (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 7

Form-based Solutions with Hidden Fields Session token and information can be included in so-called hidden fields in a form The form will be sent by the user client to the server with an HTTP POST command. This looks like the following example: <FORM METHOD=POST ACTION= /cgi-bin/order_goods.pl > <INPUT TYPE= hidden NAME= customerid VALUE= 0815 > <INPUT TYPE= hidden NAME= valid_order VALUE= yes > <INPUT TYPE= hidden NAME= productid VALUE= 4711 > As described in the case of URL-encoded session tokens, this form-based mechanism works even in case of user client security restrictions (if, for example, no cookies are allowed). Thus, it can serve as a fallback mechanism if the server detects problems with other mechanisms like cookies or JavaScript The form-based solution does not provide pre-defined protection mechanisms as those provided by cookies, for example Moreover, the form-based approach requires repeated sending of HTTP forms via POST commands, which implies a certain amount of overhead that might reduce performance. Also, hidden fields cannot last beyond a certain interactive session (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 8

HTTP Basic and/or Digest Authentication-based Solutions In HTTP Basic authentication, the client sends his username and password in cleartext as part of the HTTP request In all subsequent HTTP requests for content from subdirectories of the original request, these credentials will be automatically resent In HTTP Digest authentication, no passwords are sent in the clear Instead, a cryptographic hash value containing the username, password, and additional security-relevant data, will be transmitted from the client to the server (more details can be found in RFC2617 - HTTP Authentication: Basic and Digest Access Authentication, June 1999) Problems: HTTP Basic authentication is vulnerable to passive eavesdropping. Moreover, it provides no mechanism for explicit session expiration (i.e. logout) HTTP Digest authentication cannot guarantee sufficient support on all client platforms Both mechanisms do not provide session tracking, but only authentication (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 9

Cookie-based Solutions Cookies are a simple session management mechanism Cookies have been designed to track status information about user visits on web servers (who requested which pages at what time) Originally, nobody intended to use cookies for authentication purposes Nevertheless, a large quantity of web applications today uses cookies for user authentication and authorization Cookies are normally sent from the web server to the client using two different methods: either within HTTP headers or by JavaScript (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 10

Structure of a Cookie The syntax for the Set-Cookie2 response header, according to RFC2965 syntax notation, is as follows: set-cookie = "Set-Cookie2:" cookies cookies = 1#cookie cookie = NAME "=" VALUE *(";" set-cookie-av) NAME = attr VALUE = value set-cookie-av = "Comment" "=" value "CommentURL" "=" <"> http_url <"> "Discard" "Domain" "=" value "Max-Age" "=" value "Path" "=" value "Port" [ "=" <"> portlist <"> ] "Secure" "Version" "=" 1*DIGIT portlist = 1#portnum portnum = 1*DIGIT (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 11

Cookies: the Secure Option The Secure option tells the user client that the cookie in question should be sent over an SSL-protected channel At least this is what common web browsers do, even though the RFC2965 makes a slightly different statement: The Secure attribute (with no value) directs the user agent to use only (unspecified) secure means to contact the origin server whenever it sends back this cookie, to protect the confidentiality and authenticity of the information in the cookie. The user agent (possibly with user interaction) MAY determine what level of security it considers appropriate for "secure" cookies. The Secure attribute should be considered security advice from the server to the user agent, indicating that it is in the session's interest to protect the cookie contents. When it sends a "secure" cookie back to a server, the user agent SHOULD use no less than the same level of security as was used when it received the cookie from the server. (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 12

Cookies: Further Options The Discard option tells the user client to discard the cookie as soon as the user client terminates The Domain and Path values specify the domain and corresponding folder subtree to which the cookie applies The Max-Age option allows to set an explicit cookie life time. If this life time is over or if Max-Age is set to zero, then the cookie should be discarded by the user client. Thus, the origin server can effectively terminate a session by sending the client a corresponding Set-Cookie2 header with Max-Age=0 If no Max-Age option is present, then the cookie is a so-called session cookie, i.e. the user client is supposed to store the cookie temporarily in its memory space and discard the cookie as soon as the user client terminates (i.e. the browser is closed) The Port option allows to define valid port numbers to which a given cookie can be returned. The security relevance of this feature is of minor relevance, nevertheless it could be useful in some specific scenarios (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 13

Persistent Cookies Persistent cookies will be stored (in case of Microsoft Windows2000/XP, for example) in C:\Documents and Settings\<username>\Cookies Each such cookie is stored in a.txt file starting with the username, followed by an @ and some information about the issuer domain Persistent cookies have no protection from the operation system against user manipulations (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 14

Microsoft`s HttpOnly Option Microsoft implemented protection mechanisms into Internet Explorer 6, the so-called HTTP-only option HttpOnly is not part of an RFC or similar standard ; HttpOnly gets appended to a cookie; if IE6 receives such a cookie, it does not allow scripted (e.g. via JavaScript) access to this cookie other browsers may either ignore this option or even reject the whole cookie Http-only mechanism is good, but not absolutely secure against all sorts of scripting attacks (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 15

How to change Cookies or Hidden Fields Changing cookies, URLs or hidden fields is quite simple; all you need is (one of) the following: local proxy (e.g. Paros) text editor, for persistent cookies stored in text files telnet or other simple Unix tools in case of URLs you need no editor at all... sometimes: Base64 decoder (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 16

Example: Apache Apache provides a so-called user tracking mechanism with mod_usertrack.c (in previous versions mod_cookies.c) Even though the source code documentation in Apache version 2 explicitly warns not to use this mechanism for security purposes like authentication, many application programmers still do (who cares about documentation?! ) The generated cookies include the client`s IP address, the web server`s process ID, as well as the time of the web request. An example cookie looks like this: Apache= 64.3.40.151.27273996348638848 (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 17

Ad Hoc Measures / Recommendations use session identifier strings that cannot be efficiently guessed or otherwise computed use long (pseudo) random numbers within session identifiers do not store session status information in cookies and/or URL strings or hidden fields use only a session identifier on the client side that refers to all relevant information that is stored on the server side in case that session information must be stored on the client side, then it should be encrypted and/or cryptographically hashed change session identifiers whenever the user switches between authenticated/unauthenticated, secure/insecure areas, etc. make use of cookie security options (as described above) use URL-/Cookie-/Hidden Field-based session identifiers in parallel (each using a different ID string) make use of the HTTP referrer field as an additional security feature: deny requests with wrong referrer data; depending on the application scenario, however, it could be necessary to allow requests with missing referrer data divide the application into two parts on separate servers: one for insecure HTTP requests, the other for secure HTTPS requests; include corresponding path restrictions in the cookie path option (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 18

Dangerous Confusion among old and new RFC (?) Example for one (among others) problem in HTTP State Management Mechanism RFCs: Interpretation of the Path attribute according to RFC2109 from 1997: Defaults to the path of the requesting URL that generated the Set-Cookie response, up to, but not including, the right-most /. Interpretation of the Path attribute according to the successor of RFC2109, i.e. RFC2965 from 2000: Defaults to the path of the requesting URL that generated the Set-Cookie2 response, up to and including the right-most /. This is a quite important difference, as can be seen from the following examples: www.shared-host.example.com/thilo/ www.shared-host.example.com/thilo-the-victim/ Setting a path attribute /thilo would, according to the new standard, not allow the area /thilo-the-victim to access cookie information from /thilo. If the old standard applies, however, this would be allowed. (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 19

Stronger Improvements: Dynamic Links Idea: generate dynamic links that include session identifier information (e.g. user ID and previous page) different implementation variants are possible some use JavaScript on the client side to generate those links; this allows unauthorized user manipulations problems: page reload and browser back button can imply difficulties (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 20

Conclusion many web applications still suffer from weak session management for medium security, a good cookie-based standard solution can be sufficient for higher security needs, a Dynamic Link-based approach is recommended each web application should be checked against all problem categories mentioned above never trust user input (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 21

Appendix (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 22

Why this presentation from us? - our professional background: several project years in research projects on secure software development, with partners like SAP, Deutsche Bank, Commerzbank, Universities, etc. large amount of application vulnerability checks for software companies, including reviews and coaching for developers Security requirements- and design specifications for large development projects Writing of company guidelines and checklists for secure development, mostly in banking and finance sector Reverse engineering and reviews of security mechanisms and crypto algorithms Implementation of security functions for customers (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 23

Final Remark the present work has been conducted within the socalled secologic research project (term: 2005+2006) for more details see www.secologic.org we are grateful to the German Ministry Bundesministerium für Wirtschaft for supporting this project we appreciate all suggestions and feedback with respect to our presentation slides and white papers (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 24

Copyright Remark This document has been prepared by EUROSEC and serves the purpose of conducting courses and seminars about secure software development (focus on web applications) We published these slides to support further activities in the development of better software applications These slides can be used for your own purposes/employees within your company, as long as you include an information about authorship by EUROSEC Commercial use by companies specialized in seminars and/or consulting, is not allowed without a separate agreement; please contact us:kontakt@eurosec.com (c) 2005, EUROSEC GmbH Chiffriertechnik & Sicherheit 25