1855
Language : Not Language-Specific (Prevalence = Undetermined)
Technology : Web Based (Prevalence = Undetermined)
Background Details
An HTTP cookie is a small piece of data attributed to a specific website and stored on the user's
computer by the user's web browser. This data can be leveraged for a variety of purposes including
saving information entered into form fields, recording user activity, and for authentication purposes.
Cookies used to save or record information generated by the user are accessed and modified
by script code embedded in a web page. While cookies used for authentication are created by
the website's server and sent to the user to be attached to future requests. These authentication
cookies are often not meant to be accessed by the web page sent to the user, and are instead just
supposed to be attached to future requests to verify authentication details.
Likelihood Of Exploit
Medium
Common Consequences
Scope Impact Likelihood
Confidentiality Read Application Data
If the HttpOnly flag is not set, then sensitive information
stored in the cookie may be exposed to unintended parties.
Integrity Gain Privileges or Assume Identity
If the cookie in question is an authentication cookie, then
not setting the HttpOnly flag may allow an adversary to
steal authentication data (e.g., a session ID) and assume
the identity of the user.
Detection Methods
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST),
can find some instances of this weakness by analyzing source code (or binary/compiled code)
without having to execute it. Typically, this is done by building a model of data flow and control
flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input)
with "sinks" (destinations where the data interacts with external components, a lower layer such
as the OS, etc.)
Effectiveness = High
Potential Mitigations
Phase: Implementation
Leverage the HttpOnly flag when setting a sensitive cookie in a response.
Effectiveness = High
While this mitigation is effective for protecting cookies from a browser's own scripting engine,
third-party components or plugins may have their own engines that allow access to cookies.
Attackers might also be able to use XMLHTTPResponse to read the headers directly and obtain
the cookie.
Demonstrative Examples
Example 1:
In this example, a cookie is used to store a session ID for a client's interaction with a website. The
intention is that the cookie will be sent to the website with each request made by the client.
The snippet of code below establishes a new cookie to hold the sessionID.
CWE Version 4.14
CWE-1004: Sensitive Cookie Without 'HttpOnly' Flag
CWE-1004: Sensitive Cookie Without 'HttpOnly' Flag