Skip to content

Fix zip-slip blacklist bypass in isDangerousZipEntryName - #621

Merged
kalenkevich merged 1 commit into
google:mainfrom
prasanna8585:fix/zip-slip-segment-check
Aug 5, 2026
Merged

kalenkevich merged 1 commit into
google:mainfrom
prasanna8585:fix/zip-slip-segment-check

Conversation

@prasanna8585

@prasanna8585 prasanna8585 commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

isDangerousZipEntryName used prefix/substring string checks (startsWith('/'), startsWith('../'), includes('/../')) that miss entries whose traversal segment isn't followed by more path content — e.g. an entry literally named scripts/.. passes all three checks, as does any entry using a backslash separator instead of a forward slash.

Confirmed via a dynamic PoC: crafted a real zip with Python's zipfile module (bypassing AdmZip's own write-side path normalization, which is not representative of an attacker-crafted zip), fed the raw bytes through the actual compiled loadSkillFromZipBuffer, and confirmed scripts/.. passes the old check and reaches skill.resources.scripts['..']. Also confirmed a second, independent check in materializeFiles (utils/file_utils.ts) catches and rejects the resulting escape attempt in every consumer that writes this data to disk — so this closes a genuine defense-in-depth gap rather than a currently-reachable filesystem escape in the traced call paths.

Replaces the checks with a segment-based approach: split on both / and \, reject if any segment is exactly .., plus an explicit absolute-path check (POSIX and Windows). Added two regression test cases for the confirmed bypasses.

isDangerousZipEntryName rejected entries via string prefix/substring
checks (startsWith('/'), startsWith('../'), includes('/../')), which
misses entries whose traversal segment isn't bounded by a following
'/' -- e.g. an entry named exactly 'scripts/..' (no trailing content)
passes all three checks, as does any entry using backslash as a
separator instead of forward slash (e.g. 'scripts\\..\\..\\evil').

Confirmed via a dynamic PoC (crafted a real zip with Python's zipfile
module, bypassing AdmZip's own write-side path normalization, and fed
the raw bytes through the actual compiled loadSkillFromZipBuffer) that
'scripts/..' passes the old check and reaches
skill.resources.scripts['..']. A second, independent hardened check in
materializeFiles (utils/file_utils.ts) was confirmed to catch and
reject the resulting escape attempt in every consumer of this data
that writes to disk, so this fix closes a genuine gap in
defense-in-depth rather than a currently-reachable filesystem escape.

Replaces the prefix/substring checks with a segment-based check: split
on both '/' and '\\' and reject if any segment is exactly '..', plus
an explicit absolute-path check (POSIX and Windows style). Verified
against the previous bypass cases, the existing test suite (68 tests,
all still pass), and additional false-positive traps (filenames merely
containing '..' as a substring, e.g. 'a/b..c/d', must not be rejected).
@Varun-S10 Varun-S10 self-assigned this Aug 5, 2026
@Varun-S10

Copy link
Copy Markdown
Contributor

Hi @kalenkevich, I have tested and validated the proposed changes in this PR. Could you please review this PR?

@Varun-S10 Varun-S10 added the needs review [Status] The PR/issue is awaiting review from the maintainer label Aug 5, 2026
@kalenkevich
kalenkevich merged commit 7bc05f6 into google:main Aug 5, 2026
17 of 22 checks passed
@AmaadMartin AmaadMartin mentioned this pull request Aug 5, 2026
kalenkevich added a commit that referenced this pull request Aug 5, 2026
Both PR titles used "Fix <subject>" with no colon, so the squash subjects
were not conventional commits and release-please dropped them from the
generated changelog:

  d3f250e Fix unsafe A2A peer-supplied transferToAgent metadata (#596)
  7bc05f6 Fix zip-slip blacklist bypass in isDangerousZipEntryName (#621)

Both are core-only security fixes landed after adk-v1.5.0, so they belong
in the adk 1.6.0 Bug Fixes section. Entries are inserted in the position
release-please would have emitted them.
kalenkevich added a commit that referenced this pull request Aug 6, 2026
* Release: v1.6.0

* chore(changelog): add missing #596 and #621 security fixes to adk 1.6.0

Both PR titles used "Fix <subject>" with no colon, so the squash subjects
were not conventional commits and release-please dropped them from the
generated changelog:

  d3f250e Fix unsafe A2A peer-supplied transferToAgent metadata (#596)
  7bc05f6 Fix zip-slip blacklist bypass in isDangerousZipEntryName (#621)

Both are core-only security fixes landed after adk-v1.5.0, so they belong
in the adk 1.6.0 Bug Fixes section. Entries are inserted in the position
release-please would have emitted them.
prasanna8585 added a commit to prasanna8585/adk-js that referenced this pull request Aug 21, 2026
isDangerousZipEntryName rejected entries via string prefix/substring
checks (startsWith('/'), startsWith('../'), includes('/../')), which
misses entries whose traversal segment isn't bounded by a following
'/' -- e.g. an entry named exactly 'scripts/..' (no trailing content)
passes all three checks, as does any entry using backslash as a
separator instead of forward slash (e.g. 'scripts\\..\\..\\evil').

Confirmed via a dynamic PoC (crafted a real zip with Python's zipfile
module, bypassing AdmZip's own write-side path normalization, and fed
the raw bytes through the actual compiled loadSkillFromZipBuffer) that
'scripts/..' passes the old check and reaches
skill.resources.scripts['..']. A second, independent hardened check in
materializeFiles (utils/file_utils.ts) was confirmed to catch and
reject the resulting escape attempt in every consumer of this data
that writes to disk, so this fix closes a genuine gap in
defense-in-depth rather than a currently-reachable filesystem escape.

Replaces the prefix/substring checks with a segment-based check: split
on both '/' and '\\' and reject if any segment is exactly '..', plus
an explicit absolute-path check (POSIX and Windows style). Verified
against the previous bypass cases, the existing test suite (68 tests,
all still pass), and additional false-positive traps (filenames merely
containing '..' as a substring, e.g. 'a/b..c/d', must not be rejected).
prasanna8585 pushed a commit to prasanna8585/adk-js that referenced this pull request Aug 21, 2026
* Release: v1.6.0

* chore(changelog): add missing google#596 and google#621 security fixes to adk 1.6.0

Both PR titles used "Fix <subject>" with no colon, so the squash subjects
were not conventional commits and release-please dropped them from the
generated changelog:

  d3f250e Fix unsafe A2A peer-supplied transferToAgent metadata (google#596)
  7bc05f6 Fix zip-slip blacklist bypass in isDangerousZipEntryName (google#621)

Both are core-only security fixes landed after adk-v1.5.0, so they belong
in the adk 1.6.0 Bug Fixes section. Entries are inserted in the position
release-please would have emitted them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review [Status] The PR/issue is awaiting review from the maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants