Web security

Note: These lecture notes were slightly modified from the ones posted on the 6.858 course website from 2014.

What is the web?

In the old days, it was a simple client/server architecture (client was your web browser, server was a machine on the network that could deliver static text and images to your browser).

The web has changed: now the browser is very complicated.

The web is now a complex platform for distributed computation! But what does this mean for security?

Client-side web applications

In this lecture, we're going to focus on the client-side of a web application. In particular, we're going to focus on how to isolate content from different providers that has to reside within the same browser.

To answer these questions, browsers use a security model called the same-origin policy.

Same-origin policy

What happens if the browser mistakenly identifies the MIME type of an object?

Let's take a deeper look at how the browser secures various resources.

Frame/window objects

DOM nodes

Cookies

HTTP responses: Many exceptions and half-exceptions to same-origin policy

Example:

<embed src=...> //Requires plugin-specific  
                //elaborations.

Cross-Site Request Forgery attacks

Remember that, when the browser generates an HTTP request, it automatically includes the relevant cookies.

What happens if an attacker gets the user to click on a URL like this? * http://bank.com/xfer?amount=500&to=attacker

This attack is called a cross-site request forgery (CSRF).

DNS rebinding attacks

Network addresses almost have an origin.

What about the pixels on a screen?

What about frame URLs that don't have an origin? * Example: + file://foo.txt + about:blank + javascript:document.cookie="x" * Sometimes the frame is only accessible to other frames with that protocol (e.g., file://). [This can be irritating if you're debugging a site and you want to mix file:// and http:// content]. * Sometimes the frame is just inaccessible to all other origins (e.g., "about:"). * Sometimes the origin is inherited from whoever created the URL (e.g., "javascript:"). This prevents attacks in which a attacker.com creates a frame belonging to victim.com, and then navigates the victim frame to a javascript: URL--we don't want the JavaScript to execute in the context of victim.com!

DNS names can be used as an attack vector

Plugins

Often have subtly-different security policies.

HTML5 introduces a new screen-sharing API: Once the user gives permission, a site can capture the entire visible screen area and transmit it back to the site's origin.

Conclusions

Since "The Tangled Web," there have been various modifications and additions to the aggregate web stack.

The browser security model is obviously a mess. It's very complex and contains a lot of subtleties and inconsistencies.