Katalog CWE

CWE-194 · Słabość

Unexpected Sign Extension

Abstrakcja
Wariant
Status
Niekompletny
Ryzyko wykorzystania
wysokie
Dodano
19 lipca 2006
Ostatnia zmiana
11 grudnia 2025

Podatności CVE z tą słabościąPełny wpis na cwe.mitre.org ↗

Opis

The product performs an operation on a number that causes it to be sign extended when it is transformed into a larger data type. When the original number is negative, this can produce unexpected values that lead to resultant weaknesses.

Skutki

  • Integrity, Confidentiality, Availability, Other

    Read Memory; Modify Memory; Other

    When an unexpected sign extension occurs in code that operates directly on memory buffers, such as a size value or a memory index, then it could cause the program to write or read outside the boundaries of the intended buffer. If the numeric value is associated with an application-level resource, such as a quantity or price for a product in an e-commerce site, then the sign extension could produce a value that is much higher (or lower) than the application's allowable range.

Zapobieganie

  • Implementation

    Avoid using signed variables if you don't need to represent negative values. When negative values are needed, perform validation after you save those values to larger data types, or before passing them to functions that are expecting unsigned values.

Przykłady podatności

Słabość nadrzędna

Kiedy powstaje

Dotyczy

C, C++

Uwagi

Sign extension errors can lead to buffer overflows and other memory-based problems. They are also likely to be factors in other weaknesses that are not based on memory operations, but rely on numeric calculation.

This entry is closely associated with signed-to-unsigned conversion errors (CWE-195) and other numeric errors. These relationships need to be more closely examined within CWE.

Źródła

  1. C Language Issues for Application Security — John McDonald, Mark Dowd, Justin Schuh, 2008
  2. Integral Security — Robert Seacord, 2006
  3. The CLASP Application Security Process — Secure Software, Inc., 2005

Wpis z katalogu CWE 4.20.