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

BaseDraft

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

View on MITRE
Back to CWE Lookup

Technical Details

Structure
Simple

Applicable To

Languages
CC++
Platforms

Frequently Asked Questions

What is CWE-135: Incorrect Calculation of Multi-Byte String Length?+

CWE-135: Incorrect Calculation of Multi-Byte String Length is a Common Weakness Enumeration (CWE) entry maintained by MITRE. The product does not correctly calculate the length of strings that can contain wide or multi-byte characters.

What are the security consequences of Incorrect Calculation of Multi-Byte String Length?+

If exploited, CWE-135 (Incorrect Calculation of Multi-Byte String Length) it can compromise Integrity, Confidentiality and Availability, leading to outcomes such as Execute Unauthorized Code or Commands, Read Memory, DoS: Crash, Exit, or Restart, DoS: Resource Consumption (CPU) and DoS: Resource Consumption (Memory).

How do you prevent or mitigate Incorrect Calculation of Multi-Byte String Length?+

Recommended mitigations for CWE-135 include: Always verify the length of the string unit character. Use length computing functions (e.g. strlen, wcslen, etc.) appropriately with their equivalent type (e.g.: byte, wchar_t, etc.)

Which programming languages are affected by Incorrect Calculation of Multi-Byte String Length?+

CWE-135 commonly affects C and C++. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.

What is the difference between a CWE and a CVE?+

A CWE (Common Weakness Enumeration) like CWE-135 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.

Learn More