SlideShare a Scribd company logo
Web Application Security (PHP)
Zakieh Alizadeh
zakiehalizadeh@gmail.com
APA Laboratory – Ferdowsi University of Mashhad
Session 8
Session Management
Session Management
Session Management
 Description Mechanism of Cookies
 Introducing Session Management Attacks
Strategies Of Session Storage
Session Management Testing
Strategies for Secure Session Management
Mechanism of Cookies
HTTP session token
 Problem : HTTP is stateless
o Solution : HTTP Cookies
 The client usually stores cookies and sends the token as an
o HTTP cookie
o parameter in GET or POST queries.
Mechanism of Cookies
 What is Sessions
 A session is a semi-permanent interactive information interchange, also known as
a dialogue, a conversation or a meeting, between a computer and user .
 An established communication session may involve more than one message in
each direction.
 A session is typically, but not always, stateful, meaning that at least one of the
communicating parts needs to save information.
 where the communication consists of independent requests with responses.
Such as HTTP.
Mechanism of Cookies
Session ID
 A session identifier, session ID or session token is a piece of data that is
used in network communications (often over HTTP) to identify a session.
 A session ID is often a long, randomly generated string to decrease the
brute-force search.
 The reason to use session tokens is :
o client only has to handle the identifier (a small piece of data that hasn’t
security risk) - all session data is stored on the server and is not
transmit
Mechanism of Cookies
HTTP session token
Mechanism of Cookies
HTTP session token
Mechanism of Cookies
HTTP session token
Http Cookies
HTTP Cookies
 The following is a list of the attributes that can be set for each cookie :
o secure - only send the cookie if the request is being sent over a
secure channel such as HTTPS.
o HttpOnly - it does not allow the cookie to be accessed via a client side
script such as JavaScript.
• Note that not all browsers support this functionality.
o domain - compare against the domain of the server in which the URL
is being requested
Http Cookies
HTTP Cookies
 The following is a list of the attributes that can be set for each cookie :
o path - In addition to the domain, the URL path can be specified for
which the cookie is valid. If the domain and path match, then the
cookie will be sent in the request.
o expires - This attribute is used to set persistent cookies, since the
cookie does not expire until the set date is exceeded.
Http Cookies
 HTTP Cookies : PHP function
 session_set_cookie_params() The effect of this function only lasts for the duration of
the script.
 Thus, you need to call it for every request and before session_start() is called.
 This function updates the runtime ini values of the corresponding PHP ini configuration
session_set_cookie_params ($lifetime , $path , $domain, $secure = false , $httponly = false)
Http Cookies
 HTTP Cookies : PHP function
 setcookie() defines a cookie to be sent along with the rest of the HTTP headers.
 Like other headers, cookies must be sent before any output from your script (this is a
protocol restriction).
 Once the cookies have been set, they can be accessed on the next page load with the
$_COOKIE
Setcookie ( $name , $value , $expire = 0 , $path , $domain , $secure =false , $httponly = false )
Session Management
Session management
 session management is the process of keeping track of a user's activity
across sessions of interaction with the system.
Session Management
 Description Mechanism of Cookies
 Introducing Session Management Attacks
Strategies Of Session Storage
Session Management Testing
Strategies for Secure Session Management
Session Attacks
Sessions Attack
 Session Fixation
 Session Brute-Forcing
 Session Hijacking
 Session Poisoning
Sessions Attack
Session fixation
 session fixation attacks allows one person to fixate (set) another person's
session identifier (SID).
 Hacker abtains valid session witout hijacking or sniffing, he fix valid
session for victim.
 Most rely on session identifiers being accepted from URLs (query string)
or POST data.
Sessions Attack
Session fixation
 Session fixation vulnerabilities occur when:
 A web application authenticates a user without first invalidating the
existing session ID, thereby continuing to use the session ID already
associated with the user.
 An attacker is able to force a known session ID on a user so that, once the
user authenticates, the attacker has access to the authenticated session.
Sessions Attack
Session fixation
1
3
2
4
No new
Cookie Set
In HTTP
Response
successfully authenticate request
Sessions Attack
Session fixation
Sessions Attack
Session fixation : Countermeasures
 Do not accept session identifiers from GET / POST variables
 Accept only server-generated SIDs
 Logout function
 Destroy session if Referrer is suspicious
 Time-out old SIDs
 Verify that additional information is consistent throughout session
 User Agent
Sessions Attack
Session fixation : Defense in Depth
 Enable HTTPS (to protect against other problems)
 Correct configuration (do not accept external SIDs, set time-out, etc.)
o Ini_set(“session_use_only_cookie”,1)
 Perform session_regeneration, support log-out, etc.
Sessions Attack
Session hijacking
 session hijacking is the exploitation of a valid sessionID to gain unauthorized
access to information or services in a computer system.
Sessions Attack
Session hijacking : Methods
 Session fixation
 Session sidejacking
o where the attacker uses packet sniffing
o Many web sites use SSL encryption for login pages to prevent
attackers from seeing the password, but do not use encryption for the
rest of the site once authenticated.

Sessions Attack
Session hijacking : Methods
 obtaining the file or memory contents of the appropriate part of either
the user's computer or the server.
 Cross-site scripting, where the attacker tricks the user's computer into
running code which is treated as trustworthy because it appears to
belong to the server, allowing the attacker to obtain a copy of the cookie
or perform other operations.
Sessions Attack
Session hijacking : Countermeasures
 Provide a method for users to log out of the application.
o Logging out button should clear
o all session state and remove or invalidate any residual cookies.
 Set short expiry times on persistent cookies, no more than a day.
 Do not store session tokens in the URL or other trivially modified data
entry point.
Sessions Attack
Brute Force Session Identifier
 Session tokens are generated in
o a predictable fashion
o key space that is too small to prevent guessing a token in reasonable
time.
o The application does not detect and prevent session brute forcing
attempts.
 A session ID must not be valid over two currently active SSL connections
at the same time.
Sessions Attack
Brute Force SessionID: Countermeasures
 Session identifiers should be at least 128 bits(32byte) long to prevent
brute-force session guessing attacks.
 Limit the number of unique session tokens you see from the same IP
address (ie 20 in thelast five minutes).
 Use Strong Session Cryptographic Algorithms
o Use Framework session management impelemention
Sessions Attack
Session poisoning
 This should actually be called session injection, as it is just one more
variable injection type of attack. If you allow user input into session
variables, make sure you validate the data.
 Typically a server application that is vulnerable to this type of exploit will
copy user input into session variables.
Sessions Attack
Session poisoning :Example
 Exploiting ambiguous or dual use of same session variable
 Exploiting scripts allowing writes to arbitrary session variables
$var = $_GET["something"];
$_SESSION["$var"] = $var2;
vulnerable.php?something=SESSION_VAR_TO_POISON
Sessions Attack
Session poisoning :Example
 Session poisoning attacks enabled by php.ini: register_globals = on
 It is possible for attacker to cause both conditions to be false.
 php.ini is misconfigured (register_globals = on), which allows $var default
value to be controlled by GPC (GET, POST, or COOKIE) input.
if ($condition1) { $var = 'SOMETHING'; };
if ($condition2) { $var = 'OTHER'; };
$_SESSION["$var"] = $var2;
Session Storage
Session Storage
 Sessions data can Store in :
o Files (on server)
o database.
 Sessions data that Storage in Files
o Better performance ,But weak security
 Sessions data that Storage in Database
o Better security,But weak performance
Session Management
 Description Mechanism of Cookies
 Introducing Session Management Attacks
Strategies Of Session Storage
Session Management Testing
Strategies for Secure Session Management
Session Management Testing
Session Management Testing
Test Desc
Testing for Session
Management Schema
 1-cookie collection: 2-cookie reverse engineering 3- cookie
manipulation
 The session tokens tested for their randomness, uniqueness,
resistance to statistical and cryptographic analysis
Testing for Cookies
attributes
Testing for secure or httponly setting
Are all Set-Cookie directives tagged as Secure?
What Expires= times are used on persistent cookies
Testing for Session
Fixation  no new cookie has been issued upon a successful authentication
Session Management Testing
Session Management Testing
Test Desc
Testing for Exposed
Session Variables
How are Session IDs transferred? E.g., GET, POST, Form Field
Are Session IDs always sent over encrypted transport by default?
Testing for CSRF
URL being tested; for example
 u = http://www.example.com/action
build an html page containing the http request referencing URL u
Regeneration of
Session Tokens
•Note the Session ID at the start and after every significant test
transaction.
If the session ID never changes,Application be at risk
Session Management
 Description Mechanism of Cookies
 Introducing Session Management Attacks
Strategies Of Session Storage
Session Management Testing
Strategies for Secure Session Management
Session Management
Session Management : Countermeasures
 Avoid Weak Session Cryptographic Algorithms
 Use Appropriate Key Space
 Impelement Session Time-out
 Regeneration of Session Tokens
o prior to any significant transaction
o after a certain number of requests
o after as a function of time, say every 20 minutes or so.
o Problem : when using third party software
Session Management
Session Management : Countermeasures
 Using framework implementation session management.
 Authorization and role data should be stored on the server side only.
 Presentation flags (such as theme or user language) can belong in
cookies.
 Tie the session to a particular browser by using a hash of the server-side
IP address.
Session Management

More Related Content

PDF
Session4-Authentication
zakieh alizadeh
 
PDF
Session3 data-validation-sql injection
zakieh alizadeh
 
PDF
S5-Authorization
zakieh alizadeh
 
PDF
Session10-PHP Misconfiguration
zakieh alizadeh
 
PDF
Session7-XSS & CSRF
zakieh alizadeh
 
PDF
Session2-Application Threat Modeling
zakieh alizadeh
 
PDF
Session9-File Upload Security
zakieh alizadeh
 
PDF
Common Web Application Attacks
Ahmed Sherif
 
Session4-Authentication
zakieh alizadeh
 
Session3 data-validation-sql injection
zakieh alizadeh
 
S5-Authorization
zakieh alizadeh
 
Session10-PHP Misconfiguration
zakieh alizadeh
 
Session7-XSS & CSRF
zakieh alizadeh
 
Session2-Application Threat Modeling
zakieh alizadeh
 
Session9-File Upload Security
zakieh alizadeh
 
Common Web Application Attacks
Ahmed Sherif
 

What's hot (20)

PPT
Application Security Part 1 Threat Defense In Client Server Applications ...
Greg Sohl
 
PPT
Owasp Top 10 And Security Flaw Root Causes
Marco Morana
 
PDF
OWASP Secure Coding Practices - Quick Reference Guide
Ludovic Petit
 
PPT
Secure code practices
Hina Rawal
 
PPT
Intro to Web Application Security
Rob Ragan
 
PDF
2013 OWASP Top 10
bilcorry
 
ODP
Top 10 Web Security Vulnerabilities
Carol McDonald
 
PPTX
Web application attacks
hruth
 
PPTX
PCI Security Requirements - secure coding
Haitham Raik
 
PPTX
PCI security requirements secure coding and code review 2014
Haitham Raik
 
PPTX
Web application security
Kapil Sharma
 
PPTX
OWASP Top 10 Proactive Controls
Katy Anton
 
PPT
Introduction to Web Application Penetration Testing
Anurag Srivastava
 
PPT
Top 10 Web Security Vulnerabilities (OWASP Top 10)
Brian Huff
 
PPTX
Owasp first5 presentation
Ashwini Paranjpe
 
PPTX
OWASP top 10-2013
tmd800
 
PDF
Owasp top 10 2013
Edouard de Lansalut
 
PPT
Owasp Top 10 - Owasp Pune Chapter - January 2008
abhijitapatil
 
PDF
Web Application Firewall: Suckseed or Succeed
Prathan Phongthiproek
 
Application Security Part 1 Threat Defense In Client Server Applications ...
Greg Sohl
 
Owasp Top 10 And Security Flaw Root Causes
Marco Morana
 
OWASP Secure Coding Practices - Quick Reference Guide
Ludovic Petit
 
Secure code practices
Hina Rawal
 
Intro to Web Application Security
Rob Ragan
 
2013 OWASP Top 10
bilcorry
 
Top 10 Web Security Vulnerabilities
Carol McDonald
 
Web application attacks
hruth
 
PCI Security Requirements - secure coding
Haitham Raik
 
PCI security requirements secure coding and code review 2014
Haitham Raik
 
Web application security
Kapil Sharma
 
OWASP Top 10 Proactive Controls
Katy Anton
 
Introduction to Web Application Penetration Testing
Anurag Srivastava
 
Top 10 Web Security Vulnerabilities (OWASP Top 10)
Brian Huff
 
Owasp first5 presentation
Ashwini Paranjpe
 
OWASP top 10-2013
tmd800
 
Owasp top 10 2013
Edouard de Lansalut
 
Owasp Top 10 - Owasp Pune Chapter - January 2008
abhijitapatil
 
Web Application Firewall: Suckseed or Succeed
Prathan Phongthiproek
 
Ad

Similar to S8-Session Managment (20)

PPTX
Cookies and Session
KoraStats
 
ODP
Session Management & Cookies In Php
Harit Kothari
 
PDF
PHP-Cookies-Sessions.pdf
HumphreyOwuor1
 
PPT
Phpnw security-20111009
Paul Lemon
 
PPT
Lecture8 php page control by okello erick
okelloerick
 
PDF
Web app development_cookies_sessions_14
Hassen Poreya
 
PPT
Php ssession - cookies -introduction
Programmer Blog
 
PDF
Hacking Web Aplications using Cookie Poisoning
Sumutiu Marius
 
PDF
wapt lab 6 - converted (2).pdfwaptLab09 tis lab is used for college lab exam
imgautam076
 
PDF
4.4 PHP Session
Jalpesh Vasa
 
PDF
Top 10 Web Application vulnerabilities
Terrance Medina
 
PDF
Security in php
Jalpesh Vasa
 
PDF
Security 202 - Are you sure your site is secure?
ConFoo
 
PPT
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
SreejithVP7
 
PPT
Session,cookies
rkmourya511
 
PPT
Php 07-cookies-sessions
YUSRA FERNANDO
 
PPTX
StateManagementintPHPStateManagementinPHP.pptx
sneha852132
 
PPT
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
pondypaiyan
 
Cookies and Session
KoraStats
 
Session Management & Cookies In Php
Harit Kothari
 
PHP-Cookies-Sessions.pdf
HumphreyOwuor1
 
Phpnw security-20111009
Paul Lemon
 
Lecture8 php page control by okello erick
okelloerick
 
Web app development_cookies_sessions_14
Hassen Poreya
 
Php ssession - cookies -introduction
Programmer Blog
 
Hacking Web Aplications using Cookie Poisoning
Sumutiu Marius
 
wapt lab 6 - converted (2).pdfwaptLab09 tis lab is used for college lab exam
imgautam076
 
4.4 PHP Session
Jalpesh Vasa
 
Top 10 Web Application vulnerabilities
Terrance Medina
 
Security in php
Jalpesh Vasa
 
Security 202 - Are you sure your site is secure?
ConFoo
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
SreejithVP7
 
Session,cookies
rkmourya511
 
Php 07-cookies-sessions
YUSRA FERNANDO
 
StateManagementintPHPStateManagementinPHP.pptx
sneha852132
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
pondypaiyan
 
Ad

More from zakieh alizadeh (8)

PDF
Session11-NoSQL InjectionPHP Injection
zakieh alizadeh
 
PDF
Session6-Protecct Sensetive Data
zakieh alizadeh
 
PDF
Session1-Introduce Http-HTTP Security headers
zakieh alizadeh
 
PDF
yii framework
zakieh alizadeh
 
PDF
Web security Contents
zakieh alizadeh
 
PDF
Validating and Sanitizing User Data
zakieh alizadeh
 
PPSX
Session3 data-validation
zakieh alizadeh
 
PDF
Introduce Yii
zakieh alizadeh
 
Session11-NoSQL InjectionPHP Injection
zakieh alizadeh
 
Session6-Protecct Sensetive Data
zakieh alizadeh
 
Session1-Introduce Http-HTTP Security headers
zakieh alizadeh
 
yii framework
zakieh alizadeh
 
Web security Contents
zakieh alizadeh
 
Validating and Sanitizing User Data
zakieh alizadeh
 
Session3 data-validation
zakieh alizadeh
 
Introduce Yii
zakieh alizadeh
 

Recently uploaded (20)

PDF
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
PPTX
Smart Panchayat Raj e-Governance App.pptx
Rohitnikam33
 
DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PDF
Build Multi-agent using Agent Development Kit
FadyIbrahim23
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PDF
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
PDF
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
PPTX
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
PDF
Appium Automation Testing Tutorial PDF: Learn Mobile Testing in 7 Days
jamescantor38
 
PDF
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
ESUG
 
PDF
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
PPTX
TestNG for Java Testing and Automation testing
ssuser0213cb
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PDF
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 
PPTX
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
PPTX
PFAS Reporting Requirements 2026 Are You Submission Ready Certivo.pptx
Certivo Inc
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PDF
Microsoft Teams Essentials; The pricing and the versions_PDF.pdf
Q-Advise
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
Smart Panchayat Raj e-Governance App.pptx
Rohitnikam33
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
Build Multi-agent using Agent Development Kit
FadyIbrahim23
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
Appium Automation Testing Tutorial PDF: Learn Mobile Testing in 7 Days
jamescantor38
 
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
ESUG
 
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
TestNG for Java Testing and Automation testing
ssuser0213cb
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
PFAS Reporting Requirements 2026 Are You Submission Ready Certivo.pptx
Certivo Inc
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
Microsoft Teams Essentials; The pricing and the versions_PDF.pdf
Q-Advise
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 

S8-Session Managment

  • 1. Web Application Security (PHP) Zakieh Alizadeh [email protected] APA Laboratory – Ferdowsi University of Mashhad
  • 4. Session Management  Description Mechanism of Cookies  Introducing Session Management Attacks Strategies Of Session Storage Session Management Testing Strategies for Secure Session Management
  • 5. Mechanism of Cookies HTTP session token  Problem : HTTP is stateless o Solution : HTTP Cookies  The client usually stores cookies and sends the token as an o HTTP cookie o parameter in GET or POST queries.
  • 6. Mechanism of Cookies  What is Sessions  A session is a semi-permanent interactive information interchange, also known as a dialogue, a conversation or a meeting, between a computer and user .  An established communication session may involve more than one message in each direction.  A session is typically, but not always, stateful, meaning that at least one of the communicating parts needs to save information.  where the communication consists of independent requests with responses. Such as HTTP.
  • 7. Mechanism of Cookies Session ID  A session identifier, session ID or session token is a piece of data that is used in network communications (often over HTTP) to identify a session.  A session ID is often a long, randomly generated string to decrease the brute-force search.  The reason to use session tokens is : o client only has to handle the identifier (a small piece of data that hasn’t security risk) - all session data is stored on the server and is not transmit
  • 11. Http Cookies HTTP Cookies  The following is a list of the attributes that can be set for each cookie : o secure - only send the cookie if the request is being sent over a secure channel such as HTTPS. o HttpOnly - it does not allow the cookie to be accessed via a client side script such as JavaScript. • Note that not all browsers support this functionality. o domain - compare against the domain of the server in which the URL is being requested
  • 12. Http Cookies HTTP Cookies  The following is a list of the attributes that can be set for each cookie : o path - In addition to the domain, the URL path can be specified for which the cookie is valid. If the domain and path match, then the cookie will be sent in the request. o expires - This attribute is used to set persistent cookies, since the cookie does not expire until the set date is exceeded.
  • 13. Http Cookies  HTTP Cookies : PHP function  session_set_cookie_params() The effect of this function only lasts for the duration of the script.  Thus, you need to call it for every request and before session_start() is called.  This function updates the runtime ini values of the corresponding PHP ini configuration session_set_cookie_params ($lifetime , $path , $domain, $secure = false , $httponly = false)
  • 14. Http Cookies  HTTP Cookies : PHP function  setcookie() defines a cookie to be sent along with the rest of the HTTP headers.  Like other headers, cookies must be sent before any output from your script (this is a protocol restriction).  Once the cookies have been set, they can be accessed on the next page load with the $_COOKIE Setcookie ( $name , $value , $expire = 0 , $path , $domain , $secure =false , $httponly = false )
  • 15. Session Management Session management  session management is the process of keeping track of a user's activity across sessions of interaction with the system.
  • 16. Session Management  Description Mechanism of Cookies  Introducing Session Management Attacks Strategies Of Session Storage Session Management Testing Strategies for Secure Session Management
  • 17. Session Attacks Sessions Attack  Session Fixation  Session Brute-Forcing  Session Hijacking  Session Poisoning
  • 18. Sessions Attack Session fixation  session fixation attacks allows one person to fixate (set) another person's session identifier (SID).  Hacker abtains valid session witout hijacking or sniffing, he fix valid session for victim.  Most rely on session identifiers being accepted from URLs (query string) or POST data.
  • 19. Sessions Attack Session fixation  Session fixation vulnerabilities occur when:  A web application authenticates a user without first invalidating the existing session ID, thereby continuing to use the session ID already associated with the user.  An attacker is able to force a known session ID on a user so that, once the user authenticates, the attacker has access to the authenticated session.
  • 20. Sessions Attack Session fixation 1 3 2 4 No new Cookie Set In HTTP Response successfully authenticate request
  • 22. Sessions Attack Session fixation : Countermeasures  Do not accept session identifiers from GET / POST variables  Accept only server-generated SIDs  Logout function  Destroy session if Referrer is suspicious  Time-out old SIDs  Verify that additional information is consistent throughout session  User Agent
  • 23. Sessions Attack Session fixation : Defense in Depth  Enable HTTPS (to protect against other problems)  Correct configuration (do not accept external SIDs, set time-out, etc.) o Ini_set(“session_use_only_cookie”,1)  Perform session_regeneration, support log-out, etc.
  • 24. Sessions Attack Session hijacking  session hijacking is the exploitation of a valid sessionID to gain unauthorized access to information or services in a computer system.
  • 25. Sessions Attack Session hijacking : Methods  Session fixation  Session sidejacking o where the attacker uses packet sniffing o Many web sites use SSL encryption for login pages to prevent attackers from seeing the password, but do not use encryption for the rest of the site once authenticated. 
  • 26. Sessions Attack Session hijacking : Methods  obtaining the file or memory contents of the appropriate part of either the user's computer or the server.  Cross-site scripting, where the attacker tricks the user's computer into running code which is treated as trustworthy because it appears to belong to the server, allowing the attacker to obtain a copy of the cookie or perform other operations.
  • 27. Sessions Attack Session hijacking : Countermeasures  Provide a method for users to log out of the application. o Logging out button should clear o all session state and remove or invalidate any residual cookies.  Set short expiry times on persistent cookies, no more than a day.  Do not store session tokens in the URL or other trivially modified data entry point.
  • 28. Sessions Attack Brute Force Session Identifier  Session tokens are generated in o a predictable fashion o key space that is too small to prevent guessing a token in reasonable time. o The application does not detect and prevent session brute forcing attempts.  A session ID must not be valid over two currently active SSL connections at the same time.
  • 29. Sessions Attack Brute Force SessionID: Countermeasures  Session identifiers should be at least 128 bits(32byte) long to prevent brute-force session guessing attacks.  Limit the number of unique session tokens you see from the same IP address (ie 20 in thelast five minutes).  Use Strong Session Cryptographic Algorithms o Use Framework session management impelemention
  • 30. Sessions Attack Session poisoning  This should actually be called session injection, as it is just one more variable injection type of attack. If you allow user input into session variables, make sure you validate the data.  Typically a server application that is vulnerable to this type of exploit will copy user input into session variables.
  • 31. Sessions Attack Session poisoning :Example  Exploiting ambiguous or dual use of same session variable  Exploiting scripts allowing writes to arbitrary session variables $var = $_GET["something"]; $_SESSION["$var"] = $var2; vulnerable.php?something=SESSION_VAR_TO_POISON
  • 32. Sessions Attack Session poisoning :Example  Session poisoning attacks enabled by php.ini: register_globals = on  It is possible for attacker to cause both conditions to be false.  php.ini is misconfigured (register_globals = on), which allows $var default value to be controlled by GPC (GET, POST, or COOKIE) input. if ($condition1) { $var = 'SOMETHING'; }; if ($condition2) { $var = 'OTHER'; }; $_SESSION["$var"] = $var2;
  • 33. Session Storage Session Storage  Sessions data can Store in : o Files (on server) o database.  Sessions data that Storage in Files o Better performance ,But weak security  Sessions data that Storage in Database o Better security,But weak performance
  • 34. Session Management  Description Mechanism of Cookies  Introducing Session Management Attacks Strategies Of Session Storage Session Management Testing Strategies for Secure Session Management
  • 35. Session Management Testing Session Management Testing Test Desc Testing for Session Management Schema  1-cookie collection: 2-cookie reverse engineering 3- cookie manipulation  The session tokens tested for their randomness, uniqueness, resistance to statistical and cryptographic analysis Testing for Cookies attributes Testing for secure or httponly setting Are all Set-Cookie directives tagged as Secure? What Expires= times are used on persistent cookies Testing for Session Fixation  no new cookie has been issued upon a successful authentication
  • 36. Session Management Testing Session Management Testing Test Desc Testing for Exposed Session Variables How are Session IDs transferred? E.g., GET, POST, Form Field Are Session IDs always sent over encrypted transport by default? Testing for CSRF URL being tested; for example  u = http://www.example.com/action build an html page containing the http request referencing URL u Regeneration of Session Tokens •Note the Session ID at the start and after every significant test transaction. If the session ID never changes,Application be at risk
  • 37. Session Management  Description Mechanism of Cookies  Introducing Session Management Attacks Strategies Of Session Storage Session Management Testing Strategies for Secure Session Management
  • 38. Session Management Session Management : Countermeasures  Avoid Weak Session Cryptographic Algorithms  Use Appropriate Key Space  Impelement Session Time-out  Regeneration of Session Tokens o prior to any significant transaction o after a certain number of requests o after as a function of time, say every 20 minutes or so. o Problem : when using third party software
  • 39. Session Management Session Management : Countermeasures  Using framework implementation session management.  Authorization and role data should be stored on the server side only.  Presentation flags (such as theme or user language) can belong in cookies.  Tie the session to a particular browser by using a hash of the server-side IP address.