Security Operations

A site's login and account pages use HTTPS, but a user on public Wi-Fi follows an old http:// link to the same site. The browser sends the session cookie in cleartext, where an eavesdropper captures it. Which cookie attribute prevents the browser from sending the cookie over unencrypted HTTP?

Show the answer

Correct answerA. Secure

AWhy this is right: Secure tells the browser to send the cookie only over HTTPS, so it never travels in cleartext on an http:// request.

BWhy not this: HttpOnly blocks script access through document.cookie but does not stop the browser from sending the cookie over plain HTTP.

CWhy not this: SameSite=Lax limits cross-site request sending, mainly against CSRF, and does not require an encrypted connection.

DWhy not this: Path scopes which URL paths receive the cookie and does not enforce encrypted transport.

The Secure attribute makes the browser send the cookie only over HTTPS, so an http:// request never carries it in cleartext for an eavesdropper to capture. HttpOnly is tempting because it protects the cookie, but it only hides it from scripts; the browser still attaches the cookie to plain HTTP requests.