fix(portability): vet zip inventory before import - #7273
Conversation
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
1 similar comment
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
Open PR relationship auditThis is a consolidated, point-in-time code-level audit note. It compares complete merge-base diffs and current/merged code; it does not treat a shared topic as duplication or partial coverage as completion. Relationship findings
No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit. |
ba64967 to
d94797e
Compare
|
Rebased onto main Conflicts: none, clean rebase. Both insertion points ( Gates run locally (changed files only): Please review the rebase. A maintainer push makes the maintainer the last pusher, so under the repo's last-push rule a second approver is needed. Reply if anything looks wrong. |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Both dashboard callers run these functions via Design-Verdict: PASS Closes a counted residual by moving the existing cap ahead of the allocation it bounds, via the shared vet built for exactly this — right layer, right channel. [DESIGN-REVIEWED] d94797e |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of All evidence is gathered. Both remaining unvetted First-Principles-Verdict: PASS Verify the #6501 claim: the description's only provenance link is that merged review; the red-on-base test otherwise carries the defect on its own. What this change shipsIntent: stop an uploaded import archive from allocating its zip inventory before the size cap can refuse it — a FIX. Inventory (4 items)
Counted: [FIRST-PRINCIPLES-REVIEWED] d94797e |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed Review detailsThe candidate requires a legitimate import archive whose central directory exceeds No findings. [OPUS-REVIEWED] d94797e |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
hoang-phan98
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: the two untrusted-archive import parse sites still constructed zipfile.ZipFile before the shared inventory cap ran, so the member-count and central-directory caps were not enforced ahead of the parse; this calls the repo's pre-existing shared vet first and maps its rejection reasons onto the import error paths, one source file plus its test. CodeQL is not applicable on this fork PR (default-setup emits no check-run); SAST coverage is Semgrep only, latest run success with 0 annotations.
Problem / Motivation
The dashboard portability import paths constructed
zipfile.ZipFilebeforechecking their member caps.
ZipFilematerializes the central-directoryinventory during construction, so a crafted import could consume memory before
the existing post-open guard ran.
This is the exact portability residual counted and deferred by the merged review
on #6501.
Why it matters
Portability archives are uploaded input. A cap that runs only after inventory
allocation does not protect preview or apply from the allocation it is meant to
bound.
What changed (motivation → approach → change)
Uploaded archives could materialize an over-cap central-directory inventory
before rejection →
ZipFilematerializes that inventory during construction,ahead of the existing post-open cap → run the existing shared
vet_zip_inventorypreflight beforeZipFileconstruction in bothvalidate_import_zipand the defense-in-depthapply_import_zippath.Preflight rejections use each function's existing return/exception channel, and
the post-open member and uncompressed-size checks remain in place.
Tests
ZipFilewas constructed foran archive whose declared member count exceeded the import cap.
and invalid-ZIP tests pass (4/4).
Black, and
git diff --check.were installed solely for reassurance, so lockfile-complete server CI owns
the typecheck.
Manual verification
N/A — focused unit coverage directly asserts the pre-construction ordering and
both public import entry points.
Related Issues
No linked issue. This is the reviewer-counted residual from merged #6501.
Pattern harvest
Rule candidate: review-prompt
Pattern: Archive safety caps must run before a parser/materializer performs the
allocation the cap is intended to bound.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement