fix: use bounded read for bundle download HTTP responses (import of github/spec-kit#3764) - #104
Open
one-kash wants to merge 2 commits into
Open
fix: use bounded read for bundle download HTTP responses (import of github/spec-kit#3764)#104one-kash wants to merge 2 commits into
one-kash wants to merge 2 commits into
Conversation
The bundle download used unbounded resp.read() to read HTTP responses into memory. A malicious or misconfigured catalog server could return an arbitrarily large payload causing OOM. Replace with read_response_limited() capped at MAX_DOWNLOAD_BYTES (50 MiB), consistent with how other download paths in the codebase enforce bounded reads. Add regression test that monkeypatches MAX_DOWNLOAD_BYTES to 100 bytes and verifies oversized responses are rejected.
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.
Imported from upstream PR github#3764
Original author: @Quratulain-bilal
Original head branch:
fix/unbounded-bundle-downloadSummary
The bundle download in
commands/bundle/__init__.pyused unboundedresp.read()to read HTTP responses into memory. A malicious or misconfigured catalog server could return an arbitrarily large payload causing OOM.Changes
src/specify_cli/commands/bundle/__init__.py: Replacedresp.read()withread_response_limited(resp, max_bytes=MAX_DOWNLOAD_BYTES)capped at 50 MiB, consistent with how other download paths in the codebase enforce bounded reads.Testing
All 31 tests in
test_bundle_cli.pypass after the fix.Security Impact
This is a Medium severity fix - it closes a potential memory exhaustion vector against the bundle download endpoint. The 50 MiB limit is appropriate for bundle artifacts (ZIPs, archives) which are larger than JSON metadata but still bounded.