BREACH, a new attack against SSL based on compression, was announced at Black Hat recently. As I understand it, the attack scenario is something like this:
- An attacker MITMs your SSL traffic (without attempting to decrypt it);
- then they acquire the ability to make some set of requests on your behalf (e.g., by having you visit a webpage which runs Javascript they control);
- the Javascript coordinates with the MITM'd proxy to make requests to the server with various parameters, e.g., /?q=a, /?q=b, etc.;
- the server has some page which sends back the value of q in the response body (like a search results page) and is otherwise fairly static;
- by examining the size of the response, they can determine when they're matching your CSRF token because the response will be smaller. For example, if your CSRF token starts a9f..., then the response to /?q=a9f will be slightly smaller than other responses because it can compress better;
- they can quickly extend the query and discover the entire CSRF token (with just thousands of requests);
- then the Javascript (which is still running elsewhere) can launch CSRF attacks.
There's some discussion here:
- BREACH: http://breachattack.com/
- BREACH and Django: https://www.djangoproject.com/weblog/2013/aug/06/breach-and-django/ (and on HN)
- BREACH and Rails: https://github.com/rails/rails/pull/11729
Some recommended mitigations are listed here http://breachattack.com/#mitigations.
Of these:
- Disable HTTP Compression: Very practical but implies a huge performance cost. This isn't something we can fix anyway in most cases (it's usually in layers above us), although we could try to detect it (see T2226).
- Separate secrets from user input: This is possible, but I think not very practical. We'd have to do something like manage CSRF using Javascript, and nothing would work without JS anymore. We can't move CSRF tokens into cookies or it defeats the whole purpose.
- Randomizing secrets per request: This is very practical and has no significant downsides.
- Masking secrets: As above.
- CSRF: Basically, this means that any page which echoes request data must have CSRF protection. This is possible, but is really hard to detect and would reduce functionality (you could no longer have GET query pages, for example), although with ApplicationSearch we might be closer than I think here. We could look at this in more detail, although I worry that the lack of mechanism to detect it make it perilous.
- Length hiding: Trivial, but not clearly effective
- Rate limiting: Undesirable and ineffective.