...
A Web browser that failed to check for these devices would allow an attacker to create a website with image tags such as <IMG src="file:///dev/mouse"> that would lock the user's mousemouse [Howard 2002].
Noncompliant Code Example
...
Essentially, an attacker can switch out a file for one of the file types shown in the following table with the specified effect.
File Types and Effects
Type | Note on Effect |
|---|---|
Another regular file | The |
FIFO | Either |
Symbolic link |
|
Special device | Usually the |
To be compliant with this rule and to prevent this TOCTOU race condition, file_name must refer to a file in a secure directory. (See FIO15-C. Ensure that file operations are performed in a secure directory.)
...
Allowing operations that are appropriate only for regular files to be performed on devices can result in denial-of-service attacks or more serious exploits depending on the platform.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
FIO32-C | Medium | Unlikely | Medium | P4 | L3 |
Automated Detection
Tool | Version | Checker | Description |
|---|---|---|---|
| Compass/ROSE |
Could detect some violations of this rule. This rule applies only to untrusted file name strings, and ROSE cannot tell which strings are trusted and which are not. The best heuristic is to note if there is any verification of the file name before or after the |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...
Key here (explains table format and definitions)
Taxonomy | Taxonomy item | Relationship |
|---|---|---|
| CERT C Secure Coding Standard | FIO05-C. Identify files using multiple file attributes | Prior to 2018-01-12: CERT: Unspecified Relationship |
| CERT C Secure Coding Standard | FIO15-C. Ensure that file operations are performed in a secure directory | Prior to 2018-01-12: CERT: Unspecified Relationship |
| CERT C Secure Coding Standard | POS01-C. Check for the existence of links when dealing with files | Prior to 2018-01-12: CERT: Unspecified Relationship |
| CERT C Secure Coding Standard | POS35-C. Avoid race conditions while checking for the existence of a symbolic link | Prior to 2018-01-12: CERT: Unspecified Relationship |
| CERT Oracle Secure Coding Standard for Java | FIO00-J. Do not operate on files in shared directories | Prior to 2018-01-12: CERT: Unspecified Relationship |
CERT-CWE Mapping Notes
Key here for mapping notes
...
- Treating device names (both trusted and untrusted) like regular files in POSIX
Bibliography
| [Garfinkel 1996] | Section 5.6, "Device Files" |
| [Howard 2002] | Chapter 11, "Canonical Representation Issues" |
| [IEEE Std 1003.1:2013] | XSH, System Interfaces, open |
| [MSDN] |
...
...