Not Http-Only Cookie
- CWE 1004
Not HTTP Only Cookie occurs when a web application sets cookies without the HttpOnly attribute. Cookies without this flag can be accessed via client-side scripts such as JavaScript, increasing the risk of theft through cross-site scripting (XSS) attacks or malicious browser extensions. This vulnerability can lead to session hijacking, unauthorized access, or exposure of sensitive information stored in cookies, such as authentication tokens or session identifiers.
Common patterns leading to cookies lacking the HttpOnly flag:
- Setting authentication or session cookies via server-side code without
HttpOnly. - Framework defaults that do not enforce
HttpOnlyunless explicitly configured. - Using JavaScript to create cookies for authentication or sensitive data storage.
- Absence of secure cookie policies in server or application configuration.
Impacts:
- Session Hijacking: Attackers can steal session identifiers through XSS attacks or client-side scripts.
- Sensitive Data Exposure: Cookies may contain sensitive user data accessible to malicious scripts.
- Privilege Escalation: Stolen cookies may allow attackers to impersonate other users or gain elevated privileges.
- Increased Risk in Shared Devices: Other users or browser extensions can access non-HttpOnly cookies.
Detection indicators:
- Cookies returned in HTTP responses without the
HttpOnlyflag. - Client-side scripts able to read session or authentication cookies.
- Security scanners flagging cookies missing security attributes.
Remediation
Mitigation strategies focus on securing cookie attributes and handling:
Set HttpOnly Attribute on Sensitive Cookies
Configure the web server or application framework to mark all authentication, session, and sensitive cookies asHttpOnly.Use Secure Attribute
CombineHttpOnlywithSecureto ensure cookies are transmitted only over HTTPS connections.Limit Cookie Scope
Use thePathandDomainattributes to restrict where cookies are sent.Avoid Storing Sensitive Data in Client-Accessible Cookies
Do not store passwords, tokens, or other confidential information in cookies accessible via JavaScript.Review Framework Defaults
Check default cookie behavior in web frameworks and enforceHttpOnlywhere necessary.Regular Security Testing
Include checks for missingHttpOnlyandSecureattributes during penetration testing and automated scans.Monitor and Audit Cookies
Review HTTP responses to ensure all sensitive cookies are properly flagged.
References
Search Vulnerability
You may also see
- Long Redirect Response
- Error Message
- Stack Trace
- Internal Path
- Not Secure Cookie
- Not Http-Only Cookie
- Sensitive Data in Query String
- Sensitive Data over HTTP
- Server Error
- Source Code Disclosure
- Information Leakage
- Web Backdoor
- Database Connection String
- Autocomplete Enabled
- Undefined Content-Type Header
- Missing X-Frame-Options Header
- File Upload Input Detected
- Mixed Content
- Insecure iFrame
- XPath Injection
- Basic Authentication over HTTP
- Forbidden Resource
- Multiple Choices Enabled
- Apache MultiViews Enabled
- GraphQL Endpoint Detected