Insecure string processing function
Description
This function is easy to misuse by not accounting for the space necessary when transforming strings. Ensure that the destination buffer is large enough to fit the transformed output.
Examples
Insecure Code
c
strtrns(dest, src, "abc");Secure Code
c
size_t dest_size = strlen(src) * 2 + 1; char* dest = malloc(dest_size); strtrns(dest, src, "abc");Remediation
Verify that the destination buffer is large enough to fit the transformed output.
Rule Details
| Field | Value |
|---|---|
| ID | CODE-0585 |
| Category | Injection |
| Severity | HIGH |
| CWE | CWE-120 |
| Confidence | HIGH |
| Impact | HIGH |
| Likelihood | MEDIUM |
| Exploitability | EASY |
| Tags | string processing, buffer overflow |
| OWASP | A1:2017-Injection, A03:2021-Injection |