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?
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?
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.
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
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?
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?