Skip to content

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

FieldValue
IDCODE-0585
CategoryInjection
SeverityHIGH
CWECWE-120
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityEASY
Tagsstring processing, buffer overflow
OWASPA1:2017-Injection, A03:2021-Injection