05-Web Application Vulnerabilities II (Website Attacks Tips)
05-Web Application Vulnerabilities II (Website Attacks Tips)
Alrehamy
Department of Information Security Year(III)-Term(I)-Lecture(#5)
Cookies purposes
Session management: Logins, shopping carts, game scores, or anything else
the server should remember.
1
College of Information Technology Lecturer: Dr. Hassan H. Alrehamy
Department of Information Security Year(III)-Term(I)-Lecture(#5)
Cookie Security
When a web application stores information in cookies, it must be kept in mind that
all cookie values are visible to, and can be changed by, the end user. Depending on
the application, you may want to use an opaque identifier that the server looks up,
or investigate alternative authentication/confidentiality mechanisms such as ( Web
Tokens). A cookie is associated with a domain. If this domain is the same as the
domain of the page you're on, the cookie is called a first-party cookie. If the domain
is different, it's a third-party cookie. While the server hosting a web page sets first-
party cookies, the page may contain images or other components stored on servers
in other domains (for example, ad banners) that may set third-party cookies. These
are mainly used for advertising and tracking across the web. For example, the types
of cookies used by Google. A third-party server can create a profile of a user's
browsing history and habits based on cookies sent to it by the same browser when
accessing multiple sites. Firefox, by default, blocks third-party cookies that are
known to contain trackers. Third-party cookies (or just tracking cookies) may also
be blocked by other browser settings or extensions. Cookie blocking can cause some
third-party components (such as social media widgets) not to function as intended.
Depending on the programming language of a web application, a cookie can be
easily created as a set of key-value pairs. For example to create a cookie in ASP.Net
application:
HttpCookie userInfo = new HttpCookie("userInfo");
userInfo["UserName"] = "Alrehamy";
userInfo["UserLoc"] = "Iraq";
userInfo.Expires.Add(new TimeSpan(0, 1, 0));
Response.Cookies.Add(userInfo);
Or even:
Response.Cookies["userName"].Value = "Alrehamy";
Response.Cookies["userLocr"].Value = "Iraq";
Cookie is a text-based file stored on the client machine. This file is usually located on "C:\Document and
Settings\Currently_Login user\Cookie" path.
We need to import namespace called Systen.Web.HttpCookie before we use cookie.
2
College of Information Technology Lecturer: Dr. Hassan H. Alrehamy
Department of Information Security Year(III)-Term(I)-Lecture(#5)
3
College of Information Technology Lecturer: Dr. Hassan H. Alrehamy
Department of Information Security Year(III)-Term(I)-Lecture(#5)
different for each one. If you are using a single browser with multiple tabs then all
the tabs share the same Session Cookie. Now a hacker or attacker gets in and steals
the Cookie of "Browser 1" and updates the "Browser 2" Cookie. All the Session
information of "Browser 1" will be copied to "Browser 2". This can easily be done
by freely available tools or browser plugins like Modify Headers, Burp or Fiddler
etc.
Cookie-related Law Regulations
Legislation or regulations that cover the use of cookies include:
The General Data Privacy Regulation (GDPR) in the European Union
The ePrivacy Directive in the EU
The California Consumer Privacy Act
These regulations have global reach. They apply to any site on the World Wide Web
that users from these jurisdictions access. These regulations include requirements
such as:
Notifying users that your site uses cookies.
Allowing users to opt out of receiving some or all cookies.
Allowing users to use the bulk of your service without receiving cookies.
There may be other regulations that govern the use of cookies in your locality. The
burden is on you to know and comply with these regulations.