43
Web Security Model 1

Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Web Security Model

1

Page 2: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Web Security

making websites safe to visit

protecting user data across websites

allowing bad sites to run without interacting with good sites

supporting secure web applications

securing internet traffic (e.g., TLS)

2

Page 3: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

URI URN URL

uniform resource indicator (URI)a unique string meant to identify some resource

uniform resource name (URN)a kind of URI that gives a unique nameurn:isbn:0130460192urn:ietf:rfc:2648urn:lex:eu:council:directive:2010-03-09;2010-19-UE

3

Page 4: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

URI URN URL

uniform resource locator (URL)most common kind of URIidentifies the resourcealso gives a sequence of instructions on how to get it

format: schema:[//[user@]host[:port]]path[?query][#fragment]host include www.ucalgary.ca

schema include http, ftpports omitted if default for the schema

4

Page 5: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Host or Domain

a series of one or more dot-separated partswww.ucalgary.ca

localhost

top level domain (TLD): com, ca, org, netsecond and third level domains are subordinate to their parent

.ca is top of the tree, then calgary, then the www serveryou can add more myserver.cs.ucalgary.ca

5

Page 6: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

HTTP: HyperText Transfer Protocol

used to request and return dataGET, POST, HEAD, ...

stateless request/response protocoleach request is independent of previous requestsstatelessness has a significant impact on design and implementation ofapplications

6

Page 7: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

GET /bea/30200/coverage?mnc=260&f=11111 HTTP/1.1

Host: in.cuebiq.com

Accept: image/gif, image/x−bitmap, image/jpeg, */*

Accept−Language: en

User−Agent: okhttp/3.8.1

Connection: Keep−Alive

HTTP Request

methodarguments

headers

data (none for GET)

blank link

versionfile

Page 8: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

version

HTTP Response

HTTP/1.1 200 OK

Cache−Control: max−age=0

Content−Encoding: gzip

Content−Type: application/json;charset=utf−8

Date: Thu, 19 Apr 2018 11:22:45 GMT

Content−Length: 38

Connection: keep−alive

{"cs":{"d":10080}}

headers

blank line

data (data length)

status code reason phrase

Page 9: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Goals of Web Security

safely browse the Webmalicious website cannot:

steal information from the usermodify legitimate sitesotherwise harm the user

support secure web applicationsapplications delivered over the web should have the same security aslocal softwarewhat would these be?

9

Page 10: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Goals of Web Security

security should be provided even if the user visits both a goodand bad site

evil sites should not be able to interfere with good siteseven when they are run

at the same timeseparate windowseparate tabin an iframe on the same webpage

i.e., evil site presents good site inside

10

Page 11: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Two Sides of Web Security

web browserresponsible for securely confining Web contente.g., evil site iframing a good site must not learn your password as youtype it in

web applicationse.g., online merchants, banks, blogs, collaborative editingmix of server-side and client-side code

PHP, Ruby, ASP, JSP on server sidemostly JavaScript on client side

many potential bugs: XSS, XSRF, SQL-injection

e.g., evil site must not be able to send queries on your behalf even ifyou logged in through an iframe

11

Page 12: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

������������

Browser

OS

hardwaresystem

space

space

user website

INTERNET

request

reply

Page 13: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

������������

OS

hardwarespace

user websiterequest

Browserspace

system

replyINTERNET

malware

network

attackerweb

attackerattacker

Page 14: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Malware Attacker

malicious code runs on victim’s computer

can exploit bugs in softwarecan convince user to install malicious content

e.g., masquerade as anti-virus, video codec, etc.

14

Page 15: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Network Attacker

passive attackswireless eavesdropper

active attacksevil Wi-Fi routerDNS poisoning

15

Page 16: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Web Attacker

controls a malicious website (attacker.com)can even have a nice SSL/TLS certificate for the site

user visits attacker.comphishing emailenticing content

10 things that are things! number 7 included!

placed by an ad networkclicked by accident (clickjacking)

attacker has no other access to user machine

16

Page 17: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

iframe attacker:iframe with malicious content included in otherwise honest

webpagee.g., ads, analytics, trackers

the main reason to use an ad blockeris not because ads are annoying

it is because ads are running arbitrarycode on your computer.

17

Page 18: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

But I never visit risky websites!simple trick: put up a page with popular content, get into

search engines, then redirect to exploit site.1% of top 10,000 pages.

18

Page 19: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Browser: Basic Execute Model

each browser window or frameloads contentrenders it to the screen

processes HTML, CSS, runs scriptsload images, subframes, etc.

respond to events

eventsuser actions like onclick, onkeydownrendering behaviour like onload, errortimer elapsing like setTimeout

19

Page 20: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Document Object Model (DOM)

HTML is internally represented as a document objectit has properties that are themselves objectsthese are arranged in a hierarchical structureeverything in HTML is put somewhere inside

anchor objects have href properties

the browser displays the HTML on a framecan be a window or part of a windowrepresented by a window objectthe window.location property has the URL components as properties

the document object is the root and is standardized by the DOMthe DOM is an API for JavaScript to manipulate anything insidee.g., window.location = ‘‘evil.com’’

20

Page 21: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

JavaScript

language executed by the browserscripts are embedded in webpagescan be set to run at different times:

before loading HTMLbefore viewing pagewhile viewing pagewhen leaving page

JavaScript allows malicious webpages to execute code onuser’s machine

you download code and run it

21

Page 22: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

JavaScript History

created by Brendan Eich at Netscapescripting language for Navigator 2

later standardized for cross-browser compatibilityECMAScript

has nothing to do with javaname was part of marketing deal“Java is to JavaScript as car is to carpet”

22

Page 23: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Uses of JavaScript

active and immersive Web 2.0 multimedia experiences!special effects

change images, hide elements, change cursor

dynamic content manipulationform validation

“credit card field must not have spaces”

least surprise failuredesign failurepossible input validation failure

lots of web appscollaborative editing, social media, etc.

23

Page 24: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Where to put JavaScript

embedded in HTML as a <script> element<script> alert(“Hello, world!”) </script><script type=“text/JavaScript” src=“notmalicious.js” />

event handler in a tag<a href=“http://www.ucalgary.ca” onmouseover=“alert(‘click’);”>

JavaScript schema<a href=“JavaScript: alert(‘click’);”>click here</a>

24

Page 25: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Same Origin Policy (SOP)SOP is an isolation and access control philosophy

to protect data connected to one host beingaccessed by another (possibly malicious) host

25

Page 26: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Same Origin Policy

avoid having an evil website manipulate another websiteSOP is a compromise

one option would be to not allow any content other than the websiteitself

e.g., embed all files and scripts into the single HTML page

another would be to not allow any third party contentSOP allows third party content, but sandboxes it

e.g., treats it as though it were another opened tab

SOP controls all access to the DOM

26

Page 27: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Same Origin Policy

a base HTML document is assigned an originbased on the URI that retrieved itconsists of (scheme, host, port) triple

scheme://host:port/irrelevant/to/sop

two origins are the same if the whole triple matches

string matching

scripts and images inherit the origin of the HTML document thatcaused it to load

i.e., not the server they are loaded from

27

Page 28: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad
Page 29: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

SOP: one origin should not be able toaccess the resources of another origin.JavaScript on one page cannot read

or modify pages from different origins

29

Page 30: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

N.B.: the content of an iframe has theorigin of the URL that serves the iframe;

not the website that embeds it.

30

Page 31: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Special case: JavaScript runs with the origin of theloading page.

31

Page 32: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad
Page 33: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Same Origin?http://wikipedia.org/a/ and http://wikipedia.org/b/http://wikipedia.org/ and http://www.wikipedia.org/http://wikipedia.org/ and https://wikipedia.org/b/

http://wikipedia.org:81/ and http://wikipedia.org:82/

33

Page 34: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Web Cookies

34

Page 35: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

HTTP is Statelesseach HTTP request is a standalone event

this is a poor match to how it is usede.g., shopping carts, being “logged-in”, language

preferences

35

Page 36: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Web cookies add statea cookie is a file created by a website to store information

in the browser

36

Page 37: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Web Cookies

server replies with an HTTP header Set-Cookiee.g., Set-Cookie: test cookie=CheckForPermission;domain=.doubleclick.net

cookie has parameters“argument=value” format or just “argument”arguments are optionalarguments are separated by semicolons

37

Page 38: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

SOP for Cookies

cookies have a different SOP than the DOM’s SOP

can be sent on any port

can be sent using HTTP or HTTPSmust be sent to same domain and path

subdirectories okay

these can be tweaked

38

Page 39: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Web Cookie Arguments

Secure; (only send over encrypted channel)

HttpOnly; (deny DOM API access to cookie)Expires=Mon, 29-Jan-2018 14:30:11 GMT; (date to delete)

format is Wdy, DD-Mon-YYYY HH:MM:SS GMTpast date means delete immediatelyno expire means this session only

39

Page 40: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Web Cookie Arguments

Domain=valueby default cookie can only be read by exact domain

e.g., myserver.cs.ucalgary.ca

is used to widen domain

e.g., .ucalgary.cameans anything that ends in .ucalgary.cais this secure? what is threat model?

cannot be used to allow different domain

Path=value;widen path of who may read the cookieby default only HTML in the current directory and subdirectories canget cookie

40

Page 41: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Cookie Uses

session IDrandom number stored in a cookie and sent to the serverindexes server-side state for the client

authenticationcookie’s session ID also acts as an authenticator

the cookie proves to the website that the client previously authenticatedcorrectly

what does this remind you of?cookie theft: anyone knowing this number can impersonate you

why can’t it prove that it is Alice?

41

Page 42: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad

Cookie Uses

personalizationhelps the website recognize the user from a previous visitstore settings locally or remotely

trackingfollow the user from site to sitelearn their browsing behaviour, etc.

third-party cookiesa.com has an iframe for b.comb.com sends a cookie for the siteuser will send that back to b.com whenever visiting a.com

42

Page 43: Web Security Modelpages.cpsc.ucalgary.ca/~joel.reardon/526/notes/slide-14-websec.pdf · Goals of Web Security security should be provided even if the user visits both a good and bad