Repository navigation
Fix archive extraction - #742
Merged
Merged
Conversation
Usually it is not possible to create device nodes. But some folks may run Bob as root inside a container. As there is no legitimate reason to have device nodes as build result, just refuse to extract such members.
The existing tar extraction filter had multiple shortcomings. The most severe one was that hard link targets could point outside of the workspace. This basically allowed overwriting any file on the system. We now validate that hard link targets are neither absolute nor that they point outside of the workspace. Note that symlinks are allowed to be absolute. We expect that some packages have such symlinks as their result. To prevent any problems, all target file name checks are done through os.path.realpath() to resolve such symlinks. Then the archive member name was not normalized. For files, this is fine. But for directories it's not. Before writing a member, tarfile calls os.makedirs(dirname(targetpath)) on the raw name. If that path contains .. segments, it can lead to created directories outside the workspace. Additionally the fix for CVE-2026-7774 has been integrated too.
The TarFile extraction_filter and os.path.ALLOW_MISSING have been backported all the way to Python 3.9.23. There is no reason to run unpatched versions nowadays. Bail out with a proper error message otherwise.
Make sure we do not extract malicious archive members in the future.
Running "python -m tarfile -e" is unsafe, at least before Python 3.14. That command doesn't apply any extraction filter, and whatever python is first on PATH might not be Bob's interpreter. Instead, Bob now extracts in-process through tarfileOpen(), so _tarExtractFilter and the check for old Python versions both apply.
On Windows Bob can use the Python tarfile module to extract archives. Make sure the internal version is used to prevent problems with malicious archives.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #742 +/- ##
==========================================
+ Coverage 90.39% 90.42% +0.02%
==========================================
Files 59 59
Lines 17408 17451 +43
==========================================
+ Hits 15736 15780 +44
+ Misses 1672 1671 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.