Skip to content

fix(snapshot): contain tar entry paths within destination directory - #472

Merged
jaypipes merged 1 commit into
jaypipes:mainfrom
bunlongheng:fix/untar-path-traversal
Sep 4, 2026
Merged

jaypipes merged 1 commit into
jaypipes:mainfrom
bunlongheng:fix/untar-path-traversal

Conversation

@bunlongheng

Copy link
Copy Markdown
Contributor

The Untar helper in pkg/snapshot/unpack.go joins tar entry names to the destination root without checking whether the result stays inside it. A crafted snapshot archive with entries like ../../etc/cron.d/evil can write files outside the intended directory.

Added a filepath.Clean prefix check that rejects any entry - including symlinks whose target resolves outside root - before any file or directory is created.

@jaypipes jaypipes left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @bunlongheng for the clean PR summary and fix. Much appreciated :)

@jaypipes

Copy link
Copy Markdown
Owner

@bunlongheng please do sign the DCO. See here for more information.

@jaypipes

Copy link
Copy Markdown
Owner

@bunlongheng ping. please sign your commit and the DCO :) See here for more information.

@jaypipes

jaypipes commented Sep 1, 2026

Copy link
Copy Markdown
Owner

@bunlongheng final ping. please sign your commit and the DCO, otherwise I will close this PR out by end of week. Thank you!

Signed-off-by: Bunlong Heng <bheng.code@gmail.com>
@bunlongheng
bunlongheng force-pushed the fix/untar-path-traversal branch from 8a294b5 to 8642dec Compare September 1, 2026 15:49
@bunlongheng

Copy link
Copy Markdown
Contributor Author

@jaypipes Done - amended the commit with the DCO sign-off and pushed. The DCO check is green now. Sorry for the delay, and thank you for the patience with the reminders (and for the approval)!

@jaypipes jaypipes left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bunlongheng!

@jaypipes
jaypipes merged commit 72554a2 into jaypipes:main Sep 4, 2026
15 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.

2 participants