Stack-based buffer overflow
Description
The software directly writes into a stack buffer, which might lead to a stack-based buffer overflow. This can cause the program to crash or potentially allow an attacker to execute arbitrary code.
Examples
Insecure Code
c
char buf[10]; strcpy(buf, "hello world");Secure Code
c
char buf[20]; strncpy(buf, "hello world", 19); buf[19] = '\0';Remediation
Use secure functions like snprintf or strcpy_s instead of strcpy, and ensure that the destination buffer is large enough to hold the copied string.
Rule Details
| Field | Value |
|---|---|
| ID | CODE-0098 |
| Category | Injection |
| Severity | CRITICAL |
| CWE | CWE-121 |
| Confidence | MEDIUM |
| Impact | HIGH |
| Likelihood | MEDIUM |
| Exploitability | EASY |
| Tags | buffer overflow, stack-based |
| OWASP | N/A |