Attacking Session Management Juliette Lessing

Slides:



Advertisements
Similar presentations
Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems © 2002, Predictive Systems.
Advertisements

Kerberos 1 Public domain image of Heracles and Cerberus. From an Attic bilingual amphora, 530–520 BC. From Italy (?).
Chapter 6 Attacking Authentication
Attacking Authentication and Authorization CSE 591 – Security and Vulnerability Analysis Spring 2015 Adam Doupé Arizona State University
Session Hijacking Why web security depends on communications security and how TLS everywhere is the only solution. Scott Helme - 6th Aug scotthel.me.
ATTACKING AUTHENTICATION The Web Application Hacker’s Handbook, Ch. 6 Presenter: Jie Huang 10/31/2012.
CS426Fall 2010/Lecture 81 Computer Security CS 426 Lecture 8 User Authentication.
DICOM INTERNATIONAL DICOM INTERNATIONAL CONFERENCE & SEMINAR April 8-10, 2008 Chengdu, China DICOM Security Eric Pan Agfa HealthCare.
It’s always better live. MSDN Events Security Best Practices Part 2 of 2 Reducing Vulnerabilities using Visual Studio 2008.
Security Awareness: Applying Practical Security in Your World, Second Edition Chapter 5 Network Security.
Chapter 9 Web Applications. Web Applications are public and available to the entire world. Easy access to the application means also easy access for malicious.
Chapter 4 Application Security Knowledge and Test Prep
RADIUS Server PAP & CHAP Protocols. Computer Security  In computer security, AAA protocol commonly stands for authentication, authorization and accounting.
 Proxy Servers are software that act as intermediaries between client and servers on the Internet.  They help users on private networks get information.
Session Hijacking & ARP Poisoning Why web security depends on communications security and how TLS everywhere is the only solution.
Session 11: Security with ASP.NET
CSC 2720 Building Web Applications Cookies, URL-Rewriting, Hidden Fields and Session Management.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
Web Services Security. Introduction Developing standards for Web Services security – XML Key Management Specification (XKMS) – XML Signature – XML Encryption.
Chapter 9 Web Applications. Web Applications are public and available to the entire world. Easy access to the application means also easy access for malicious.
Csci5233 Computer Security1 Bishop: Chapter 27 System Security.
Copyright ®xSpring Pte Ltd, All rights reserved Versions DateVersionDescriptionAuthor May First version. Modified from Enterprise edition.NBL.
Robust Defenses for Cross-Site Request Forgery CS6V Presented by Saravana M Subramanian.
IBM Rational Application Security Group (aka Watchfire) Web Based Man In the Middle Attack © 2009 IBM Corporation 1 Active Man in the Middle Attacks The.
Web Application Firewall (WAF) RSA ® Conference 2013.
3-Protecting Systems Dr. John P. Abraham Professor UTPA.
Software Security Testing Vinay Srinivasan cell:
Module 10: Monitoring ISA Server Overview Monitoring Overview Configuring Alerts Configuring Session Monitoring Configuring Logging Configuring.
COMP3121 E-Commerce Technologies Richard Henson University of Worcester November 2011.
Event Management & ITIL V3
Implementing a Port Knocking System in C Honors Thesis Defense by Matt Doyle.
Chapter 2. Core Defense Mechanisms. Fundamental security problem All user input is untrusted.
Feedback #2 (under assignments) Lecture Code:
Packet Filtering & Firewalls. Stateless Packet Filtering Assume We can classify a “good” packet and/or a “bad packet” Each rule can examine that single.
1 Maryland ColdFusion User Group Session Management December 2001 Michael Schuler
1 Topic 2: Lesson 3 Intro to Firewalls Summary. 2 Basic questions What is a firewall? What is a firewall? What can a firewall do? What can a firewall.
Fundamentals of Proxying. Proxy Server Fundamentals  Proxy simply means acting on someone other’s behalf  A Proxy acts on behalf of the client or user.
SEC835 Runtime authentication Secure session management Secure use of cryptomaterials.
Ram Santhanam Application Level Attacks - Session Hijacking & Defences
Broken Authentication & Session Management. What is it ? Bad implementation of authentication and session management. If an attacker can get your session.
G CITRIXHACKIN. Citrix Presentation Server 4.5 New version is called XenApp/Server Common Deployments Nfuse classic CSG – Citrix Secure Gateway Citrix.
Cookies and Sessions IDIA 618 Fall 2014 Bridget M. Blodgett.
CS 4244: Internet Programming Security 1.0. Introduction Client identification and cookies Basic Authentication Digest Authentication Secure HTTP.
Module 7: Advanced Application and Web Filtering.
Cookies Bill Chu. © Bei-Tseng Chu Aug 2000 Definition A cookie is a TEXT object of max 4KB sent from a web server to a browser It is intended for the.
Ch. 7 -Attacking Session Management Latasha A. Gibbs CSCE 813 – Internet Security, Fall 2012 College of Engineering and Computing University of South Carolina.
Configuring and Troubleshooting Identity and Access Solutions with Windows Server® 2008 Active Directory®
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
Search Engine using Web Mining COMS E Web Enhanced Information Mgmt Prof. Gail Kaiser Presented By: Rupal Shah (UNI: rrs2146)
Web2.0 Secure Development Practice Bruce Xia
1 State and Session Management HTTP is a stateless protocol – it has no memory of prior connections and cannot distinguish one request from another. The.
Web Application (In)security Note: Unless noted differently, all scanned figures were from the textbook, Stuttard & Pinto, 2011.
Firewalls A brief introduction to firewalls. What does a Firewall do? Firewalls are essential tools in managing and controlling network traffic Firewalls.
CSRF Attacks Daniel Chen 11/18/15. What is CSRF?  Cross Site Request Forgery (Sea-Surf)  AKA XSRF/ One Click / Sidejacking / Session Riding  Exploits.
Session Management Tyler Moore CS7403 University of Tulsa Slides adapted in part or whole from Dan Boneh, Stanford CS155 1.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
PHP: Further Skills 02 By Trevor Adams. Topics covered Persistence What is it? Why do we need it? Basic Persistence Hidden form fields Query strings Cookies.
Carrie Estes Collin Donaldson.  Zero day attacks  “zero day”  Web application attacks  Signing up for a class  Hardening the web server  Enhancing.
1 Example security systems n Kerberos n Secure shell.
Presented by Deepak Varghese Reg No: Introduction Application S/W for server load balancing Many client requests make server congestion Distribute.
Chapter 7: Using Network Clients The Complete Guide To Linux System Administration.
SESSION HIJACKING It is a method of taking over a secure/unsecure Web user session by secretly obtaining the session ID and masquerading as an authorized.
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Chapter 7: Identifying Advanced Attacks
Secure Software Confidentiality Integrity Data Security Authentication
Web Services Security.
– Chapter 3 – Device Security (B)
Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems
Presentation transcript:

Attacking Session Management Juliette Lessing Chapter 7 Attacking Session Management Juliette Lessing

Session management Enables the application to uniquely identify a given user across a number of different requests. Prime target for malicious attacks against application. Encountered defects. If an attacker can break an application’s session management, then she can effectively bypass its authentication controls ans masquerade as other application users without knowing their credentials. If an attacker compromises an administrative user in this way, then the attacker can own the entire application. There is a wide variety of defects that can commonly be found in session management functions and this chapter looks at all types of weakness that are encountered before.

Two types of weaknesses Weaknesses in Session Token Generation Weaknesses in the handling of session tokens throughout their lifecycle.

Weaknesses in Session Token Generation Meaningful tokens (1) Created using a transformation of the user’s user name or other info associated with them But actually: Session management mechanisms are often vulnerable to attack because tokens are generated in an unsafe manner that enables an attacker to identify the values of tokens that have been issued to other users. First: meaningful tokens: Some session tokens are created using a transformation of the user’s user- name or email address, or other information associated with them. This infor- mation may be encoded or obfuscated in some way, and may be combined with other data. For example, the following token may initially appear to be a long random string but when you run in through the right decoder it reveals the actual data.

Meaningful tokens (2) Exhibit some structure allowing an attacker to understand their function and means of generation. Components: User name E-mail address Client’s IP address Tokens that contain meaningful data often exhibit some structure which allows an attacker to understand their function and means of generation. Components that may be encountered within structured tokens include among others user name, e-mail address and client’s IP address

Meaningful tokens (3) Hack steps: Obtain single token from the application, modify it to determine validity. Change token’s value one byte at a time and check whether application is still accepted. Are some portions not required to be correct, exlude them. Log in as several different users at different times and record the tokens received from the server. Analyze the tokens for any correlations that appear to be related to the username and other user-controllable data. Analyze the tokens for any detectable encoding or obfuscation. If any meaning can be reverse engineered from the sample of session tokens, guess the tokens, find a page of the application that is session-dependent, and make large numbers of requests to this page using these guessed tokens. Monitor the results for any cases where the page is loaded correctly, indicating a valid session token. Obtain a single token from the application, and modify it in systematic ways to determine whether the entire token is validated, or whether some subcomponents of the token are ignored. Try changing the token’s value one byte at a time (or even one bit at a time) and submitting the modified token back to the application to determine whether it is still accepted. If you find that certain portions of the token are not actually required to be correct, you can exclude these from any further analysis, potentially reducing the amount of work that you need to perform. Log in as several different users at different times and record the tokens received from the server. If self-registration is available and you can choose your username, log in with a series of similar usernames contain- ing small variations between them, such as A, AA, AAA, AAAA, AAAB, AAAC, AABA, and so on. If other user-specific data is submitted at the login or stored in user profiles (such as an email address), perform a similar exercise to vary that data systematically and record the tokens received following login. Analyze the tokens for any detectable encoding or obfuscation. Where the username contains a sequence of the same character, look for a corre- sponding character sequence in the token, which may indicate the use of XOR obfuscation. Look for sequences in the token containing only hexa- decimal characters, which may indicate a hex-encoding of an ASCII string or other information. Look for sequences ending in an equals sign and/or only containing the other valid Base64 characters: a–z, A–Z, 0–9, +, and /. If any meaning can be reverse engineered from the sample of session tokens, consider whether you have sufficient information to attempt to guess the tokens recently issued to other application users. Find a page of the application that is session-dependent (e.g., one that returns an error message or a redirect elsewhere if accessed without a valid ses- sion), and use a tool such as Burp Intruder to make large numbers of requests to this page using guessed tokens. Monitor the results for any cases where the page is loaded correctly, indicating a valid session token.

Weaknesses in Session Token Generation Predictable tokens (1) Contain sequences or patterns Arise from 3 different sources: Concealed sequences Time dependency Weak random number generation Predictable tokens contain sequences or patterns that allow an attacker to extrapolate from a sample of tokens to find other valid tokens recently issued by the application. The authors’ experience in the field indicates that predictable session tokens commonly arise from three different sources which are Concealed sequences, Time dependency and Weak random number generation

Predictable tokens (2) Concealed sequences         Firstly, concealed sequences. It is common to encounter session tokens that cannot be trivially predicted when analyzed in their raw form but that contain sequences that reveal them- selves when the tokens are suitably decoded or unpacked. In the first serie of values, there is among others a + sign indicating we need a Base64 decoder. Next we encounter strange values, binary data. Rendering the decoded data as hexadecimal numbers we get the next serie of values. And in the end leading to the last values which reveals a concealed pattern. Transforming it then to using text-based protocol HTTP allows you to easily write a script to produce the series of tokens that the server will next produce, and the series that it produced prior to the captured sample.

Predictable tokens (2) 2. Time dependency  Attack: Start polling the server to obtain new session tokens in quick succession Monitor the increments in the first number. Increases more than one? Token has been issued by another user We know upper and lower bounds of second number which was issued to them brute-force attacks in order to successfully access a protected page Running this scripted attack continuously will enable us to capture the session token of every other application user. When an administrative user logs in, we will fully compromise the entire application. Some web servers and applications employ algorithms for generating session tokens that use the time of generation as an input to the token’s value. If insuf- ficient other entropy is incorporated into the algorithm, then you may be able to predict other users’ tokens. Although any given sequence of tokens on its own may appear to be completely random, the same sequence coupled with information about the time at which each token was generated may contain a discernible pattern. Start polling the server to obtain new session tokens in quick succession Monitor the increments in the first number. Increases more than one? Token has been issued by another user When a token has been issued to another user, we know the upper and lower bounds of the second number that was issued to them, because we possess the tokens that were issued immediately before and after theirs. Because we are obtaining new session tokens frequently, the range between these bounds will typically consist of only a few hun- dred values. Each time a token is issued to another user, we launch a brute-force attack to iterate through each number in the range, appending this to the missing incremental number that we know was issued to the other user. We attempt to access a protected page using each token we con- struct, until the attempt succeeds and we have compromised the user’s session.

Predictable tokens (3) 3. Weak random number generation This algorithm takes the last number generated, multiplies it by one constant, and adds another constant, to obtain the next number. The number is truncated to 48 bits, and the algorithm shifts the result to return the specific number of bits requested by the caller. Very little that occurs inside a computer is random. When a predictable pseudo-random number generator is used for produc- ing session tokens, the resulting tokens are vulnerable to sequencing by an attacker.

Weaknesses in Session Token Handling Disclosure of tokens on the network (1) Weaknesses occur when: Some applications elect to use HTTPS to protect the user’s credentials during login but then revert to HTTP for the remainder of the user’s session Some applications use HTTP for preauthenticated areas of the site, such as the site’s front page, but switch to HTTPS from the login page onwards. It doesnt matter whether sessions don’t contain any meaningful information if the tokens are not handled carefully after generation it is subject to attack anyway. There are a variety of ways in which an application’s unsafe handling of tokens can make it vulnerable to attack. Firstly via the disclosure of tokens on the network which arises when the session token is transmitted across the network in unencrypted form, enabling a suitably positioned eavesdrop- per to obtain the token and so masquerade as the legitimate user. Weaknesses occur when…..

Disclosure of tokens on the network (2) Hack steps: Walk through application in normal way and identify login functions and transitions between HTTP and HTTPS communications Are HTTP cookies used as transmission mechanism? Verify whether secure flag is set Determine whether session tokens are ever transmitted over an unencrypted connection. Yes? Regard them as vulnerable to interception Verify whether a new token is issued following login, or whether a token transmitted during the HTTP stage is still being used to track the user’s authenticed session Verify whether server is listening on port 80. If so, visit any HTTP URL directly from with an authenticated session and verify whether the session token is transmitted In cases where a token for an authenticated session is transmitted to the server over HTTP, verify whether that token continues to be valid or is immediately terminated by the server. Walk through application in normal way and identify login functions and transitions between HTTP and HTTPS communications Are HTTP cookies used as transmission mechanism? Verify whether secure flag is set, preventing them from ever being transmitted over unencrypted connections Determine whether, in the normal use of the application, session tokens are ever transmitted over an unencrypted connection. If so, they should be regarded as vulnerable to interception. Verify whether a new token is issued following login, or whether a token transmitted during the HTTP stage is still being used to track the user’s authenticed session Verify whether server is listening on port 80. If so, visit any HTTP URL directly from with an authenticated session and verify whether the session token is transmitted

Weaknesses in Session Token Handling Disclosure of tokens in logs causes of session tokens appearing in system logs An administrator, for example, may consult a log of recent sessions in the course of investigating a security breach. Often, this kind of monitoring and control functionality discloses the actual session token associated with each session. And often, the functionality is poorly protected, allowing unauthorized users to access the list of current session tokens, and thereby hijack the sessions of all application users. cause of session tokens appearing in system logs is where an application uses the URL query string as a mechanism for transmitting tokens, as opposed to using HTTP cookies or the body of POST requests

Weaknesses in Session Token Handling Vulnerable session termination (1) Some applications do not provide effective logout functionality: A log-out function is not implemented The logout function does not actually cause the server to invalidate the session When a user clicks Logout, this fact is not communi- cated to the server at all, and so the server performs no action whatsoever. Proper termination of sessions is important to reduce the window of opportunity within which an attacker may capture, guess, or misuse a valid session token. However, some applications do not provide effective logout functionality. This can be due to: No implementation of a logout funtion Logout funtions doesnt cause the server to terminate the session When a user clicks logout this is not communicated to the server at all

Vulnerable session termination (2) Hack steps: Investigate whether session expiration is implemented on the server side Determine whether a logout function exists and is prominently made available to users. If not, users are more vulnerable because they have no means of causing the application to invalidate their session. Where a logout function is provided, test its effectiveness. After logging out, attempt to reuse the old token and determine whether it is still valid. If so, users remain vulnerable to some session hijacking attacks even after they have “logged out.” investigate whether session expiration is implemented on the server side: (STEPS TO INVESTIGATE) Log in to the application to obtain a valid session token. Wait for a period without using this token, and then submit a request for a protected page (e.g., “my details”) using the token. If the page is displayed as normal, then the token is still active. Use trial and error to determine how long any session expiration time- out is, or whether a token can still be used days after the last request using it.

Weaknesses in Session Token Handling Client Exposure to Token Hijacking Hack steps (1): Identify any cross-site scripting vulnerabilities within the application and determine whether these can be exploited to capture the session tokens of other users If the application issues session tokens to unauthenticated, obtain a token and perform a login.

Hack steps (2): Check whether the application is willing to return to the login page eventhough you are already authenticated, sumbit another login as a different user using the same token. If it does not issue a fresh token, it is vulnerable to session fixation Identify the format of session tokens used by the application. Modify your token to an invented value that is validly formed, and attempt to login. If the application allows you to create an authenticated session using an invented token, then it is vulnerable to session fixation.

Securing Session Management In order to perform session management in a secure manner: Generate strong tokens Protect Tokens throughout Their Lifecycle should only ever be transmitted over HTTPS never be transmitted in the URL Logout functionality should be implemented Session expiration should be implemented after a suitable period of inactivity (e.g., 10 minutes). Etc. Firstly, generate strong tokens. The tokens used to re-identify a user between successive requests should be generated in a manner that does not provide any scope for an attacker who obtains a large sample of tokens from the application in the usual way to pre- dict or extrapolate the tokens issued to other users. The most effective token generation mechanisms are those that: - use an extremely large set of possible values, and contain a strong source of pseudo-randomness, ensuring an even and unpredictable spread of tokens across the range of possible values. Also, protect tokens throughout their lifecycle Having created a robust token whose value cannot be predicted, this token needs to be protected throughout its lifecycle from creation to disposal, to ensure that it is not disclosed to anyone other than the user to whom it is issued Should only ever be transmitted over HTTPS Never be transmitted in the URL Logout functionality should be implemented Session expiration should be implemented after a suitable period of inactivity (e.g., 10 minutes). And to defend session management mechanisms against attacks: -

Securing Session Management Per-page Tokens New page is created every time Prevents session fixation attacks a new page token is created every time a user requests an application page (as opposed to an image, for example) and is passed to the client in a cookie or a hidden field of an HTML form. Each time the user makes a request, the page token is validated against the last value issued, in addition to the normal validation of the main session token. In the case of a non-match, the entire session is terminated While the use of per-page tokens does impose some restrictions on navigation (for example, on use of the back and forward buttons and multi-window brows- ing), it effectively prevents session fixation attacks and ensures that the simulta- neous use of a hijacked session by a legitimate user and an attacker will quickly be blocked after both have made a single request