Skip to content

Insecure Temporary File Creation

Description

The application uses the insecure `mktemp` method to create temporary files, which can lead to unintended files being created or overwritten due to symlinks.

Examples

Insecure Code

python
tempfile.mktemp()

Secure Code

python
with tempfile.TemporaryFile() as fp: fp.write(b'Some data')

Remediation

Use `tempfile.TemporaryFile` instead of `mktemp` to create temporary files.

Rule Details

FieldValue
IDCODE-0170
CategoryInsecureConfig
SeverityMEDIUM
CWECWE-377
ConfidenceHIGH
ImpactMEDIUM
LikelihoodMEDIUM
ExploitabilityMODERATE
Tagstemporary files, symlinks
OWASPA3:2017-Sensitive Data Exposure, A01:2021-Broken Access Control