Medium severityPythonOther Security ChecksHIGH confidence
Insecure Tempfile Mktemp
tempfile.mktemp() is deprecated and insecure: the returned name can be claimed by an attacker before you open it, creating a race condition (CWE-377).
Standards mapping
- OWASP Top 10
- A01:2021 - Broken Access Control
- OWASP ASVS
- V12.3.1 (L1)
Vulnerable vs. safe
Flagged by this check
return tempfile.mktemp()Passes - the safe pattern
fd, path = tempfile.mkstemp()Why it matters & how to fix it
tempfile.mktemp() is deprecated and insecure: the returned name can be claimed by an attacker before you open it, creating a race condition (CWE-377). Use tempfile.mkstemp() or tempfile.NamedTemporaryFile(), which create the file atomically.
References
Rule ID integsec-python-insecure-tempfile-mktemp - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentestRelated checks
- JavaScript / TypeScript - Other Security ChecksChild Process Shell True
- JavaScript / TypeScript - Other Security ChecksOpen Redirect Tainted Input
- Python - Other Security ChecksDjango Mark Safe
- Python - Other Security ChecksFlask Debug Enabled
- Python - Other Security ChecksFlask Render Template String
- Python - Other Security ChecksJinja2 Autoescape Off