Conversation
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
Two hostile-image checks lived only in the reader. Xattrs: the reader rejects an undefined name index (7 upward, which used to map to the empty prefix and let an image spell "security.capability" in full under it, colliding with the properly prefixed entry) and a key listed twice (which was taken last-wins, so the parser's iteration order picked which copy a policy decision saw). parseXattrsFromBuf, the copyFromImage fast path, still did both — so an image the reader refused to Stat would still be copied by CopyFrom(MetadataOnly), spoofed capability included. Route its names through xattrIndex.prefix(), propagate long-prefix lookup failures instead of swallowing them, and reject duplicates; the parser now returns an error and copyFromImage fails the copy on it. Dirent names: checkDirentName rejects separators and NULs but let a zero-length name through. No writer emits one, and as a path element it names the directory itself, so a lookup for it silently succeeds; ReadDir handed it out as an entry, and the fast path — which strips trailing NULs first, so an all-NUL entry became empty — skipped it silently. Reject it in checkDirentName, which covers all four parse sites, and move the fast path's check ahead of its "."/".." filter so the empty case is an error there too. The tampered image in the new test shows why this is corruption and not cosmetics: alongside the empty entry the neighbouring name reads back as "..a". Tests: TestCopyFromImageXattrParity (undefined index, duplicate key — both fail on the previous parser) and TestEmptyDirentNameIsRejected (reader and CopyFrom; fails on the previous reader with the entry list ["" "..a" "b"]). Signed-off-by: apostasie <spam_blackhole@farcloser.world> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
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 free
to 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.
No description provided.