Insecure use of gets() function
Description
The gets() function is always unsafe because it does not perform bounds checking on the size of its input. An attacker can easily send arbitrarily-sized input to gets() and overflow the destination buffer.
Examples
Insecure Code
c
char buffer[10]; gets(buffer);Secure Code
c
char buffer[10]; fgets(buffer, 10, stdin);Remediation
Replace gets() with fgets() to perform bounds checking on input size
Rule Details
| Field | Value |
|---|---|
| ID | CODE-0280 |
| Category | Injection |
| Severity | CRITICAL |
| CWE | CWE-120 |
| Confidence | HIGH |
| Impact | HIGH |
| Likelihood | HIGH |
| Exploitability | EASY |
| Tags | buffer overflow, input validation |
| OWASP | N/A |