Skip to content

Fix archive extraction - #742

Merged
jkloetzke merged 6 commits into
BobBuildTool:masterfrom
jkloetzke:fix-archive-extract
Nov 16, 2026
Merged

jkloetzke merged 6 commits into
BobBuildTool:masterfrom
jkloetzke:fix-archive-extract

Conversation

@jkloetzke

Copy link
Copy Markdown
Member

No description provided.

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

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.23077% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.42%. Comparing base (e05a6d5) to head (eddabac).

Files with missing lines Patch % Lines
pym/bob/scm/url.py 88.00% 3 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jkloetzke
jkloetzke merged commit f8d2851 into BobBuildTool:master Nov 16, 2026
11 checks passed
@jkloetzke
jkloetzke deleted the fix-archive-extract branch November 16, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant