Skip to content

fix(amazonq): block zip slip in the legacy .NET transform artifact download - #3044

Open
tomar-gunjan wants to merge 3 commits into
mainfrom
tomgun/zipslip-legacy-download
Open

tomar-gunjan wants to merge 3 commits into
mainfrom
tomgun/zipslip-legacy-download

Conversation

@tomar-gunjan

Copy link
Copy Markdown
Contributor

Problem

TransformHandler.extractAllEntriesTo, used by aws/qNetTransform/downloadArtifacts, wrote each zip entry to path.join(target, entryName) with no containment check, so ../ entries were written outside the extraction folder. Delegate to the guarded Utils.extractAllEntriesTo, which the ATX download path already uses: it skips and logs any entry that resolves outside the folder.

Solution

Added checks
Adds a zip-slip test. Updates two tests that asserted the old behavior: the ENOENT log line, and a traversal entry expected to reach mkdir.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

…wnload

TransformHandler.extractAllEntriesTo, used by aws/qNetTransform/downloadArtifacts,
wrote each zip entry to path.join(target, entryName) with no containment check,
so ../ entries were written outside the extraction folder. Delegate to the
guarded Utils.extractAllEntriesTo, which the ATX download path already uses: it
skips and logs any entry that resolves outside the folder.

Adds a zip-slip test. Updates two tests that asserted the old behavior: the
ENOENT log line, and a traversal entry expected to reach mkdir.
@tomar-gunjan
tomar-gunjan requested a review from a team as a code owner November 12, 2026 18:18
@codecov-commenter

codecov-commenter commented Nov 12, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 88.23529% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...anguage-server/netTransform/atxTransformHandler.ts 87.80% 10 Missing ⚠️

📢 Thoughts on this report? Let us know!

Applying a step's checkpoint joined each path in metadata.json to the
solution folder without checking it. An entry with .. segments, an absolute
or drive path, or a Windows stream name could write, overwrite or delete a
file outside the solution folder. The job and step IDs also name the folder a
checkpoint is extracted to, so an ID like . or .. could extract it over the
job's data, such as source-files.json.

- Skip and log added, updated, removed and moved entries that resolve outside
  the solution folder or inside artifactWorkspace.
- Skip and log completed steps and diff artifacts whose job or step ID is not
  a plain folder name. A skipped diff artifact is reported as DiffApplyFailed.
- Name the HITL artifact file hitl-artifact-unknown when its tag is not a
  plain file name.

The paths are checked as text, so a link inside the solution folder is still
followed, as before.

Addresses LS40 and LS103 from the language servers security review
(P561843575).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants