Uh oh!
There was an error while loading. Please reload this page.
EXT4: reject '..' components that escape the image root during unpack - #897
Merged
Conversation
dkovba
self-requested a review
August 28, 2026 01:15
dkovba
approved these changes
Aug 28, 2026
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Aug 28, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes#896.
libarchive permits path traversal components (
.and..) in entry pathnames during entry iteration. The library will only extract (inarchive_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 ContainerizationEXT4Testspasses (68 tests)..(accepted and resolved correctly),..escaping beyond a single real component, and leading.//trailing/tolerance