Skip to content

storage: fix corner cases in archive#856

Open
caxu-rh wants to merge 1 commit into
containers:mainfrom
caxu-rh:storage-pkg-archive-path-escape
Open

storage: fix corner cases in archive#856
caxu-rh wants to merge 1 commit into
containers:mainfrom
caxu-rh:storage-pkg-archive-path-escape

Conversation

@caxu-rh
Copy link
Copy Markdown
Contributor

@caxu-rh caxu-rh commented May 19, 2026

A symlink or hardlink in the archive pointing to a target in a sibling directory of the extract dir matching the same prefix, e.g. a link at the root of the archive /foo with extract dir /tmp/root pointing at ../rootx/bar, is not caught.

With this fix, the goal is to make sure that extractDir passed into extractTarFileEntry is always Cleaned (ensuring there is no trailing slash), and then add in a trailing slash when matching with HasPrefix. We can add a Clean at the top of extractTarFileEntry, if that would be more clear.

I added an additional set of test cases covering the scenario with a similarly named directory destx, in addition to the existing scenario testing stuff in victim. The tests could also just be adjusted to just use destx entirely and remove victim, but I'm not sure if there's still value in testing those separately, hence left it separate for now.

A symlink or hardlink in the archive pointing to a
target in a sibling directory of the extract dir
matching the same prefix, e.g. a link at the root
of the archive `/foo` with extract dir `/tmp/root`
pointing at `../rootx/bar`, is not caught as a breakout.

Signed-off-by: Caleb Xu <caxu@redhat.com>
@github-actions github-actions Bot added the storage Related to "storage" package label May 19, 2026
@mtrmac mtrmac changed the title storage: fix breakout corner cases in archive storage: fix corner cases in archive May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

storage Related to "storage" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant