security: mitigate urllib3 decompression-bomb bypass (CTO-4807)#301
Open
tech-sushant wants to merge 1 commit into
Open
security: mitigate urllib3 decompression-bomb bypass (CTO-4807)#301tech-sushant wants to merge 1 commit into
tech-sushant wants to merge 1 commit into
Conversation
…ssion bomb (CTO-4807) GHSA-mf9v-mfxr-j63j flags a decompression-bomb safeguard bypass in urllib3 < 2.7.0's streaming API. urllib3 2.7.0 requires Python >= 3.10 but the CI matrix still includes Python 3.9, so we cannot bump the pin. This patch installs a small monkey-patch on requests.adapters.HTTPAdapter that sets `Accept-Encoding: identity` on every outbound HTTP request. With no compressed responses ever arriving, urllib3's decompression code path is never exercised at runtime and the bug cannot trigger. - New module: EnigmaAutomation/security_mitigations.py - Imported once from EnigmaAutomation/__init__.py so it loads in every process (Django web, manage.py CLI, celery workers, pytest with DJANGO_SETTINGS_MODULE set). Note: SCA scanners detect by version, not behavior, so CTO-4807 will still flag urllib3==2.6.3. Requesting a risk-acceptance from security with this mitigation as justification, pending the Python upgrade that unblocks urllib3 2.7.0. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Accept-Encoding: identityon every outbound HTTP request. With no compressed responses ever arriving, urllib3's decompression path is never exercised → the bug can't trigger.EnigmaAutomation/security_mitigations.pyand imported it once fromEnigmaAutomation/__init__.pyso the patch loads in every process (Django web, manage.py CLI, celery workers, pytest withDJANGO_SETTINGS_MODULEset).How it works
```python
requests.adapters.HTTPAdapter.send is wrapped to inject the header
request.headers["Accept-Encoding"] = "identity"
```
Every `requests.get/post/...` (and anything else built on `requests`, which is what urllib3 is pulled in via in this codebase) now negotiates an uncompressed response. Servers respect `identity` per RFC 9110.
Scope of impact
Test plan
🤖 Generated with Claude Code