CS155: Homework #2
Due: Saturday, May 26
Problem 1: Same-origin policy
The browser same-origin policy (SOP) consists of several different policies, including an SOP for DOM access and an SOP for cookie access. The SOP for DOM access is based on the triple (protocol, host, port), while the SOP for sending cookies to sites involves the domain and path. Cookies designated "secure" are sent by the browser over HTTPS only. In current browsers, reading document.cookie in an HTTP context does not reveal secure cookies.
Suppose the SOP for DOM access was defined using only host and port (as was the case in Safari until Safari 3.0) and did not include the protocol.
- Explain how a network attacker could steal facebook.com cookies that are designated "secure".
- Under the same assumptions, is it possible for a web attacker to steal facebook.com cookies that are designated "secure"? Describe an attack or explain why you believe none exists. Recall that a web attacker can set up a malicious web site and operate a browser to visit any site, but cannot intercept or forge network packets. Assume the user is willing to visit any site set up by the web attacker, but the web attacker can only set up web sites at domains other than facebook.com. For this part let's assume that the facebook.com site has no XSS vulnerabilities.
Problem 2: User trackingMost popular browsers let users block 3rd party cookies. This makes it more difficult for 3rd party sites, such as ad networks, to track users across connections. In class we described the HSTS header: a security mechanism that lets a domain specify that all connections to that domain must be over HTTPS. Typically, browsers will record HSTS headers even when they are provided by 3rd party domains. Explain how a 3rd party can use HSTS to track a user across connections even when the user's browser blocks 3rd party cookies. Your goal is to identify when two independent HTTP requests sent one day apart (over independent TCP connections) are originating from the same browser. Assume that the user is behind a proxy servicing many machines so that the request's source IP address cannot be used to track the user.
Problem 3: Secure open redirectsMany sites use public scripts that take a URL as a parameter and send the browser to that URL. For example, on LinkedIn, the following link is used to redirect the browser to a user's personal homepage:
http://www.linkedin.com/redirect?url=http://crypto.stanford.edu/cs155Sites use redirects to learn that the user clicked on an external link. Search engines, for example, use redirects to learn what search result the user clicked on. While open redirects are widely used, they pose a security risk. A phisher, for example, can create a LinkedIn phishing page and trick the user into clicking on
http://www.linkedin.com/redirect?url=http://phisher.comClicking on this link will lead to the phishing page, but users may think are clicking on a link to LinkedIn. Your goal is to design a secure redirect script that will only redirect to URLs that the site approves. Note that it is unreasonable for the redirect script to maintain a whitelist of all allowed redirect targets. First, external links are frequently added and removed. Second, in the case of a search engine, all links are valid links.
- A first idea is to rely on the Referer header. In the case of LinkedIn, the redirect script would check that the Referer header is a LinkedIn page, and ignore all other redirect requests. Explain why this approach does not work.
- Propose a secure method. That is, a single redirect script that
will only redirect to URLs authorized by the site. Make sure to
describe your method in sufficient detail.
Hint: use cryptography.
Problem 4: Cookies
- Explain what are httpOnly cookies.
- What attack are httpOnly cookies intended to prevent? Give an example attack that does not work if the site uses httpOnly cookies, but works with normal cookies. Make sure to provide a sketch of the vulnerable code and the attack URL (ignoring URL encoding, e.g., do not encode spaces)
- Give an example XSS exploit where httpOnly cookies do not improve security.
Problem 5: DNS Rebinding
DNS rebinding is an attack that uses DNS to subvert the same-origin policy in web browsers. In effect, a limitation of the same-origin policy is that it depends on domain names. Therefore, if an attacker is able to manipulate the meaning of domain names, the attacker can overcome restrictions imposed by the same-origin policy. There is an illustration of DNS rebinding in the lecture slides. The information you need about DNS is covered in the assigned reading called A Security Evaluation of DNSSEC with NSEC3.
- This attack assumes that the web user visits a malicious site. Give three ways that an attacker may attract honest users to their site. (Do not assume that the malicious site is actually called evil.com.)
- How can the content from 18.104.22.168 cause the user's browser send the second http request to www.evil.com.
- Why does the second request for www.evil.com cause a second request to the evil.com DNS server?
- Suppose that the page at 192.168.0.100 contains names and addresses of the corporate employees, organized in a systematic way. How can the attacker controlling evil.com send this information back to evil.com ?
- Is blocking RRs with TTL=0 at the firewall an effective defense against DNS rebinding? Explain briefly.
- What firewall rule will prevent this particular attack? (Assume a DNS RR is contained in a single packet.)
Problem 6: FirewallsConsider three kinds of firewalls: (1) stateless packet-filter firewalls, (2) stateful packet-filter firewalls, and (3) application-layer gateways. For each of the following attacks, state the simplest form of firewall that can be placed between an enterprise network and the external Internet to detect and significantly mitigate the attack. If none of the three kinds will work, write 0. Explain each answer briefly.
- Port sweep
- Syn flooding (too many SYN packets with no matching ACK)
- DNS cache poisoning
- viruses in incoming email addressed to enterprise users
- unrequested streaming video
- preventing an external network attacker from setting a secure cookie using HTTP