Skip to content

fix(fetchers): enforce body size limits for registry JSON#119

Merged
chaliy merged 2 commits into
mainfrom
2026-05-17-fix-unbounded-json-parsing-vulnerability
May 17, 2026
Merged

fix(fetchers): enforce body size limits for registry JSON#119
chaliy merged 2 commits into
mainfrom
2026-05-17-fix-unbounded-json-parsing-vulnerability

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented May 17, 2026

Motivation

  • The PackageRegistryFetcher previously used Response::json() which buffers the entire decompressed response body, bypassing the repository's existing body-size cap and creating an OOM/DoS risk for large or malicious registry metadata.

Description

  • Reused the default fetcher's read_body_with_timeout and applied options.max_body_size.unwrap_or(DEFAULT_MAX_BODY_SIZE) in PackageRegistryFetcher::fetch to restore bounded reads.
  • Replaced unbounded resp.json().await calls with a bounded read followed by serde_json::from_slice(&body) for PyPI, crates.io, and npm handlers.
  • Propagated a max_body_size: usize parameter to fetch_pypi, fetch_crates_io, and fetch_npm and preserved existing output formatting and behavior.
  • Committed under fix(fetchers): enforce body size limits for registry JSON to address the introduced vulnerability with minimal behavioral change.

Testing

  • Ran cargo fmt --all which completed successfully.
  • Ran targeted tests with cargo test -p fetchkit package_registry -- --nocapture and all package-registry-related unit tests passed (8 passed, 0 failed).
  • Built and ran fetchkit test profile during the run which finished successfully for the exercised targets.

Codex Task

@chaliy chaliy merged commit 8f76539 into main May 17, 2026
11 checks passed
@chaliy chaliy deleted the 2026-05-17-fix-unbounded-json-parsing-vulnerability branch May 17, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant