Browser Security II (Slides)
Browser Security II (Slides)
https://example.org/absolute/URI/with/absolute/path/to/resource.txt
//example.org/scheme-relative/URI/with/absolute/path/to/resource.txt
/relative/URI/with/absolute/path/to/resource.txt
relative/path/to/resource.txt
../../../resource.txt
./resource.txt#frag01
resource.txt
#frag01
SOP Review
(scheme://domain:port/path?params)
SOP Review
This lesson:
Optional
SOP and Cookies
GET...
Server
Browser
HTTP Header:
Set-cookie: NAME=VALUE
domain=(when to send);
scope
path=(when to send)
secure=(only send over SSL)
expires=(when expires)
HttpOnly weak XSS defense
SameSite=[lax | strict] weak CSRF defense
Default scope is domain and path of setting URL
Scope Setting Rules
Domain: any domain-suffix of URL-hostname, except TLD
login.site.com can set cookies for all of .site.com but not
for another site or TLD
Cookie1 Cookie2
name= userid name= userid
value= test value= test123
domain= login.site.com domain= .site.com
path= / path= /
secure secure
distinct cookies
Reading Cookies on the Server
Server
GET //URL-domain/URL-path
Browser
Cookie: NAME=VALUE
Deleting a cookie:
document.cookie = “name=; expires= Thu, 01-Jan-70”
http://www.example.com/dir2/other.html
http://www.example.com/dir/page2.html
http://username:[email protected]/dir2/other.html
http://www.example.com:81/dir/other.html
http://example.com/dir/other.html
https://www.example.com/dir/other.html
Fill in the blanks with the most correct answer.
Answer choices: session, persistent, secure, HttpOnly, SameSite,
Third-party, Super, Zombie
Super A cookie with an origin of a top-level domain
Zombie A cookie that is regenerated after it is deleted
SameSite A cookie that can only be sent in requests originating from
the same origin as the target domain.
HttpOnly A cookie that cannot be accessed by client-side APIs.
Third-party A cookie that belongs to a domain that is different than the
one shown in the address bar.
Session An in-memory cookie. It does not have an expiration date. It
is deleted when the browser is closed.
Persistent A cookie that has an expiration date or time. Also called tracking cookies.
Secure A cookie that can only be transmitted over an encrypted connection.
Cookie Protocol Problems
The server is blind
Does not see cookie
attributes (e.g. secure,
HttpOnly)
Does not see which domain
set the cookie
Server only sees:
Cookie: NAME=VALUE
Cookie Protocol Problems
Example 1
1
Alice logs in at login.site.com session-id of Alice’s session
2
Alice visits evil.site.com session-id of Badguy’s session
3
Alice visits course.site.com thinks it is from badguy
Cookie Protocol Problems
Example 1
<iframe src=“x.com/B”></iframe>
alert(frames[0].document.cookie);
Cookie Protocol Problems
Cookies have no integrity!
Cookie Protocol Problems
Cookies have no integrity!
Set-cookie: Cookie:
shopping cart total= $150 shopping cart total= $15
Problem:
Referer leaks URL session token to 3rd parties
Functionality Security
Let user login as Prevent others from
different user. abusing content
Session Token Security- Logout Procedure
What happens during a logout:
1 Delete SessionToken from client
2 Mark session token as expired on server
Attacker
Session Hijacking
Session ID= ACF3D35F216AAEFC
Attacker
Session Hijacking
Beware of predictable tokens!
Example 2: Weak
Example 1: Counter:
MAC token:
User logs in, gets counter Weak MAC exposes secret
value, can view sessions of key from a few cookies,
other users gets counter value, can
view sessions of other users
Apache Tomcat: generateSessionId()
Returns random session ID
[server retrieves client state based on session-id]
Session Hijacking
Session tokens must be unpredictable to attacker
SID=IP
Session Hijacking
SID=IP
Session Hijacking