Repository navigation
Conversation
Enforce a shared decompressed-stream limit before tar metadata reads and forward seeks in archive detection and extraction. Assisted-by: GitHub Copilot (model: GPT-6.1 Sol, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Tiny archives can trigger excessive memory use without a dedicated GNU/PAX metadata limit, while exception-handling flaws can reject valid ZIPs and obscure format-mismatch and size-limit diagnostics.
3 open issues
What changed in this PR
Hardens Spec Kit’s shared archive helpers by bounding decompressed tar.gz access before GNU/PAX metadata parsing during format detection and extraction.
Changes:
- Adds a 54 MiB decompressed-stream budget alongside existing member and total-file-size limits.
- Adds coverage for oversized metadata, read/seek boundaries, and caller-owned stream handling.
- Documents the stream limit in the shared catalog reference.
AI disclosure: GitHub Copilot performed this review autonomously for the requester; model/settings unavailable. Review text and suggested fixes are AI-generated.
| File | Description |
|---|---|
tests/test_download_security.py |
Adds metadata-budget, stream-boundary, and stream-ownership coverage. |
src/specify_cli/_download_security.py |
Adds a bounded gzip reader for tar detection and extraction. |
docs/reference/catalogs.md |
Documents the 54 MiB limit and its scope. |
Review effort: Max (auto)
Bound individual GNU/PAX payloads before recursive metadata parsing, preserve size-limit errors for OSError-derived caller types, and treat malformed gzip headers as format-probe failures. Assisted-by: GitHub Copilot (model: GPT-6.1 Sol, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Pushed commit 373ca76: GNU/PAX metadata payloads are now capped at 64 KiB before recursive parsing reads them, size-limit diagnostics are preserved for OSError-derived caller errors, and malformed gzip headers no longer hide format mismatches or reject otherwise valid ZIP archives. The targeted archive and installer suites passed all 1,791 tests. AI disclosure: posted on behalf of @mnriem by GitHub Copilot using GPT-6.1 Sol in autonomous, user-directed mode; reasoning effort was not exposed. The code, tests, documentation, and this summary were AI-generated. |
|
|
||
|
|
||
| class _BoundedTarInfo(tarfile.TarInfo): | ||
| """Check every metadata header, including headers parsed recursively.""" |
| except _TarLimitError as exc: | ||
| _raise_from(error_type, str(exc), exc) |


Description
Bound decompressed tar.gz reads and seeks before GNU/PAX metadata parsing in both archive format detection and extraction. The shared 54 MiB stream limit includes headers, padding, metadata, and file contents while preserving the existing member-size and total-file-size limits.
Report limit violations through the caller's error type, preserve caller-owned streams, and document the limit in the shared catalog reference.
Testing
uv run specify --helpuv sync && uv run pytestThe full suite used the documented worktree-local interpreter instead of the template's
uv run pytestinvocation:LC_ALL=en_US.UTF-8 .venv/bin/python -m pytest tests -n 4 -q --tb=short— passed: 13,691 passed, 130 skipped, 63 warnings.uv run specify --help— passed.A separate sample project is not applicable to this shared archive-helper change.
AI Disclosure
AI disclosure: GitHub Copilot using GPT-6.1 Sol performed autonomous, user-directed implementation and validation and generated the code, tests, documentation, and PR description. Reasoning effort was not exposed to the session. A GitHub Copilot security-review subagent assisted with the initial assessment; its model was not reported. No line-by-line human review is claimed.