Skip to content

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
mainfrom
import/pr-3764
Open

fix: use bounded read for bundle download HTTP responses (import of github/spec-kit#3764)#104
one-kash wants to merge 2 commits into
mainfrom
import/pr-3764

Conversation

@one-kash

Copy link
Copy Markdown

Imported from upstream PR github#3764
Original author: @Quratulain-bilal
Original head branch: fix/unbounded-bundle-download


Summary

The bundle download in commands/bundle/__init__.py used unbounded resp.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: Replaced resp.read() with read_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.py pass 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants