CWE-195: Signed to Unsigned Conversion Error

Variant Draft Simple

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

The product uses a signed primitive and performs a cast to an unsigned primitive, which can produce an unexpected value if the value of the signed primitive can not be represented using an unsigned primitive.

常见后果

影响范围: Integrity

技术影响: Unexpected State

说明: Conversion between signed and unsigned values can lead to a variety of errors, but from a security standpoint is most commonly associated with integer overflow and buffer overflow vulnerabilities.

检测方法

方法: Automated Static Analysis

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 searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

有效性: High

观察示例

参考: CVE-2025-27363

Font rendering library does not properly handle assigning a signed short value to an unsigned long (CWE-195), leading to an integer wraparound (CWE-190), causing too small of a buffer (CWE-131), leading to an out-of-bounds write (CWE-787).

参考: CVE-2007-4268

Chain: integer signedness error (CWE-195) passes signed comparison, leading to heap overflow (CWE-122)

引入模式

阶段 说明
Implementation -

适用平台

编程语言
C (Undetermined) C++ (Undetermined)

分类映射

分类名称 条目ID 条目名称 映射适配度
CLASP - Signed to unsigned conversion error -
Software Fault Patterns SFP1 Glitch in computation -
CERT C Secure Coding INT31-C Ensure that integer conversions do not result in lost or misinterpreted data CWE More Specific
关键信息

CWE ID: CWE-195

抽象级别: Variant

结构: Simple

状态: Draft

相关弱点