CWE-124: Buffer Underflow
Buffer Underwrite
The product writes to a buffer using an index or pointer that references a memory location prior to the beginning of the buffer.
How it's found
Buffer Underflow is typically found by tracing untrusted input from where it enters the system to the point where it is used without the check or neutralization this weakness describes, combining manual code review with dynamic testing.
Consequences
- Modify Memory, DoS: Crash, Exit, or Restart: Out of bounds memory access will very likely result in the corruption of relevant memory, and perhaps instructions, possibly leading to a crash.
- Execute Unauthorized Code or Commands, Modify Memory, Bypass Protection Mechanism, Other: If the corrupted memory can be effectively controlled, it may be possible to execute arbitrary code. If the corrupted memory is data rather than instructions, the system will continue to function with improper changes, possibly in violation of an implicit or explicit policy. The consequences would only be limited by how the affected data is used, such as an adjacent memory location that is used to specify whether the user has special privileges.
- Bypass Protection Mechanism, Other: When the consequence is arbitrary code execution, this can often be used to subvert any other security service.
Mitigations
- Requirements: Choose a language that is not susceptible to these issues.
- Implementation: All calculated values that are used as index or for pointer arithmetic should be validated to ensure that they are within an expected range.
Where this fits in a TurboPentest engagement
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Frequently asked questions
What is CWE-124?
The product writes to a buffer using an index or pointer that references a memory location prior to the beginning of the buffer.
How do you find Buffer Underflow?
Buffer Underflow is typically found by tracing untrusted input from where it enters the system to the point where it is used without the check or neutralization this weakness describes, combining manual code review with dynamic testing.
What is the impact of CWE-124?
Modify Memory, DoS: Crash, Exit, or Restart: Out of bounds memory access will very likely result in the corruption of relevant memory, and perhaps instructions, possibly leading to a crash. Execute Unauthorized Code or Commands, Modify Memory, Bypass Protection Mechanism, Other: If the corrupted memory can be effectively controlled, it may be possible to execute arbitrary code. If the corrupted memory is data rather than instructions, the system will continue to function with improper changes, possibly in violation of an implicit or explicit policy. The consequences would only be limited by how the affected data is used, such as an adjacent memory location that is used to specify whether the user has special privileges. Bypass Protection Mechanism, Other: When the consequence is arbitrary code execution, this can often be used to subvert any other security service.
Does TurboPentest test for Buffer Underflow?
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Related CWEs
Written and reviewed by
Michel Chamberland - Founder & CEO, IntegSec
CISSP, OSCP, OSCE, CEH, GIAC, CCSK · 20+ years in offensive security
Michel has spent 20+ years on offensive security teams including IBM X-Force Red and Trustwave SpiderLabs, leading penetration tests, red team engagements, and breach response for Fortune 500 customers. He is the founder of IntegSec and the architect of TurboPentest.
Find these issues before an attacker does
TurboPentest runs an agentic AI pentest against your target and reports findings with proof, from $99 per target.
Start a pentest