[release/7.0] Fix PAX extended attribute reading logic to treat '=' character as valid in the value strings. #83177
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.
Backport of #82810 to release/7.0
/cc @carlossanlop
Customer Impact
The dotnet/sdk-container-builds team reported that they were unable to read TAR entries in the PAX format that contained the
=
character in their extended attribute metadata.In the PAX TAR format, each entry representing a filesystem object is always preceded by an entry containing only metadata information in its data section. This metatada is known as extended attributes, and they are stored in the form of key-value-pairs, where the separator character between keys and values is the
=
character, and the separator of one key-value with another is the\n
character.The sdk-container-builds team is using those extended attributes to store Windows Security Descriptor data. An example of a value that they were unable to read is:
[MSWINDOWS.rawsd](https://github.com/buildpacks/rfcs/blob/main/text/0076-windows-security-identifiers.md)
AQAAgBQAAAAkAAAAAAAAAAAAAAABAgAAAAAABSAAAAAhAgAAAQIAAAAAAAUgAAAAIQIAAA==
The root cause of this bug is that we were explicitly disallowing any
=
characters in the value part of the key-value-pair, after detecting the very first one and considering it the separator. In reality, the TAR spec does not specify that this restriction should be in place, and we should allow any number of=
characters in the value section, since we only care about the first one.So the fix was to remove the code block that was preventing the use of more than one
=
.Testing
tar
tool to ensure the behavior was not unexpectedly different.=
characters in the value string, both in our sync and async APIs.Risk
Low.
The fix just removes an if block that prevented a desired behavior.
Even though the PAX format is the default one in our
TarFile
APIs, users can only specify custom extended attributes when manually constructing a TAR archive using the advanced APIs: aTarWriter
instance, and thePaxTarEntry
constructor that takes a dictionary.No OOB changes needed for this assembly.
Notes
Fixing this issue made us discover that we could add more robust validation in the
PaxTarEntry
constructor that takes a dictionary of key-value-pairs to use as extended attributes, to safe-guard users from creating TAR archives that contain forbidden characters in these values. We will merge that fix in .NET 8. It may not meet the bar for a backport by itself.