CWE-469 · Słabość
Use of Pointer Subtraction to Determine Size
- Abstrakcja
- Bazowa
- Status
- Szkic
- Ryzyko wykorzystania
- średnie
- Dodano
- 19 lipca 2006
- Ostatnia zmiana
- 11 grudnia 2025
Opis
The product subtracts one pointer from another in order to determine size, but this calculation can be incorrect if the pointers do not exist in the same memory chunk.
Skutki
Access Control, Integrity, Confidentiality, Availability
Modify Memory; Read Memory; Execute Unauthorized Code or Commands; Gain Privileges or Assume Identity
There is the potential for arbitrary code execution with privileges of the vulnerable program.
Zapobieganie
Implementation
Save an index variable. This is the recommended solution. Rather than subtract pointers from one another, use an index variable of the same size as the pointers in question. Use this variable to "walk" from one pointer to the other and calculate the difference. Always validate this number.
Słabość nadrzędna
Kiedy powstaje
- Implementation
Dotyczy
C, C++
Źródła
- The CLASP Application Security Process — Secure Software, Inc., 2005
Wpis z katalogu CWE 4.20.