Use of non-secure temporary
file (NON_SECURE_TEMP_FILE)
R2026bTemporary 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 |
PQL Name:
std.defects.NON_SECURE_TEMP_FILE
|
Version History
Introduced in R2015b
See Also
Data race (DATA_RACE) | Find defects (-checkers)
Topics
- Interpret Polyspace Bug Finder Results in Polyspace Platform User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Polyspace Results Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)