Description
In C and C++, one may often accidentally refer to the wrong memory due to the semantics of when math operations are implicitly scaled.
Potential Impact
Confidentiality, Integrity
Read Memory, Modify Memory
Demonstrative Examples
int *p = x;char * second_char = (char *)(p + 1);Mitigations & Prevention
Use a platform with high-level memory abstractions.
Always use array indexing instead of direct pointer manipulation.
Use technologies for preventing buffer overflows.
Detection Methods
- Automated Static Analysis High — Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then sea
Related Weaknesses
Taxonomy Mappings
- CLASP: — Unintentional pointer scaling
- CERT C Secure Coding: ARR39-C — Do not add or subtract a scaled integer to a pointer
- CERT C Secure Coding: EXP08-C — Ensure pointer arithmetic is used correctly
- Software Fault Patterns: SFP1 — Glitch in computation
Frequently Asked Questions
What is CWE-468?
CWE-468 (Incorrect Pointer Scaling) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. In C and C++, one may often accidentally refer to the wrong memory due to the semantics of when math operations are implicitly scaled.
How can CWE-468 be exploited?
Attackers can exploit CWE-468 (Incorrect Pointer Scaling) to read memory, modify memory. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-468?
Key mitigations include: Use a platform with high-level memory abstractions.
What is the severity of CWE-468?
CWE-468 is classified as a Base-level weakness (Medium abstraction). Its actual severity depends on the specific context and how the weakness manifests in your application.