fix: use bounded read for bundle download HTTP responses - #3764
Open
Quratulain-bilal wants to merge 2 commits into
Open
fix: use bounded read for bundle download HTTP responses#3764Quratulain-bilal wants to merge 2 commits into
Quratulain-bilal wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Bounds bundle HTTP response reads at 50 MiB to prevent memory exhaustion.
Changes:
- Replaces unbounded response reading with the shared limited-read helper.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/commands/bundle/__init__.py |
Enforces the bundle download size limit. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Medium
Quratulain-bilal
force-pushed
the
fix/unbounded-bundle-download
branch
from
July 27, 2026 20:37
e5c651b to
b8c293d
Compare
Contributor
Author
|
Thanks for the review! Regression test added in the latest push: All 32 bundle CLI tests pass. |
mnriem
requested changes
Jul 27, 2026
mnriem
left a comment
Collaborator
There was a problem hiding this comment.
Please address Copilot feedback
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.
Quratulain-bilal
force-pushed
the
fix/unbounded-bundle-download
branch
from
July 27, 2026 21:53
b8c293d to
d222d92
Compare
Collaborator
|
Please resolve conflicts |
Contributor
There was a problem hiding this comment.
Review details
Comments suppressed due to low confidence (1)
src/specify_cli/commands/bundle/init.py:19
- This duplicates the
_download_securityimport already present below, redefining both imported names. The repository's Ruff CI check (.github/workflows/test.yml:26-27) will reject this; keep a single import in the existing first-party order.
from ..._download_security import MAX_DOWNLOAD_BYTES, read_response_limited
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Medium
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
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.