Hi,

I found that --no-absolute-filenames does not contain member names
with interior .. components. safer_name_suffix() only strips leading /
and ../, so a member named e.g. a/../../evil is written outside the
extraction directory even with the flag on.

Reproducer (single regular-file member, no symlink anywhere, flag on):
build a newc archive containing one regular file named a/../../evil,
then run cpio -id --no-absolute-filenames in an empty directory. The
file evil is created one level above the extraction directory, with
exit code 0 and no warning.

This is not CVE-2023-7216 (symlink following, WONTFIX) and not
CVE-2026-66484 (tar hard-link target, absolute path, link() to an
existing file). This is the member name itself, relative interior ..,
open() writing new content. The CVE-2026-66484 fix touches only
stash_tar_linkname(), so this path is still open at HEAD e5bb73f8.

The attached patch collapses interior .. components lexically under
the flag (src/util.c). Verified on unpatched and patched builds: a
42-case matrix across newc, ustar and odc (files, dirs, symlinks,
hardlinks, fifos, deep paths) — the unpatched binary escapes in 21 of
42 cases, the patched binary in 0 cases of this class. make check
passes 18/18.

Known limitation, disclosed and out of scope for this patch: two-step
symlink following (a link pointing to .., then a member under that
link) still escapes. That is a different mechanism, the same class as
CVE-2023-7216.

Please review, and let me know if you would like any changes.

Thanks,
Mat Lail Pajri

Attachment: cpio-interior-dotdot.patch
Description: Binary data

Reply via email to