...
If not properly performed, checking for the existence of symbolic links can lead to race conditions.
This rule is a specific instance of rule FIO45-C. Avoid TOCTOU race conditions while accessing files.
Noncompliant Code Example
...
TOCTOU race condition vulnerabilities can be exploited to gain elevated privileges.
Rule | Severity | Likelihood | Detectable | Remediation CostRepairable | Priority | Level |
|---|---|---|---|---|---|---|
POS35-C | High | Likelyhigh | likelyNo | mediumNo | P18 P9 | L1 L2 |
Automated Detection
Tool | Version | Checker | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Astrée |
| user_defined | Soundly supported | ||||||||||
| Axivion Bauhaus Suite |
| CertC-POS35 | |||||||||||
| Compass/ROSE | Can detect some violations of this rule. In particular, it ensures that calls to | ||||||||||||
| Coverity |
| TOCTOU | Implemented | ||||||||||
| Helix QAC |
| DF4886, DF4887, DF4888 | |||||||||||
| Klocwork |
| SV.TOCTOU.FILE_ACCESS | |||||||||||
| Parasoft C/C++test |
| CERT_C-POS35-a CERT_C-POS35-b | Usage of functions prone to race is not allowedAvoid race conditions while checking for the existence of a symbolic link | ||||||||||
| Polyspace Bug Finder |
| CERT C: Rule POS35-C | Checks for file access between time of check and use (TOCTOU) (rule fully covered) |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...
| [Dowd 2006] | Chapter 9, "UNIX 1: Privileges and Files" |
| [ISO/IEC 9899:20112024] | Section 7.2123, "Input/output <stdio.h>" |
| [Open Group 2004] | lstat() fstat() open() |
| [Seacord 2013] | Chapter 8, "File I/O" |
...