Sessions and cookies
1.[3p] Match each cookie attribute to what it stops.
Match each cookie attribute to what it stops.
HttpOnly
Secure
SameSite=Lax
__Host- prefix
a cross-site form post arriving with the cookie attached
the cookie travelling over a forced plain HTTP request
injected script reading the value through document.cookie
any subdomain reading or overwriting the cookie
Show the answer
HttpOnly: injected script reading the value through document.cookie Secure: the cookie travelling over a forced plain HTTP request SameSite=Lax: a cross-site form post arriving with the cookie attached __Host- prefix: any subdomain reading or overwriting the cookie
2.[3p] Why does the sessions table store SHA-256(token) rather than the token?
Why does the sessions table store SHA-256(token) rather than the token?
The answer is: A leaked table then hands the attacker nothing usable, since the digest cannot be turned back into a token
The answer is: A leaked table then hands the attacker nothing usable, since the digest cannot be turned back into a token
The answer is: A leaked table then hands the attacker nothing usable, since the digest cannot be turned back into a token
3.[3p] Why is a fast hash correct for a session token but wrong for a password?
Why is a fast hash correct for a session token but wrong for a password?
The answer is: A session token is drawn uniformly from a 256-bit space, so there is no candidate list to guess through
The answer is: A session token is drawn uniformly from a 256-bit space, so there is no candidate list to guess through
The answer is: A session token is drawn uniformly from a 256-bit space, so there is no candidate list to guess through
4.[2p] Rotating the session token at the moment a user signs in is what defeats session fixation.
Rotating the session token at the moment a user signs in is what defeats session fixation.
The answer is: True
5.[3p] With identifiers of bits, expected collisions are about . How many bits does a token need for a billion of them to give roughly a 3 percent chance of a collision?
With identifiers of bits, expected collisions are about . How many bits does a token need for a billion of them to give roughly a 3 percent chance of a collision?
6.[3p] Which of these are real problems with keeping a session token in localStorage?
Which of these are real problems with keeping a session token in localStorage?
Select all that apply
The answer is: Any script running on the origin can read it, and no attribute exists to prevent that, Once exfiltrated it can be replayed from the attacker's own machine with no origin restriction, It trades a risk with a cheap known defence for one with no defence
7.[3p] Put these in the order the server performs them on a successful password login.
Put these in the order the server performs them on a successful password login.
Generate 32 random bytes as the token
Set the cookie carrying the token
Verify the password against the stored hash
Insert a session row keyed by the hash of the token
Show the answer
b, d, c, a
8.[3p] A cookie is named __Host-session. What must be true for the browser to accept it?
A cookie is named __Host-session. What must be true for the browser to accept it?
The answer is: Secure is set, Path is /, and there is no Domain attribute
The answer is: Secure is set, Path is /, and there is no Domain attribute
The answer is: Secure is set, Path is /, and there is no Domain attribute
9.[2p] Which expiry clock, if omitted, lets a stolen token stay valid forever so long as it is used regularly?
Which expiry clock, if omitted, lets a stolen token stay valid forever so long as it is used regularly?