Skip to content

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

Open
bunlongheng wants to merge 1 commit into
jaypipes:mainfrom
bunlongheng:fix/untar-path-traversal
Open

fix(snapshot): contain tar entry paths within destination directory#472
bunlongheng wants to merge 1 commit into
jaypipes:mainfrom
bunlongheng:fix/untar-path-traversal

Conversation

@bunlongheng

Copy link
Copy Markdown

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.

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