HttpOnly Cookie Flag (HttpOnly Flag)
Why HttpOnly Flag Matters
XSS attacks frequently target session cookies because stealing a session cookie gives the attacker full access to the victim's account. Without HttpOnly, a single XSS vulnerability allows attackers to exfiltrate all cookies using document.cookie and send them to their server.
With HttpOnly, even a successful XSS attack cannot directly steal the session cookie. The attacker can still make requests to your API using the victim's browser (since cookies are sent automatically), but they cannot exfiltrate the cookie to use from their own machine. This limits the attack's duration to the browser session.
HttpOnly should be set on all session cookies and authentication tokens. Cookies that need to be read by JavaScript (like CSRF tokens stored in cookies or UI preference cookies) cannot use HttpOnly, but these should not contain sensitive session data.
Checking Your Setup
Inspect Set-Cookie headers and confirm that JavaScript cannot read cookies that do not require client access. DomainOptic does not grade cookie flags. HttpOnly is normally appropriate for server-managed session cookies, while client-readable CSRF designs require separate analysis.
Run a Security Audit