Use of non-secure temporary file
Temporary generated file name not secure
Description
This defect occurs when you use temporary file routines that are not secure.
Risk
If an attacker guesses the file name generated by a standard temporary file routine, the attacker can:
Cause a race condition when you generate the file name.
Precreate a file of the same name, filled with malicious content. If your program reads the file, the attacker’s file can inject the malicious code.
Create a symbolic link to a file storing sensitive data. When your program writes to the temporary file, the sensitive data is deleted.
Fix
To create temporary files, use a more secure
standard temporary file routine, such as mkstemp
from
POSIX.1-2001.
Also, when creating temporary files with routines that allow
flags, such as mkostemp
, use the exclusion flag O_EXCL
to
avoid race conditions.
Examples
Result Information
Group: Security |
Language: C | C++ |
Default: Off |
Command-Line Syntax: NON_SECURE_TEMP_FILE |
Impact: High |
Version History
Introduced in R2015b
See Also
Data race
| Find defects (-checkers)
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)