CWE-1004: Sensitive Cookie Without 'HttpOnly' Flag
The product uses a cookie to store sensitive information, but the cookie is not marked with the HttpOnly flag.
How it's found
Sensitive Cookie Without 'HttpOnly' Flag is a specific, narrowly defined instance of a broader pattern. Testers confirm it with targeted code review and a proof-of-concept input that exercises the exact code path this weakness describes.
Vulnerable vs. safe
String sessionID = generateSessionId();Cookie c = new Cookie("session_id", sessionID);response.addCookie(c);String sessionID = generateSessionId();Cookie c = new Cookie("session_id", sessionID);c.setHttpOnly(true);response.addCookie(c);Consequences
- Read Application Data: If the HttpOnly flag is not set, then sensitive information stored in the cookie may be exposed to unintended parties.
- 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.
Mitigations
- Implementation: Leverage the HttpOnly flag when setting a sensitive cookie in a response.
How TurboPentest tests for this (white-box)
This weakness (Sensitive Cookie Without 'HttpOnly' Flag) is caught by white-box static analysis when you connect a GitHub repo: IntegSec's Opengrep SAST rule pack carries 10 rules for it, flagging the issue directly in your source code as part of the pentest.
Frequently asked questions
What is CWE-1004?
The product uses a cookie to store sensitive information, but the cookie is not marked with the HttpOnly flag.
How do you find Sensitive Cookie Without 'HttpOnly' Flag?
Sensitive Cookie Without 'HttpOnly' Flag is a specific, narrowly defined instance of a broader pattern. Testers confirm it with targeted code review and a proof-of-concept input that exercises the exact code path this weakness describes.
What is the impact of CWE-1004?
Read Application Data: If the HttpOnly flag is not set, then sensitive information stored in the cookie may be exposed to unintended parties. 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.
Does TurboPentest test for Sensitive Cookie Without 'HttpOnly' Flag?
This weakness (Sensitive Cookie Without 'HttpOnly' Flag) is caught by white-box static analysis when you connect a GitHub repo: IntegSec's Opengrep SAST rule pack carries 10 rules for it, flagging the issue directly in your source code as part of the pentest.
Related CWEs
Written and reviewed by
Michel Chamberland - Founder & CEO, IntegSec
CISSP, OSCP, OSCE, CEH, GIAC, CCSK · 20+ years in offensive security
Michel has spent 20+ years on offensive security teams including IBM X-Force Red and Trustwave SpiderLabs, leading penetration tests, red team engagements, and breach response for Fortune 500 customers. He is the founder of IntegSec and the architect of TurboPentest.
Find these issues before an attacker does
TurboPentest runs an agentic AI pentest against your target and reports findings with proof, from $99 per target.
Start a pentest