Where
-Infinity
0
Severity
6.8
AV:L/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:L

pytest through 9.0.2 on UNIX relies on directories with the /tmp/pytest-of-{user} name pattern, which allows local users to cause a denial of service or possibly gain privileges.

First published (updated )

I've been sleeping on this one because it doesn't affect our package manager, but if you use pytest on a multi-user system or for CI in the cloud, then maybe it is of interest.

Bug report: https://github.com/pytest-dev/pytest/issues/13669

I requested a CVE last week from MITRE but haven't heard back yet. The details are unexciting so I'll keep it short.

Summary =======

On UNIX, pytest uses a predictable naming scheme under /tmp with a UID check for added security. The UID check however will follow symlinks, and is vulnerable to TOCTOU. This leaves pytest vulnerable to several well-known vulnerabilities on multi-user systems. The risk ultimately depends on how pytest is used, but denial of service is trivial and code execution is possible.

Mitigation ==========

In the meantime, I would recommend creating your own temporary directory securely using, say $(mktemp -d), and then overriding the default using one of the standard environment variables (check the docs for python's tempfile.gettempdir) or PYTESTDEBUGTEMPROOT.

On linux, it's a good idea to set the relevant sysctls:

fs.protectedfifos = 2 fs.protectedregular = 2 fs.protectedsymlinks = 1 fs.protectedhardlinks = 1

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203