CAPEC-31: Accessing/Intercepting/Modifying HTTP Cookies
This attack relies on the use of HTTP Cookies to store credentials, state information and other critical data on client systems. There are several different forms of this attack. The first form of this attack involves accessing HTTP Cookies to mine for potentially sensitive data contained therein. The second form involves intercepting this data as it is transmitted from client to server. This intercepted information is then used by the adversary to impersonate the remote user/session. The third form is when the cookie's content is modified by the adversary before it is sent back to the server. Here the adversary seeks to convince the target server to operate on this falsified information.
Last updated
Overview
CAPEC-31 (Accessing/Intercepting/Modifying HTTP Cookies) is a detailed-level attack pattern catalogued by MITRE in the Common Attack Pattern Enumeration and Classification (CAPEC). It describes a recurring method attackers use to exploit software weaknesses.
How the attack works
The phases an attacker typically follows.
- Step 1Explore
[Obtain copy of cookie] The adversary first needs to obtain a copy of the cookie. The adversary may be a legitimate end user wanting to escalate privilege, or could be somebody sniffing on a network to get a copy of HTTP cookies.
- Sniff cookie using a network sniffer such as Wireshark
- Obtain cookie using a utility such as the Firefox Cookie Manager, Chrome DevTools or AnEC Cookie Editor.
- Steal cookie via a cross-site scripting attack.
- Guess cookie contents if it contains predictable information.
- Step 2Experiment
[Obtain sensitive information from cookie] The adversary may be able to get sensitive information from the cookie. The web application developers may have assumed that cookies are not accessible by end users, and thus, may have put potentially sensitive information in them.
- If cookie shows any signs of being encoded using a standard scheme such as base64, decode it.
- Analyze the cookie's contents to determine whether it contains any sensitive information.
- Step 3Experiment
[Modify cookie to subvert security controls.] The adversary may be able to modify or replace cookies to bypass security controls in the application.
- Modify logical parts of cookie and send it back to server to observe the effects.
- Modify numeric parts of cookie arithmetically and send it back to server to observe the effects.
- Modify cookie bitwise and send it back to server to observe the effects.
- Replace cookie with an older legitimate cookie and send it back to server to observe the effects. This technique would be helpful in cases where the cookie contains a "points balance" for a given user where the points have some value. The user may spend their points and then replace their cookie with an older one to restore their balance.
What the attacker needs
Prerequisites
- Target server software must be a HTTP daemon that relies on cookies.
- The cookies must contain sensitive information.
- The adversary must be able to make HTTP requests to the server, and the cookie must be contained in the reply.
Skills required
- Low skill: To overwrite session cookie data, and submit targeted attacks via HTTP
- High skill: Exploiting a remote buffer overflow generated by attack
Resources required
- A utility that allows for the viewing and modification of cookies. Many modern web browsers support this behavior.
Consequences
What a successful CAPEC-31 attack can achieve.
Read Data
Affects: Confidentiality
Modify Data
Affects: Integrity
Gain Privileges
Affects: Confidentiality, Access Control, Authorization
How to mitigate it
Defenses that reduce the risk of CAPEC-31.
- Design: Use input validation for cookies
- Design: Generate and validate MAC for cookies
- Implementation: Use SSL/TLS to protect cookie in transit
- Implementation: Ensure the web server implements all relevant security patches, many exploitable buffer overflows are fixed in patches issued for the software.
Examples
There are two main attack vectors for exploiting poorly protected session variables like cookies. One is the local machine itself which can be exploited directly at the physical level or indirectly through XSS and phishing. In addition, the adversary in the middle attack (CAPEC-94) relies on a network sniffer, proxy, or other intermediary to intercept the subject's credentials and use them to impersonate the digital subject on the host. The issue is that once the credentials are intercepted, impersonation is trivial for the adversary to accomplish if no other protection mechanisms are in place. See also: CVE-2010-5148 , CVE-2016-0353
Terminology & mappings
Mapped taxonomies
- ATTACK: Steal Web Session Cookie (1539)
Frequently asked questions
Common questions about CAPEC-31.
- What is CAPEC-31?
- This attack relies on the use of HTTP Cookies to store credentials, state information and other critical data on client systems. There are several different forms of this attack. The first form of this attack involves accessing HTTP Cookies to mine for potentially sensitive data contained therein. The second form involves intercepting this data as it is transmitted from client to server. This intercepted information is then used by the adversary to impersonate the remote user/session. The third form is when the cookie's content is modified by the adversary before it is sent back to the server. Here the adversary seeks to convince the target server to operate on this falsified information.
- How does a Accessing/Intercepting/Modifying HTTP Cookies attack work?
- It typically unfolds over 3 phases. It begins with: [Obtain copy of cookie] The adversary first needs to obtain a copy of the cookie. The adversary may be a legitimate end user wanting to escalate privilege, or could be somebody sniffing on a network to get a copy of HTTP cookies.
- How do you prevent CAPEC-31?
- Design: Use input validation for cookies
- What weaknesses does CAPEC-31 target?
- CAPEC-31 exploits 11 CWE weaknesses, including CWE-20 (Improper Input Validation), CWE-113 (Improper Neutralization of CRLF Sequences in HTTP Headers), CWE-302 (Authentication Bypass by Assumed-Immutable Data) and CWE-311 (Missing Encryption of Sensitive Data).
- How severe is CAPEC-31?
- MITRE rates CAPEC-31 as High severity with high likelihood of attack.
Sources
- [1]Exploiting Software: How to Break Code (2004)
References
Attack-pattern data is sourced from the MITRE CAPEC catalog (v3.9). Weakness associations link to the corresponding CWE entries on RadicalNotion.AI.
Defend against CAPEC-31
Track the CVEs and weaknesses this technique exploits, with AI-written analysis and remediation steps.