BREACH vulnerability

Published May 25 2021 01:27 PM 1,273 Views
Microsoft

When you run a penetration test on your web application, the report may point out BREACH as a high-risk vulnerability. BREACH attack works by trying to guess the secret keys in a compressed and encrypted response. Attacker makes many requests and try to figure out the encrypted information byte-by-byte using the pattern in responses.

 

Here is an example vulnerability test report that mentions the BREACH:

'id'           : 'BREACH',
'port'         : '443',
'severity'     : 'HIGH',
'finding'      : 'potentially VULNERABLE, uses gzip HTTP compression - only supplied '/' tested'

 

Mitigations

Common recommendations:

  • Disabling HTTP compression
  • Separating secrets from user input
  • Randomizing secrets per request
  • Masking secrets (effectively randomizing by XORing with a random secret per request)
  • Protecting vulnerable pages with CSRF
  • Length hiding (by adding a random number of bytes to the responses)
  • Rate-limiting the requests

 

My comments about these mitigations:

  • The first option (disabling HTTP compression) will mitigate this vulnerability. However, this may have a performance effect
  • Recommendations #2 to #5 are related to the coding of the application. They can help preventing this attack. They are also best practices for development
  • Recommendations #6 and #7 are hosting-related. You may need to talk to your hosting company to make these changes

 

The question is how the scan tool is determining to raise this vulnerability? Is it just checking if the compression is enabled? If that’s the only check it does, then recommended mitigations from #2 to #7 won’t make this vulnerability disappear from the report.

My recommendation would be to keep the compression enabled but implementing the other recommendations (from #2 to #7).

%3CLINGO-SUB%20id%3D%22lingo-sub-2385272%22%20slang%3D%22en-US%22%3EBREACH%20vulnerability%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2385272%22%20slang%3D%22en-US%22%3E%3CP%3EWhen%20you%20run%20a%20penetration%20test%20on%20your%20web%20application%2C%20the%20report%20may%20point%20out%20BREACH%20as%20a%20high-risk%20vulnerability.%20BREACH%20attack%20works%20by%20trying%20to%20guess%20the%20secret%20keys%20in%20a%20compressed%20and%20encrypted%20response.%20Attacker%20makes%20many%20requests%20and%20try%20to%20figure%20out%20the%20encrypted%20information%20byte-by-byte%20using%20the%20pattern%20in%20responses.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20is%20an%20example%20vulnerability%20test%20report%20that%20mentions%20the%20BREACH%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-html%22%3E%3CCODE%3E'id'%20%20%20%20%20%20%20%20%20%20%20%3A%20'BREACH'%2C%0A'port'%20%20%20%20%20%20%20%20%20%3A%20'443'%2C%0A'severity'%20%20%20%20%20%3A%20'HIGH'%2C%0A'finding'%20%20%20%20%20%20%3A%20'potentially%20VULNERABLE%2C%20uses%20gzip%20HTTP%20compression%20-%20only%20supplied%20'%2F'%20tested'%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CH3%20id%3D%22toc-hId-2033850800%22%20id%3D%22toc-hId-2033850803%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-226396337%22%20id%3D%22toc-hId-226396340%22%3E%3CSTRONG%3EMitigations%3C%2FSTRONG%3E%3C%2FH3%3E%0A%3CP%3ECommon%20recommendations%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EDisabling%20HTTP%20compression%3C%2FLI%3E%0A%3CLI%3ESeparating%20secrets%20from%20user%20input%3C%2FLI%3E%0A%3CLI%3ERandomizing%20secrets%20per%20request%3C%2FLI%3E%0A%3CLI%3EMasking%20secrets%20(effectively%20randomizing%20by%20XORing%20with%20a%20random%20secret%20per%20request)%3C%2FLI%3E%0A%3CLI%3EProtecting%20vulnerable%20pages%20with%20CSRF%3C%2FLI%3E%0A%3CLI%3ELength%20hiding%20(by%20adding%20a%20random%20number%20of%20bytes%20to%20the%20responses)%3C%2FLI%3E%0A%3CLI%3ERate-limiting%20the%20requests%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMy%20comments%20about%20these%20mitigations%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20first%20option%20(disabling%20HTTP%20compression)%20will%20mitigate%20this%20vulnerability.%20However%2C%20this%20may%20have%20a%20performance%20effect%3C%2FLI%3E%0A%3CLI%3ERecommendations%20%232%20to%20%235%20are%20related%20to%20the%20coding%20of%20the%20application.%20They%20can%20help%20preventing%20this%20attack.%20They%20are%20also%20best%20practices%20for%20development%3C%2FLI%3E%0A%3CLI%3ERecommendations%20%236%20and%20%237%20are%20hosting-related.%20You%20may%20need%20to%20talk%20to%20your%20hosting%20company%20to%20make%20these%20changes%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20question%20is%20how%20the%20scan%20tool%20is%20determining%20to%20raise%20this%20vulnerability%3F%20Is%20it%20just%20checking%20if%20the%20compression%20is%20enabled%3F%20If%20that%E2%80%99s%20the%20only%20check%20it%20does%2C%20then%20recommended%20mitigations%20from%20%232%20to%20%237%20won%E2%80%99t%20make%20this%20vulnerability%20disappear%20from%20the%20report.%3C%2FP%3E%0A%3CP%3EMy%20recommendation%20would%20be%20to%20keep%20the%20compression%20enabled%20but%20implementing%20the%20other%20recommendations%20(from%20%232%20to%20%237).%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2385272%22%20slang%3D%22en-US%22%3E%3CP%3EBREACH%20attack%20works%20by%20trying%20to%20guess%20the%20secret%20keys%20in%20a%20compressed%20and%20encrypted%20response%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Co-Authors
Version history
Last update:
‎May 25 2021 01:27 PM
Updated by: