Operation can result in security vulnerabilities or a system failure
This defect occurs when you do not check whether a file name parameter refers to a device file before you pass it to these functions:
fopen()
fopen_s()
freopen()
remove()
rename()
CreateFile()
CreateFileA()
CreateFileW()
_wfopen()
_wfopen_s()
Device files are files in a file system that provide an interface to device drivers. You can use these files to interact with devices.
Inappropriate I/O operation on device files does not raise a defect when:
You use stat or lstat-family functions to
check the file name parameter before calling the previously listed functions.
You use a string comparison function to compare the file name against a list of device file names.
Operations appropriate only for regular files but performed on device files can result in denial-of-service attacks, other security vulnerabilities, or system failures.
Before you perform an I/O operation on a file:
Use stat(), lstat(), or an equivalent
function to check whether the file name parameter refers to a regular file.
Use a string comparison function to compare the file name against a list of device file names.
| Group: Security |
| Language: C | C++ |
| Default: Off |
Command-Line Syntax:
INAPPROPRIATE_IO_ON_DEVICE |
| Impact: Medium |
| CWE ID: 67 |
File access between time of check and use
(TOCTOU) | Find defects (-checkers) | Opening previously opened resource | Resource leak | Returned value of a sensitive function not
checked | Vulnerable path manipulation