-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
tmpdir: prevent symlink attacks and TOCTOU races (CVE-2025-71176) #14279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
laurac8r
wants to merge
41
commits into
pytest-dev:main
Choose a base branch
from
laurac8r:hotfix/cve
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+398
−31
Open
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
f601e56
tmpdir: prevent symlink attacks and TOCTOU races (CVE-2025-71176)
ec18caa
docs: added a bugfix changelog entry
b3cb812
chore: added name to `AUTHORS` file
5894e25
chore: adding test coverage
7f93f0a
chore: Add tests for tmp_path retention configuration validation
e232f12
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] fe0832b
chore: improve coide coverage for edge case
23000e8
Merge remote-tracking branch 'origin/hotfix/cve' into hotfix/cve
09bd0ed
Merge branch 'pytest-dev:main' into hotfix/cve
laurac8r 068fd4e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a724939
chore: remove dead code
9a4451a
Merge branch 'pytest-dev:main' into hotfix/cve
laurac8r 95f39ee
Merge branch 'pytest-dev:main' into hotfix/cve
laurac8r ed4a728
Apply suggestion from @webknjaz
laurac8r 206731a
Apply suggestion from @webknjaz
laurac8r 975b944
Merge branch 'pytest-dev:main' into hotfix/cve
laurac8r d456ad4
docs: enhance CVE-2025-71176 changelog entry with hyperlinks
a624cc1
Merge remote-tracking branch 'origin/hotfix/cve' into hotfix/cve
c025681
refactor(tmpdir): extract _safe_open_dir into a reusable context manager
f2c6f23
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d58ba2a
docs: update docstring
9d501ec
Merge remote-tracking branch 'origin/hotfix/cve' into hotfix/cve
45bdce9
refactor(testing): consolidate imports in test_tmpdir.py
879767b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ab3d9e4
refactor: consolidate imports and hoist getpass to module level
40e8fdd
Merge remote-tracking branch 'origin/hotfix/cve' into hotfix/cve
64aa0f1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e1ab060
test(tmpdir): make test_pytest_sessionfinish_handles_missing_basetemp…
c8be3c5
Merge remote-tracking branch 'origin/hotfix/cve' into hotfix/cve
3a27865
hotfix: mitigate DoS when a non-directory file blocks pytest-of-<user>
e403fbf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0e3581c
test(tmpdir): add regression test for mkdir failure after unlink in _…
f9918cf
Merge remote-tracking branch 'origin/hotfix/cve' into hotfix/cve
d1d6cae
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 24003ce
Merge branch 'main' into hotfix/cve
064b26e
tmpdir: replace predictable rootdir with mkdtemp-based random suffix …
124027e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 654e3dd
refactor: style: minor code formatting cleanup in tmpdir and test_tmpdir
9a586f6
Merge remote-tracking branch 'origin/hotfix/cve' into hotfix/cve
43aa2c8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e696db0
test(tmpdir): strengthen fchmod defense-in-depth test by widening per…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Fixed a symlink attack vulnerability ([CVE-2025-71176](https://github.com/pytest-dev/pytest/issues/13669)) in | ||
| the [tmp_path](https://github.com/pytest-dev/pytest/blob/295d9da900a0dbe8b4093d6a6bc977cd567aa4b0/src/_pytest/tmpdir.py#L258) | ||
| fixture's base directory handling. | ||
|
|
||
| The ``pytest-of-<user>`` directory under the system temp root is now opened | ||
| with [O_NOFOLLOW](https://man7.org/linux/man-pages/man2/open.2.html#:~:text=not%20have%20one.-,O_NOFOLLOW,-If%20the%20trailing) | ||
| and verified using | ||
| file-descriptor-based [fstat](https://linux.die.net/man/2/fstat)/[fchmod](https://linux.die.net/man/2/fchmod), | ||
| preventing symlink attacks and [TOCTOU](https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use) races. |
laurac8r marked this conversation as resolved.
Show resolved
Hide resolved
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.