Repository navigation
Prevent zip option injection from staged filenames - #78015
Conversation
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Code Quality Reviewer completed the code quality review. PR Code Quality ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
There was a problem hiding this comment.
🟡 Changes recommended
A file entry equal to the root directory bypasses validation and becomes ./, causing zip -r to archive the entire root, including unselected files.
2 open issues
What changed in this PR
This PR hardens artifact uploads against zip option injection from staged filenames, addressing #78012.
Changes:
- Reject leading-dash filenames during staging and archive creation.
- Prefix archive members with
./and ensure temporary-directory cleanup on archive errors. - Add regression coverage for filename rejection and safe zip arguments.
| File | Description |
|---|---|
actions/setup/js/upload_artifact.test.cjs |
Tests rejection of staged and auto-copied leading-dash filenames. |
actions/setup/js/upload_artifact.cjs |
Validates filenames before copying or uploading. |
actions/setup/js/artifact_client.test.cjs |
Tests archive rejection and explicit zip member arguments. |
actions/setup/js/artifact_client.cjs |
Validates and prefixes archive members; protects cleanup on failure. |
Review effort: Max (dynamic)
| ensureZipAvailable(); | ||
| const relativeFiles = files.map(file => path.relative(rootDirectory, file)); | ||
| const invalid = relativeFiles.find(rel => !rel || rel.startsWith("..") || path.isAbsolute(rel)); | ||
| if (invalid) { |
| const spawnSyncSpy = vi.spyOn(childProcess, "spawnSync"); | ||
|
|
||
| const client = new DefaultArtifactClient(); | ||
| await expect(client.uploadArtifact("artifact", [filePath], tmpDir)).rejects.toThrow("leading-dash filenames"); | ||
|
|
||
| expect(spawnSyncSpy).not.toHaveBeenCalled(); |
|
🎉 This pull request is included in a new release. Release: |


createZipFromFilespassed staged paths directly tozip, allowing a leading-dash filename such as-Tto be interpreted as an option. Reject these filenames during staging and archive creation, and prefix archive members with./.-Tis rejected and regular member paths are safely passed tozip.