Skip to content

EXT4: reject '..' components that escape the image root during unpack - #897

Merged
jglogan merged 1 commit into
apple:mainfrom
jglogan:ext4-nopathtraversal
Aug 28, 2026
Merged

EXT4: reject '..' components that escape the image root during unpack#897
jglogan merged 1 commit into
apple:mainfrom
jglogan:ext4-nopathtraversal

Conversation

@jglogan

Copy link
Copy Markdown
Contributor

Closes#896.

libarchive permits path traversal components (. and ..) in entry pathnames during entry iteration. The library will only extract (in archive_write_disk) an entry if the normalized pathname resolves under the extraction root.

Our EXT4 unarchiver currently prepends '/' to a pathname — an entry's own path, or a hardlink entry's link target, both of which are resolved through the same normalization function — and then attempts to create the corresponding directory entry or link regardless of whether the original relative path would escape the root, yielding a filesystem image that is incorrect at least and corrupt at worst.

Valid OCI archive-type content blobs should never contain escaping pathnames. The unarchiver should treat such pathnames as garbage input and throw an exception on the first such pathname, whether it originates from an entry path or a hardlink target.

Test plan

  • swift test --filter ContainerizationEXT4Tests passes (68 tests)
  • New regression tests cover: traversal in entry path, traversal in hardlink target, traversal via an already-absolute pathname, harmless self-cancelling .. (accepted and resolved correctly), .. escaping beyond a single real component, and leading .//trailing / tolerance

@dkovba
dkovba self-requested a review August 28, 2026 01:15
@jglogan
jglogan merged commit 2faaf9b into apple:mainAug 28, 2026
7 checks passed
@jglogan
jglogan deleted the ext4-nopathtraversal branch August 28, 2026 20:32
Sign up for freeto 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.

[Bug]: EXT4 archive unpack should fail if path traversal components are detected.

2 participants

@jglogan@dkovba