Repository navigation
python: backport gh-157579 (CVE-2026-12345, tempfile cleanup race) to 3.14.8 - #895
Merged
Merged
Conversation
… 3.14.8 TemporaryDirectory cleanup re-resolved paths while resetting permissions, so an attacker able to modify the tree during cleanup could swap a directory for a symlink and have files outside the temporary directory removed (PSF-2026-42). Carry upstream's own 3.14 backport (python/cpython#158430, merge 58ed0259, merged 2026-10-09, after 3.14.8) byte-for-byte; it applies at fuzz 0 to 3.14.8 and touches none of the files 0002/0003 change. Regression test tempfile_cleanup_race_fix: fails on stock 3.14.8 (no dir-fd cleanup, no rmtree onexc kwargs), passes with the patch, and checks a read-only subtree still cleans up completely. We stay on the 3.14 series (pkgs#891 closed: node-lts's configure rejects Python 3.15); this was the one advisory 3.15.0 fixed that 3.14.8 lacked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Member
Author
|
/build |
norrietaylor
approved these changes
Oct 19, 2026
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The patch is identical to the upstream 3.14 backport 58ed0259 (GH-158430); only the hunk-header context differs. It's not in v3.14.8, applies cleanly, and is wired in before configure.
Nit, build.ncl:353: os.chmod(sub, S_IRUSR|S_IXUSR) won't force the permission-reset path if tests run as root. The presence checks still keep the test meaningful.
Generated by Claude Code
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Oct 19, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 20, 2026
bryan-minimal
added a commit
that referenced
this pull request
Oct 20, 2026
classpath-0.93 failed on pkgs#895 (a python-only change) with
`sort: /usr/lib/libc.so.6: version GLIBC_2.43 not found`. The rungs
depend on the whole glibc-bedrock-2.42, and its sealed amd64 tarball
carries a full glibc 2.42 at /usr/lib (listed: usr/lib/libc.so.6,
ld-linux-x86-64.so.2, 4087 entries), whatever its output globs say. That
collides with production glibc 2.44 path for path (~1400 files); the
sandbox keeps whichever lands first ("Not linking ... already exists"),
which shifts with fetch timing, so an unrelated python change flipped
classpath's /usr/lib/libc.so.6 to 2.42 and every production tool in the
sandbox stopped loading.
The new glibc-bedrock-2.42-sysroot collection carries only
usr/lib/glibc-bedrock-2.42/{lib,include}, all the rungs use (SR=), and
the 28 rungs import it in place of glibc-bedrock-2.42. A collection
because `subsetOf` is only supported in runtime_deps: in build_deps it
panics minimal's executor (op/src/specs.rs:88, todo!), which is what
stopped #937.
Verified on the lab (amd64, mip): main + #895's python + this builds
jikes-1.22 and classpath-0.93 (rc=0), with no glibc path conflict in
classpath's sandbox; without it, the same tree reproduces the failure.
Rebuilds the amd64 JVM ladder once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 20, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Oct 20, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Oct 20, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Oct 21, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Oct 21, 2026
bryan-minimal
added a commit
that referenced
this pull request
Oct 21, 2026
….2.2 swap main gained #941 (JVM ladder takes only the bedrock sysroot; the classpath glibc collision that failed #950's amd64 leg) and #895 (gh-157579 patch), which conflicted here only by adding beside this PR's pip wheel. Both kept: the 0004 patch with the other patches, then the ensurepip wheel swap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 22, 2026
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.
Why
We're staying on Python 3.14 for now. #891 (→ 3.15.0) is closed because the released node-lts
configurerejects Python 3.15 and the bump rebuilds 100+ packages. Of the 3 advisories 3.15.0 cleared, 3.14.8 already carries patches for two (poplib gh-143923, tarfile gh-157265). This PR covers the third:CVE-2026-12345 / PSF-2026-42 (MEDIUM), gh-157579.
tempfile.TemporaryDirectorycleanup re-resolved paths while resetting permissions. An attacker who can modify the tree during cleanup can replace a directory with a symlink and cause files outside the temporary directory to be removed.What
0004-gh-157579-tempfile-cleanup-race.patchis upstream's own 3.14 backport: [3.14] gh-157579: Fix race condition in the cleanup oftempfile.TemporaryDirectory(GH-157580) python/cpython#158430, merge58ed0259, merged to 3.14 on 2026-10-09, after 3.14.8 was cut. It is carried byte-for-byte.patch -p1 -N -F0 --dry-run).build.shapplies it the same fail-closed way as 0002/0003.build.nclcomment records where it came from, plus the drop condition: the first 3.14.x whose changelog lists gh-157579, which should be 3.14.9. From now on pkgmgr's updater checks this itself and removes patches that are already upstream (pkgmgr-rs#988).Test
tempfile_cleanup_race_fix(Standalone). The race itself can't be reproduced deterministically, so the test guards the fix's presence and normal behaviour:tempfile._rmtree_use_dir_fdis True, meaning cleanup works relative to open directory fds;shutil.rmtreehas the_onexc_kwargsparameter;I checked the test script locally with Python 3.14 against the stock and patched
tempfile.py/shutil.py: stock fails (both presence checks), patched passes. This was not a package build; CI/buildbot will build it.🤖 Generated with Claude Code
Summary by CodeRabbit