web security: web background · web security: web background cmsc 414 feb 20 2018. a very basic web...

105
WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018

Upload: others

Post on 19-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

WEB SECURITY: WEB BACKGROUND

CMSC 414FEB 20 2018

Page 2: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

A very basic web architecture

Browser Web server

Database

Client Server

(Private) Data

DB is a separate entity,logically (and often physically)

Page 3: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

A very basic web architecture

Browser Web server

Database

Client Server

(Private) Data

DB is a separate entity,logically (and often physically)

(Much) user data ispart of the browser

Page 4: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Interacting with web servers

http://www.cs.umd.edu/~dml/home.html

Get and put resources which are identified by a URL

Page 5: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Interacting with web servers

http://www.cs.umd.edu/~dml/home.html

Get and put resources which are identified by a URL

Protocolftphttpstor

Page 6: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Interacting with web servers

http://www.cs.umd.edu/~dml/home.html

Get and put resources which are identified by a URL

Page 7: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Interacting with web servers

http://www.cs.umd.edu/~dml/home.html

Get and put resources which are identified by a URL

Hostname/serverTranslated to an IP address by DNS (more on this later)

Page 8: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Interacting with web servers

http://www.cs.umd.edu/~dml/home.html

Get and put resources which are identified by a URL

Page 9: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Interacting with web servers

http://www.cs.umd.edu/~dml/home.html

Get and put resources which are identified by a URL

Path to a resource

Here, the file home.html is static content i.e., a fixed file returned by the server

Page 10: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Interacting with web servers

http://www.cs.umd.edu/~dml/home.html

Get and put resources which are identified by a URL

Path to a resource

Here, the file home.html is static content i.e., a fixed file returned by the server

http://facebook.com/delete.php

Page 11: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Interacting with web servers

http://www.cs.umd.edu/~dml/home.html

Get and put resources which are identified by a URL

Path to a resource

Here, the file home.html is static content i.e., a fixed file returned by the server

http://facebook.com/delete.php

Path to a resourceHere, the file home.html is dynamic content

i.e., the server generates the content on the fly

Page 12: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Interacting with web servers

http://www.cs.umd.edu/~dml/home.html

Get and put resources which are identified by a URL

Path to a resource

Here, the file home.html is static content i.e., a fixed file returned by the server

http://facebook.com/delete.php

Here, the file home.html is dynamic content i.e., the server generates the content on the fly

Page 13: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Interacting with web servers

http://www.cs.umd.edu/~dml/home.html

Get and put resources which are identified by a URL

Path to a resource

Here, the file home.html is static content i.e., a fixed file returned by the server

http://facebook.com/delete.php

Here, the file home.html is dynamic content i.e., the server generates the content on the fly

?f=joe123&w=16

Page 14: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Interacting with web servers

http://www.cs.umd.edu/~dml/home.html

Get and put resources which are identified by a URL

Path to a resource

Here, the file home.html is static content i.e., a fixed file returned by the server

http://facebook.com/delete.php

Here, the file home.html is dynamic content i.e., the server generates the content on the fly

?f=joe123&w=16

Arguments

Page 15: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Basic structure of web traffic

Browser Web server

Client Server

Database(Private) Data

Page 16: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Basic structure of web traffic

Browser Web server

Client Server

Page 17: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Basic structure of web traffic

Browser Web server

Client Server

HTTP

Page 18: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Basic structure of web traffic

Browser Web server

Client Server

• HyperText Transfer Protocol (HTTP) • An “application-layer” protocol for exchanging

collections of data

HTTP

Page 19: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Basic structure of web traffic

Browser Web server

Client Server

Page 20: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Basic structure of web traffic

Browser Web server

Client Server

User clicks

Page 21: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Basic structure of web traffic

Browser Web server

Client Server

HTTP Request

User clicks

Page 22: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Basic structure of web traffic

Browser Web server

Client Server

HTTP Request

User clicks

• Requests contain: • The URL of the resource the client wishes to obtain • Headers describing what the browser can do

• Requests be GET or POST • GET: all data is in the URL itself (supposed to have no side-effects) • POST: includes the data as separate fields (can have side-effects)

Page 23: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

HTTP GET requestshttp://www.reddit.com/r/security

Page 24: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

HTTP GET requestshttp://www.reddit.com/r/security

Page 25: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

HTTP GET requestshttp://www.reddit.com/r/security

User-Agent is typically a browser but it can be wget, JDK, etc.

Page 26: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate
Page 27: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate
Page 28: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Referrer URL: the site from whichthis request was issued.

Page 29: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

HTTP POST requestsPosting on Piazza

Page 30: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

HTTP POST requestsPosting on Piazza

Page 31: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

HTTP POST requestsPosting on Piazza

Implicitly includes dataas a part of the URL

Page 32: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

HTTP POST requestsPosting on Piazza

Explicitly includes data as a part of the request’s content

Implicitly includes dataas a part of the URL

Page 33: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Basic structure of web traffic

Browser Web server

Client Server

HTTP Request

User clicks

Page 34: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Basic structure of web traffic

Browser Web server

Client Server

User clicks

Page 35: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Basic structure of web traffic

Browser Web server

Client Server

User clicks

HTTP Response

Page 36: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Basic structure of web traffic

Browser Web server

Client Server

User clicks

• Responses contain: • Status code • Headers describing what the server provides • Data • Cookies

• State it would like the browser to store on the site’s behalf

HTTP Response

Page 37: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

<html> …… </html>

HTTP responses

Page 38: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

<html> …… </html>

Hea

ders

Dat

aHTTP

versionStatuscode

Reasonphrase

HTTP responses

Page 39: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate
Page 40: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate
Page 41: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate
Page 42: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

HTTP is stateless• The lifetime of an HTTP session is typically:

• Client connects to the server • Client issues a request • Server responds • Client issues a request for something in the response • …. repeat …. • Client disconnects

• HTTP has no means of noting “oh this is the same client from that previous session”

• With this alone, you’d have to log in at every page load

Page 43: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Maintaining state across HTTP sessions

• Server processing results in intermediate state

• Send the state to the client in hidden fields

• Client returns the state in subsequent responses

Browser Web server

Client Server

HTTP Request

Page 44: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Maintaining state across HTTP sessions

• Server processing results in intermediate state

• Send the state to the client in hidden fields

• Client returns the state in subsequent responses

Browser Web server

Client Server

HTTP Request

State

Page 45: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Maintaining state across HTTP sessions

• Server processing results in intermediate state

• Send the state to the client in hidden fields

• Client returns the state in subsequent responses

Browser Web server

Client Server

State

Page 46: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Maintaining state across HTTP sessions

• Server processing results in intermediate state

• Send the state to the client in hidden fields

• Client returns the state in subsequent responses

Browser Web server

Client Server

HTTP Response

State

Page 47: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Maintaining state across HTTP sessions

• Server processing results in intermediate state

• Send the state to the client in hidden fields

• Client returns the state in subsequent responses

Browser Web server

Client Server

HTTP Response

State

Page 48: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Maintaining state across HTTP sessions

• Server processing results in intermediate state

• Send the state to the client in hidden fields

• Client returns the state in subsequent responses

Browser Web server

Client Server

HTTP Response

State

Page 49: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Maintaining state across HTTP sessions

• Server processing results in intermediate state

• Send the state to the client in hidden fields

• Client returns the state in subsequent responses

Browser Web server

Client Server

State

Page 50: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Maintaining state across HTTP sessions

• Server processing results in intermediate state

• Send the state to the client in hidden fields

• Client returns the state in subsequent responses

Browser Web server

Client Server

HTTP Request

State

Page 51: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Maintaining state across HTTP sessions

• Server processing results in intermediate state

• Send the state to the client in hidden fields

• Client returns the state in subsequent responses

Browser Web server

Client Server

HTTP Request

State

Page 52: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Maintaining state across HTTP sessions

• Server processing results in intermediate state

• Send the state to the client in hidden fields

• Client returns the state in subsequent responses

Browser Web server

Client Server

HTTP Request

State

Page 53: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Online orderingOrder

$5.50

Order

socks.com

Page 54: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Online orderingOrder

$5.50

Order

Pay

The total cost is $5.50.Confirm order?

Yes No

socks.comsocks.com

Separate page

Page 55: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

<html><head> <title>Pay</title> </head><body>

<form action=“submit_order” method=“GET”>The total cost is $5.50. Confirm order?<input type=“hidden” name=“price” value=“5.50”><input type=“submit” name=“pay” value=“yes”><input type=“submit” name=“pay” value=“no”>

</body></html>

Online orderingWhat’s presented to the user

Page 56: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

<html><head> <title>Pay</title> </head><body>

<form action=“submit_order” method=“GET”>The total cost is $5.50. Confirm order?<input type=“hidden” name=“price” value=“5.50”><input type=“submit” name=“pay” value=“yes”><input type=“submit” name=“pay” value=“no”>

</body></html>

Online orderingWhat’s presented to the user

Page 57: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Online ordering

if(pay == yes && price != NULL){

bill_creditcard(price);deliver_socks();

}else

display_transaction_cancelled_page();

The corresponding backend processing

Page 58: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Online ordering

if(pay == yes && price != NULL){

bill_creditcard(price);deliver_socks();

}else

display_transaction_cancelled_page();

The corresponding backend processing

Page 59: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

<html><head> <title>Pay</title> </head><body>

<form action=“submit_order” method=“GET”>The total cost is $5.50. Confirm order?<input type=“hidden” name=“price” value=“5.50”><input type=“submit” name=“pay” value=“yes”><input type=“submit” name=“pay” value=“no”>

</body></html>

Online orderingWhat’s presented to the user

Page 60: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

<html><head> <title>Pay</title> </head><body>

<form action=“submit_order” method=“GET”>The total cost is $5.50. Confirm order?<input type=“hidden” name=“price” value=“5.50”><input type=“submit” name=“pay” value=“yes”><input type=“submit” name=“pay” value=“no”>

</body></html>

Online orderingWhat’s presented to the user

value=“0.01”

Page 61: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Minimizing trust in the client

<html><head> <title>Pay</title> </head><body>

<form action=“submit_order” method=“GET”>The total cost is $5.50. Confirm order?<input type=“hidden” name=“price” value=“5.50”><input type=“submit” name=“pay” value=“yes”><input type=“submit” name=“pay” value=“no”>

</body></html>

What’s presented to the user

Page 62: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Minimizing trust in the client

<html><head> <title>Pay</title> </head><body>

<form action=“submit_order” method=“GET”>The total cost is $5.50. Confirm order?<input type=“hidden” name=“price” value=“5.50”><input type=“submit” name=“pay” value=“yes”><input type=“submit” name=“pay” value=“no”>

</body></html>

<input type=“hidden” name=“sid” value=“781234”>

What’s presented to the user

Page 63: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Minimizing trust in the client

price = lookup(sid);if(pay == yes && price != NULL){

bill_creditcard(price);deliver_socks();

}else

display_transaction_cancelled_page();

The corresponding backend processing

Page 64: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Minimizing trust in the client

price = lookup(sid);if(pay == yes && price != NULL){

bill_creditcard(price);deliver_socks();

}else

display_transaction_cancelled_page();

The corresponding backend processing

We don’t want to pass hidden fields around all the time

Page 65: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Statefulness with Cookies

• Server stores state, indexes it with a cookie

• Send this cookie to the client

• Client stores the cookie and returns it with subsequent queries to that same server

Browser Web server

Client Server

HTTP Request

Page 66: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Statefulness with Cookies

• Server stores state, indexes it with a cookie

• Send this cookie to the client

• Client stores the cookie and returns it with subsequent queries to that same server

Browser Web server

Client Server

HTTP Request

State

Page 67: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Statefulness with Cookies

• Server stores state, indexes it with a cookie

• Send this cookie to the client

• Client stores the cookie and returns it with subsequent queries to that same server

Browser Web server

Client Server

HTTP Request

State

Cookie

Page 68: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Statefulness with Cookies

• Server stores state, indexes it with a cookie

• Send this cookie to the client

• Client stores the cookie and returns it with subsequent queries to that same server

Browser Web server

Client Server

State

Cookie

Page 69: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Statefulness with Cookies

• Server stores state, indexes it with a cookie

• Send this cookie to the client

• Client stores the cookie and returns it with subsequent queries to that same server

Browser Web server

Client Server

HTTP Response

State

Cookie

Page 70: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Statefulness with Cookies

• Server stores state, indexes it with a cookie

• Send this cookie to the client

• Client stores the cookie and returns it with subsequent queries to that same server

Browser Web server

Client Server

HTTP Response

Cookie State

Cookie

Page 71: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Statefulness with Cookies

• Server stores state, indexes it with a cookie

• Send this cookie to the client

• Client stores the cookie and returns it with subsequent queries to that same server

Browser Web server

Client Server

HTTP Response

Cookie State

Cookie

Cookie

Page 72: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Statefulness with Cookies

• Server stores state, indexes it with a cookie

• Send this cookie to the client

• Client stores the cookie and returns it with subsequent queries to that same server

Browser Web server

Client Server

HTTP Response

Cookie State

Cookie

Cookie

Server

Page 73: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Statefulness with Cookies

• Server stores state, indexes it with a cookie

• Send this cookie to the client

• Client stores the cookie and returns it with subsequent queries to that same server

Browser Web server

Client Server

State

Cookie

Cookie

Server

Page 74: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Statefulness with Cookies

• Server stores state, indexes it with a cookie

• Send this cookie to the client

• Client stores the cookie and returns it with subsequent queries to that same server

Browser Web server

Client Server

HTTP Request

State

Cookie

Cookie

Server

Page 75: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Statefulness with Cookies

• Server stores state, indexes it with a cookie

• Send this cookie to the client

• Client stores the cookie and returns it with subsequent queries to that same server

Browser Web server

Client Server

HTTP Request

State

Cookie

Cookie

Server

Cookie

Page 76: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

<html> …… </html>

Hea

ders

Dat

a

Set-Cookie:key=value; options; ….Cookies are key-value pairs

Page 77: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

<html> …… </html>

Hea

ders

Dat

a

Set-Cookie:key=value; options; ….Cookies are key-value pairs

Page 78: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Cookies

Browser

Client

(Private) Data

Semantics

Page 79: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Cookies

Browser

Client

(Private) Data

• Store “us” under the key “edition” (think of it like one big hash table)

Semantics

Page 80: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Cookies

Browser

Client

(Private) Data

• Store “us” under the key “edition” (think of it like one big hash table)

• This value is no good as of Wed Feb 18…

Semantics

Page 81: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Cookies

Browser

Client

(Private) Data

• Store “us” under the key “edition” (think of it like one big hash table)

• This value is no good as of Wed Feb 18…

• This value should only be readable by any domain ending in .zdnet.com

Semantics

Page 82: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Cookies

Browser

Client

(Private) Data

• Store “us” under the key “edition” (think of it like one big hash table)

• This value is no good as of Wed Feb 18…

• This value should only be readable by any domain ending in .zdnet.com

• This should be available to any resource within a subdirectory of /

Semantics

Page 83: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Cookies

Browser

Client

(Private) Data

• Store “us” under the key “edition” (think of it like one big hash table)

• This value is no good as of Wed Feb 18…

• This value should only be readable by any domain ending in .zdnet.com

• This should be available to any resource within a subdirectory of /

• Send the cookie to any future requests to <domain>/<path>

Semantics

Page 84: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Cookies

Browser

Client

(Private) Data

• Store “us” under the key “edition” (think of it like one big hash table)

• This value is no good as of Wed Feb 18…

• This value should only be readable by any domain ending in .zdnet.com

• This should be available to any resource within a subdirectory of /

• Send the cookie to any future requests to <domain>/<path>

Semantics

Page 85: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Requests with cookies

Subsequent visit

Page 86: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Requests with cookies

Subsequent visit

Res

pons

e

Page 87: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Requests with cookies

Subsequent visit

Res

pons

e

Page 88: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Why use cookies?• Personalization

• Let an anonymous user customize your site • Store font choice, etc., in the cookie

Page 89: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Why use cookies?• Tracking users

• Advertisers want to know your behavior • Ideally build a profile across different websites

- Read about iPad on CNN, then see ads on Amazon?! • How can an advertiser (A) know what you did on another site (S)?

Page 90: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Why use cookies?• Tracking users

• Advertisers want to know your behavior • Ideally build a profile across different websites

- Read about iPad on CNN, then see ads on Amazon?! • How can an advertiser (A) know what you did on another site (S)?

S shows you an ad from A; A scrapes the referrer URL

Page 91: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Why use cookies?• Tracking users

• Advertisers want to know your behavior • Ideally build a profile across different websites

- Read about iPad on CNN, then see ads on Amazon?! • How can an advertiser (A) know what you did on another site (S)?

S shows you an ad from A; A scrapes the referrer URL

Option 1: A maintains a DB, indexed by your IP address Problem: IP addrs change

Page 92: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Why use cookies?• Tracking users

• Advertisers want to know your behavior • Ideally build a profile across different websites

- Read about iPad on CNN, then see ads on Amazon?! • How can an advertiser (A) know what you did on another site (S)?

S shows you an ad from A; A scrapes the referrer URL

Option 1: A maintains a DB, indexed by your IP address Problem: IP addrs change

Option 2: A maintains a DB indexed by a cookie

- “Third-party cookie”- Commonly used by large

ad networks (doubleclick)

Page 93: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate
Page 94: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Ad provided byan ad network

Page 95: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Snippet of reddit.com source

Page 96: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Snippet of reddit.com source

Our first time accessing adzerk.net

Page 97: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

I visit reddit.com

Page 98: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

I visit reddit.com

Page 99: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

I visit reddit.com

Page 100: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

I visit reddit.com

Later, I go to reddit.com/r/security

Page 101: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

I visit reddit.com

Later, I go to reddit.com/r/security

Page 102: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

I visit reddit.com

Later, I go to reddit.com/r/security

Page 103: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

I visit reddit.com

Later, I go to reddit.com/r/security

We are only sharing this cookie with *.adzerk.net; but we are telling them

about where we just came from

Page 104: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Cookies and web authentication• An extremely common use of cookies is to

track users who have already authenticated

• If the user already visitedhttp://website.com/login.html?user=alice&pass=secretwith the correct password, then the server associates a “session cookie” with the logged-in user’s info

• Subsequent requests (GET and POST) include the cookie in the request headers and/or as one of the fields:http://website.com/doStuff.html?sid=81asf98as8eak

• The idea is for the server to be able to say “I am talking to the same browser that authenticated Alice earlier.”

Page 105: WEB SECURITY: WEB BACKGROUND · WEB SECURITY: WEB BACKGROUND CMSC 414 FEB 20 2018. A very basic web architecture Browser Web server Database Client Server (Private) Data DB is a separate

Cookies and web authentication• An extremely common use of cookies is to

track users who have already authenticated

• If the user already visitedhttp://website.com/login.html?user=alice&pass=secretwith the correct password, then the server associates a “session cookie” with the logged-in user’s info

• Subsequent requests (GET and POST) include the cookie in the request headers and/or as one of the fields:http://website.com/doStuff.html?sid=81asf98as8eak

• The idea is for the server to be able to say “I am talking to the same browser that authenticated Alice earlier.”

Attacks?