You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Do not use tempfile.mktemp() for creating named pipes on Windows #137335
I change the pull requests to #137333, replace the mktemp() function.
bandit Tools:
Issue: [B306:blacklist] Use of insecure and deprecated function (mktemp).
Severity: Medium Confidence: High
CWE: CWE-377 (https://cwe.mitre.org/data/definitions/377.html)
More Info: https://bandit.readthedocs.io/en/1.8.6/blacklists/blacklist_calls.html#b306-mktemp-q
Location: C:\Users\Administrator\Desktop\cpython\lib\asyncio\windows_utils.py:34:14
33 """Like os.pipe() but with overlapped support and using handles not fds."""
34 address = tempfile.mktemp(
35 prefix=r'\.\pipe\python-pipe-{:d}-{:d}-'.format(
36 os.getpid(), next(_mmap_counter)))
37
changed the title [-]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` when possible[/-][+]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` in `asyncio.windows_utils`[/+]on Aug 3, 2025
changed the title [-]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` in `asyncio.windows_utils`[/-][+]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` in `asyncio.windows_utils` and `multiprocessing.util.arbitrary_address`[/+]on Aug 3, 2025
changed the title [-]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` in `asyncio.windows_utils` and `multiprocessing.util.arbitrary_address`[/-][+]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` in `asyncio.windows_utils` and `multiprocessing.util`[/+]on Aug 3, 2025
I won't consider it a security issue as it remains to show that it's possible to exploit a race condition here. The issue with mktemp is essentially when we have filename collisions, but the occurrences of mktemp use a prefix to prevent this.
changed the title [-]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` in `asyncio.windows_utils` and `multiprocessing.util`[/-][+]Replace usages of `tempfile.mktemp()` in `asyncio.windows_utils` and `multiprocessing.util`[/+]on Aug 3, 2025
Activity
[-]tempfile. mktemp() is unsafe[/-][+]tempfile.mktemp() is unsafe[/+][-]tempfile.mktemp() is unsafe[/-][+]`tempfile.mktemp()` is unsafe[/+][-]`tempfile.mktemp()` is unsafe[/-][+]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` when possible[/+][-]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` when possible[/-][+]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` in `asyncio.windows_utils`[/+][-]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` in `asyncio.windows_utils`[/-][+]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` in `asyncio.windows_utils` and `multiprocessing.util.arbitrary_address`[/+][-]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` in `asyncio.windows_utils` and `multiprocessing.util.arbitrary_address`[/-][+]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` in `asyncio.windows_utils` and `multiprocessing.util`[/+]picnixz commentedon Aug 3, 2025
I won't consider it a security issue as it remains to show that it's possible to exploit a race condition here. The issue with
mktempis essentially when we have filename collisions, but the occurrences ofmktempuse a prefix to prevent this.[-]Replace usages of `tempfile.mktemp()` with `tempfile.mkstemp` in `asyncio.windows_utils` and `multiprocessing.util`[/-][+]Replace usages of `tempfile.mktemp()` in `asyncio.windows_utils` and `multiprocessing.util`[/+]lighting9999 commentedon Aug 3, 2025
I wrote a POC and found out that it had the possibility of denial of service.
25 remaining items
gh-137335: Fix unlikely name conflicts for named pipes in multiproces…
pythongh-137335: Fix unlikely name conflicts for named pipes in multi…
pythongh-137335: Fix unlikely name conflicts for named pipes in multi…
[3.13] gh-137335: Fix unlikely name conflicts for named pipes in mult…
[3.14] gh-137335: Fix unlikely name conflicts for named pipes in mult…
pythongh-137335: Fix unlikely name conflicts for named pipes in multi…
gh-137335: remove a mktemp use in multiprocessing.connection to avoid…
pythongh-137335: remove a mktemp use in multiprocessing.connection to…
pythongh-137335: remove a mktemp use in multiprocessing.connection to…
[3.14] gh-137335: remove a mktemp use in multiprocessing.connection t…
[3.13] gh-137335: remove a mktemp use in multiprocessing.connection t…
pythongh-137335: Fix unlikely name conflicts for named pipes in multi…
pythongh-137335: remove a mktemp use in multiprocessing.connection to…