Skip to content

Insecure Temporary File Creation

Description

Creating and using insecure temporary files can leave application and system data vulnerable to attack. The use of mktemp, tmpnam, and tempnam functions can be exploited by attackers to gain unauthorized access to sensitive data.

Examples

Insecure Code

c
FILE *fp = fopen(tmpnam(NULL), "w");

Secure Code

c
int fd = mkstemp(template); FILE *fp = fdopen(fd, "w");

Remediation

Use secure alternatives such as mkstemp or tmpfile to create temporary files.

Rule Details

FieldValue
IDCODE-0246
CategoryInsecureConfig
SeverityMEDIUM
CWECWE-377
ConfidenceHIGH
ImpactMEDIUM
LikelihoodMEDIUM
ExploitabilityMODERATE
Tagstemporary files, insecure api
OWASPN/A

References