Chapter 3
Chapter 3
Sessions
What is a ● A web session is a series of
contiguous actions by a visitor on an
web individual website within a given time
session? frame.
● This could include your search engine
searches, filling out a form to receive
content, scrolling on a website page,
adding items to a shopping cart,
researching airfare, or which pages
you viewed on a single website. Any
interaction that you have with a
single website is recorded as a web
session to that website property.
What is a web
session?
Session vs Cookies
Cookies
Session Cookies are text files stored on the client
computer and they are kept of use
● A session creates a file in a temporary tracking purpose. Server script sends a
directory on the server where registered set of cookies to the browser. For
session variables and their values are example, name, age, or identification
stored. This data will be available to all number etc. The browser stores this
pages on the site during that visit. information on a local machine for future
use.
● A session ends when the user closes the
When next time browser sends any
browser or after leaving the site, the request to web server then it sends those
server will terminate the session after a cookies information to the server and
predetermined period of time, commonly server uses that information to identify
30 minutes duration. the use
Session ● Session management is the rule set that governs interactions
Management and between a web-based application and users. Browsers and websites
use HTTP to communicate, and a web session is a series of HTTP
User requests and response transactions created by the same user.
1. Django- Django is the web framework for choice for most Python users.
2. Rails- Ruby on Rails is the web framework of choice for Ruby developers. It has
a strong community and aims to make web development fast and simple.
3. ASP.Net Core-- ASP.NET Core is the newest kid on the block. Recently released
by Microsoft, ASP.NET Core looks to bring .NET development into the future by
providing a cross-platform, high-performance, open source framework for
building cloud-first web applications.
Management
attackers to be recognized as valid
website users.
Vulnerabilities ● 82% percent of Web technology
vulnerabilities relate to Web applications
and that 34% of major Web application
vulnerabilities affect session management
mechanisms.
● Hijacking a Web navigation session is one
of the most studied kinds of attacks
Session Management Vulnerabilities
● Session management tracks a user’s activity across sessions of interaction with a website.
Its most widespread use is login, but it’s also used when the user isn’t required to log in, as
in the case of many ecommerce websites or Web-based social networks.
● The typical way to implement it is to associate each user with a unique identifier—the
session ID or session token. Token implementation typically employs one of these
mechanisms:
3. Tokens, once created by the server, are added to each link the user clicks on.
● Session management also employs other mechanisms. For example, some applications use
HTTP authentication. The browser could use the HTTP header, rather than the
application’s Web page code, to send user credentials. This kind of authentication isn’t
common
Session Management Vulnerabilities
● When a user logs out, the server removes that token from the user’s
browser, but if the user (or attacker) sends a previously used token,
the server keeps accepting it. In the worst case, the server receives
no request at logout and doesn’t invalidate the session. If an
attacker obtains this token, the attacker could use the session, just
as the user who never logged out could.
Log sniffing.
● This attack obtains the token by analyzing log files in the different systems
involved in client server communication. There are two enabling vulnerabilities.
2. The token is transmitted as a hidden field, and the server accepts GET requests
in place of POST requests.
Cache sniffing.
● If the attacker accesses the browser or proxy cache, the attacker could obtain the
token in any format containing it (cookie, URL parameter, or hidden field).
Possible Attacks -Session Prediction
● Even if the Web application doesn’t allow interception of the token and the
token-generation algorithm is strong, the attacker can “guess” a token and
connect with the website as a legitimate user.
1. Token tampering
2. Brute-force attack
● The attacker can collect different tokens and analyze their randomness with
tools such as the Burp Suite Sequencer (http://portswigger.net/suite).
Session Fixation
What Are 1.
● Here’s how cookie are intended to be used:
Session management. For example, cookies let
Session cookies
● Used only while navigating a website. They
are stored in random access memory and are
never written to the hard drive. When the
session ends, session cookies are
automatically deleted. They also help the
"back" button or third-party anonymizer
plugins work. These plugins are designed for
specific browsers to work and help maintain
user privacy.
What are the different
types of HTTP Cookies?
Persistent cookies
● It’s remained on a computer indefinitely, although
many include an expiration date and are
automatically removed when that date is reached.
Persistent cookies are used for two primary
purposes:
The session management implementation defines the exchange mechanism that will be
used between the user and the web application to share and continuously exchange the
session ID.
There are multiple mechanisms available in HTTP to maintain session state within web
applications, such as cookies (standard HTTP header), URL parameters, URL arguments on
GET requests, body arguments on POST requests, such as hidden form fields (HTML forms),
or proprietary HTTP headers.
Session Management and User Authentication