Class 26 CS 480-008 3 May 2016 On the board ------------ 1. Last time 2. Certificates 3. HTTPS --plan --what goes wrong 4. admin notes 5. ForceHTTPS --------------------------------------------------------------------------- 1. Last time --Network security --Crypto protection for network communications --Last time: Recall strawman: A generates a random symmetric session key S. A encrypts S for PK_B, sends to B. Now we have secret key S shared between A and B, can encrypt and authenticate messages using symmetric encryption Discussed three attacks: replay, later decryption, impersonation. Clarify impersonation: --This is only an attack if B cared who A was in the first place. --In the event that B does care who A is, there are solutions: client-side certificates, etc. --Today: HTTPS 2. Background: what are certificates? --certificates are signed statements that assert a mapping between an entity's name (such as a legal name and/or a domain name) and its public key --often, there is a certificate chain: one entity signs a statement, but how do you trust the signature? A: in the Web context, your browser is born trusting certain certificate authorities (CAs). Those authorities sign statements like, "Web site www.foo.com has public key 0xf120.....". --with certificates, in general, there can be certificate *chains* (one cert attests to the validity of another public key; that public key attests to the validity of a separate public key; and so on). 3. HTTPS Motivating question: how to incorporate the cryptographic protection of network traffic into the Web security model? Plan for securing web browsers: HTTPS. New protocol: https instead of http (e.g., https://www.paypal.com/). Need to protect several things: A. Data sent over the network. B. Code/data in user's browser. C. UI seen by the user. A. How to ensure data is not sniffed or tampered with on the network? Use TLS (a cryptographic protocol that uses certificates). TLS encrypts and authenticates network traffic. Negotiate ciphers (and other features: compression, extensions). Negotiation is done in clear. Include a MAC of all handshake messages to authenticate. B. How to protect data and code in the user's browser? Goal: connect browser security mechanisms to whatever TLS provides. Recall that browser has two main security mechanisms: Same-origin policy. Cookie policy (slightly different). Same-origin policy with HTTPS/TLS. TLS certificate name must match hostname in the URL In our example, certificate name must be www.paypal.com. One level of wildcard is also allowed (*.paypal.com) Browsers trust a number of certificate authorities. Origin (from the same-origin policy) includes the protocol. http://www.paypal.com/ is different from https://www.paypal.com/ Here, we care about integrity of data (e.g., Javascript code). Result: non-HTTPS pages cannot tamper with HTTPS pages. Rationale: non-HTTPS pages could have been modified by adversary. Cookies with HTTPS/TLS. Server certificates help clients differentiate between servers. Cookies (common form of user credentials) have a "Secure" flag. Secure cookies can only be sent with HTTPS requests. Non-Secure cookies can be sent with HTTP and HTTPS requests. What happens if adversary tampers with DNS records? Good news: security doesn't depend on DNS (at least, that's the plan) We already assumed adversary can tamper with network packets. Wrong server will not know correct private key matching certificate. C. Finally, users can enter credentials directly. How to secure that? Lock icon in the browser tells user they're interacting with HTTPS site. Browser should indicate to the user the name in the site's certificate. User should verify site name they intend to give credentials to. How can this plan go wrong? As you might expect, every step above can go wrong. Not an exhaustive list, but gets at problems that ForceHTTPS wants to solve. 1 (A). Cryptography. There have been some attacks on the cryptographic parts of SSL/TLS. Attack by Rizzo and Duong can allow adversary to learn some plaintext by issuing many carefully-chosen requests over a single connection. [ Ref: http://www.educatedguesswork.org/2011/09/security_impact_of_the_rizzodu.html ] Recent attack by same people using compression [ Ref: http://en.wikipedia.org/wiki/CRIME ] Most recently, more padding oracle attacks. [ Ref: https://www.openssl.org/~bodo/ssl-poodle.pdf ] Some servers/CAs use weak crypto, e.g. certificates using MD5. Some clients choose weak crypto (e.g., SSL/TLS on Android). [ Ref: http://op-co.de/blog/posts/android_ssl_downgrade/ ] Some implementations use bad randomness to generate keys [ Ref: https://wiki.debian.org/SSLkeys#End_User_Summary ] But, cryptography is rarely the weakest part of a system. 2 (B). Authenticating the server. Adversary may be able to obtain a certificate for someone else's name. Used to require a faxed request on company letterhead (but how to check?) Now often requires receiving secret token at root@domain.com or similar. Security depends on the policy of least secure certificate authority. There are 100's of trusted certificate authorities in most browsers. Several CA compromises in 2011 (certs for gmail, facebook, ..) [ Ref: DigiNotar ] [ Ref: http://dankaminsky.com/2011/08/31/notnotar/ ] Servers may be compromised and the corresponding private key stolen. How to deal with compromised certificate (e.g., invalid cert or stolen key)? Certificates have expiration dates. Checking certificate status with CA on every request is hard to scale. Certificate Revocation List (CRL) published by some CAs, but relatively few certificates in them (spot-checking: most have zero revoked certs). CRL must be periodically downloaded by client. Could be slow, if many certs are revoked. Not a problem if few or zero certs are revoked, but not too useful. OCSP: online certificate status protocol. Query whether a certificate is valid or not. One issue: OCSP protocol didn't require signing "try later" messages. [ Ref: http://www.thoughtcrime.org/papers/ocsp-attack.pdf ] Various heuristics for guessing whether certificate is OK or not. CertPatrol, EFF's SSL Observatory, .. Not as easy as "did the cert change?". Websites sometimes test new CAs. Problem: online revocation checks are soft-fail. An active network attacker can just make the checks unavailable. Browsers don't like blocking on a side channel. Performance, single point of failure, captive portals, etc. [ Ref: https://www.imperialviolet.org/2011/03/18/revocation.html ] In practice browsers push updates with blacklist after major breaches. [ Ref: https://www.imperialviolet.org/2012/02/05/crlsets.html ] Users ignore certificate mismatch errors. Despite certificates being easy to obtain, many sites misconfigure them. Some don't want to deal with (non-zero) cost of getting certificates. Others forget to renew them (certificates have expiration dates). End result: browsers allow users to override mismatched certificates. Problematic: human is now part of the process in deciding if cert is valid. Hard for developers to exactly know what certs will be accepted by browsers. Empirically, about 60% of bypass buttons shown by Chrome are clicked through. (Though this data might be stale at this point..) What's the risk of a user accepting an invalid certificate? Might be benign (expired cert, server operator forgot to renew). Might be a man-in-the-middle attack, connecting to adversary's server. Why is this bad? User's browser will send user's cookies to the adversary. User might enter sensitive data into adversary's website. User might assume data on the page is coming from the right site. 3 (B). Mixing HTTP and HTTPS content. Web page origin is determined by the URL of the page itself. Page can have many embedded elements: Javascript via