CWE-135: Incorrect Calculation of Multi-Byte String Length

Base Draft Simple

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

The product does not correctly calculate the length of strings that can contain wide or multi-byte characters.

常见后果

影响范围: Integrity Confidentiality Availability

技术影响: Execute Unauthorized Code or Commands

说明: This weakness may lead to a buffer overflow. Buffer overflows often can be used to execute arbitrary code, which is usually outside the scope of a program's implicit security policy. This can often be used to subvert any other security service.

影响范围: Availability Confidentiality

技术影响: Read Memory DoS: Crash, Exit, or Restart DoS: Resource Consumption (CPU) DoS: Resource Consumption (Memory)

说明: Out of bounds memory access will very likely result in the corruption of relevant memory, and perhaps instructions, possibly leading to a crash. Other attacks leading to lack of availability are possible, including putting the program into an infinite loop.

影响范围: Confidentiality

技术影响: Read Memory

说明: In the case of an out-of-bounds read, the attacker may have access to sensitive information. If the sensitive information contains system details, such as the current buffer's position in memory, this knowledge can be used to craft further attacks, possibly with more severe consequences.

潜在缓解措施

阶段: Implementation

策略: Input Validation

描述: Always verify the length of the string unit character.

阶段: Implementation

策略: Libraries or Frameworks

描述: Use length computing functions (e.g. strlen, wcslen, etc.) appropriately with their equivalent type (e.g.: byte, wchar_t, etc.)

检测方法

方法: 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

引入模式

阶段 说明
Implementation -

适用平台

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

分类映射

分类名称 条目ID 条目名称 映射适配度
CLASP - Improper string length checking -
The CERT Oracle Secure Coding Standard for Java (2011) FIO10-J Ensure the array is filled when using read() to fill an array -
Software Fault Patterns SFP10 Incorrect Buffer Length Computation -
关键信息

CWE ID: CWE-135

抽象级别: Base

结构: Simple

状态: Draft

相关弱点