Skip to content

fix(media): keep a tool kit's archive entries inside its folder on Windows too - #112

Merged
houko merged 1 commit into
mainfrom
fix/toolkit-zip-slip
Nov 11, 2026
Merged

houko merged 1 commit into
mainfrom
fix/toolkit-zip-slip

Conversation

@houko

@houko houko commented Nov 11, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the open code scanning alert, CodeQL go/zipslip on packages/media/toolkit.go: "Unsanitized archive entry, which may contain '..', is used in a file system operation."

CodeQL flags the code because it doesn't treat the hand-written check as a sanitizer, and on Windows that check really did have a hole:

  • untarGz refused entries that were absolute or started with ../, but it judged them by slashes only.
  • Windows also treats a backslash as a separator. So an entry named ..\evil passed the check, and filepath.Join then wrote it next to the kit's folder instead of inside it.

The check is now filepath.IsLocal on the name as the current system reads it. On Windows that also refuses drive letters and reserved device names such as NUL.

How exposed this was: kits are pinned by SHA-256, so only a tampered archive that matched a pinned checksum could have used this hole.

Test plan

  • TestInstallKitRejectsUnsafeArchives adds Windows-only cases: ..\evil, bin\..\..\evil, C:\evil and C:evil. On other systems these are ordinary file names.
    • With the old check, ..\evil would be extracted outside the folder, and the test would fail with "ffmpeg is not in the download" instead of errUnsafeEntry.
  • go test ./packages/media/ passes locally, and go vet passes for darwin, linux and windows. The Windows cases run in CI's Windows job.

Screenshots

None.

…ndows too

untarGz refused entries that were absolute or climbed out with ../, judged by slashes alone. Windows reads a backslash as a separator too, so an entry named ..\evil passed the check and filepath.Join put it beside the kit's folder. The check is now filepath.IsLocal on the name as this system reads it, which also refuses drive letters and reserved device names on Windows. The kits are pinned by SHA-256, so only a tampered release built into Kando could have done this. CodeQL's go/zipslip alert on toolkit.go pointed at the code, as it does not count the hand-written check as a sanitizer.
@github-actions github-actions Bot added area: media The media pipeline (packages/media) bug size/S 10 to 99 changed lines labels Nov 11, 2026
@houko
houko merged commit 232ded7 into main Nov 11, 2026
21 checks passed
@houko
houko deleted the fix/toolkit-zip-slip branch November 11, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: media The media pipeline (packages/media) bug size/S 10 to 99 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant