Skip to content

fix: add zip-slip guard to update_command.py#24

Merged
hozblok merged 1 commit into
masterfrom
fix/11-update-command-zip-slip
May 16, 2026
Merged

fix: add zip-slip guard to update_command.py#24
hozblok merged 1 commit into
masterfrom
fix/11-update-command-zip-slip

Conversation

@hozblok

@hozblok hozblok commented May 11, 2026

Copy link
Copy Markdown
Owner

Problem. ZipFile.extractall() will write outside the target directory if the archive contains entries with .. or absolute paths. Boost releases are trusted, but the URL is unauthenticated and --version is user-supplied — a mirror compromise or a typo pointing at the wrong asset shouldn't be able to overwrite arbitrary files on the host.

Fix. boost_headers/update_command.py — before extractall, resolve each namelist() entry against script_dir.resolve() and call Path.relative_to(). Anything that escapes raises RuntimeError before any write happens.

No unit test in this PR. The script lacks an if __name__ == "__main__": guard (item #22, in the cleanup batch PR), so it cannot be imported without running the argparse + download + rmtree flow. The check is small and reviewable inline; once #22 lands, a follow-up can extract the guard into a testable helper. Full suite still 316/316.

ZipFile.extractall() will happily write outside the target directory if
the archive contains entries with '..' or absolute paths. Boost releases
are trusted, but the URL is unauthenticated and the script also accepts
a user-supplied --version that determines the URL. A mirror compromise
or a malformed asset should not be able to overwrite arbitrary files on
the host.

Before extracting, resolve each member path against script_dir and
verify the resolved destination still lives under it. Anything that
escapes raises RuntimeError before any write happens.

No unit test in this PR: the script lacks an `if __name__ == "__main__":`
guard (PR #22 covers that), which means it cannot be imported without
running the argparse + download + rmtree flow. The check is small and
easy to review inline; once #22 lands, a follow-up can extract it into
a testable helper.

See ai/improvements_2026-05-09.md item #11.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hozblok hozblok marked this pull request as ready for review May 16, 2026 21:53
@hozblok hozblok merged commit e7f91f3 into master May 16, 2026
2 checks passed
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.

1 participant