Skip to content

Buffer Overflow via Uncontrolled Format String

Description

A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. This can occur when using uncontrolled format strings with scanf functions.

Examples

Insecure Code

c
scanf("%s", input);

Secure Code

c
scanf("%10s", input);

Remediation

Use controlled format strings and limit the input length to prevent buffer overflows.

Rule Details

FieldValue
IDCODE-0621
CategoryInjection
SeverityCRITICAL
CWECWE-120
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityEASY
Tagsbuffer overflow, format string
OWASPN/A

References