Reject negative PAX size values when reading TAR headers#128368
Open
iremyux wants to merge 2 commits into
Open
Reject negative PAX size values when reading TAR headers#128368iremyux wants to merge 2 commits into
iremyux wants to merge 2 commits into
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-formats-tar |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens tar archive parsing by rejecting negative PAX extended-attribute size values when applying extended attributes during header read, preventing invalid archives from being accepted with a negative entry length.
Changes:
- Add validation that the
PAX"size"extended attribute, when present, must be non-negative (otherwise throwInvalidDataException). - Aligns
PAXsize handling with existing negative-size checks already present for other size fields (e.g., headersize, GNU sparserealsize).
alinpahontu2912
approved these changes
May 19, 2026
MihaZupan
reviewed
May 19, 2026
| @@ -151,6 +151,11 @@ internal void ReplaceNormalAttributesWithExtended(IEnumerable<KeyValuePair<strin | |||
| // The 'size' header field only fits 12 bytes, so the data section length that surpases that limit needs to be retrieved | |||
| if (TarHelpers.TryGetStringAsBaseTenLong(ExtendedAttributes, PaxEaSize, out long size)) | |||
| { | |||
| if (size < 0) | |||
Member
There was a problem hiding this comment.
Is this something worth having a test for?
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.
This change adds a validation check while applying extended attributes in TarHeader.Read.cs so that a negative size value from PAX metadata now throws InvalidDataException instead of being accepted.