CWE-135: Incorrect Calculation of Multi-Byte String Length
The product does not correctly calculate the length of strings that can contain wide or multi-byte characters.
Last updated
Overview
CWE-135 (Incorrect Calculation of Multi-Byte String Length) is a base-level software weakness catalogued by MITRE in the Common Weakness Enumeration (CWE). It describes a recurring type of mistake that can lead to exploitable security vulnerabilities.
Real-world CVEs
1 recorded CVEs are caused by CWE-135 (Incorrect Calculation of Multi-Byte String Length). The highest-severity and most recent are shown first. 1 new CWE-135 CVE has been recorded so far in 2026.
Common consequences
What can happen when CWE-135 is exploited.
Execute Unauthorized Code or Commands
Affects: Integrity, Confidentiality, Availability
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.
Read Memory, DoS: Crash, Exit, or Restart, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory)
Affects: Availability, Confidentiality
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.
Read Memory
Affects: Confidentiality
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.
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
Applies to
Languages
How to prevent it
Practical mitigations for CWE-135, grouped by where in the lifecycle they apply.
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.)
How to detect it
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.)
Effectiveness: High
Code examples
Illustrative examples from MITRE showing how the weakness appears in code.
The following example would be exploitable if any of the commented incorrect malloc calls were used.
Vulnerable example
#include <stdio.h>Resulting query
Strlen() output: 0The output from the printf() statement would be:
Terminology & mappings
Mapped taxonomies
- CLASP: Improper string length checking
- The CERT Oracle Secure Coding Standard for Java (2011): Ensure the array is filled when using read() to fill an array (FIO10-J)
- Software Fault Patterns: Incorrect Buffer Length Computation (SFP10)
Frequently asked questions
Common questions about CWE-135.
- What is CWE-135?
- The product does not correctly calculate the length of strings that can contain wide or multi-byte characters.
- What CVEs are caused by CWE-135?
- 1 recorded CVEs are attributed to CWE-135, including CVE-2026-0810.
- How do you prevent CWE-135?
- Always verify the length of the string unit character.
- How is CWE-135 detected?
- 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.)
- What are the consequences of CWE-135?
- Exploiting CWE-135 can lead to: Execute Unauthorized Code or Commands, Read Memory, DoS: Crash, Exit, or Restart, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory).
- Is CWE-135 actively exploited?
- 1 recorded CVEs are caused by CWE-135; none are currently in CISA's KEV catalog of actively exploited flaws.
References
- MITRE CWE definition (CWE-135) (opens in a new tab)
- CWE-135 vulnerabilities on NVD (opens in a new tab)
- Learn: What is a CWE?
Weakness data is sourced from the MITRE CWE catalog (v4.20). CVE associations are aggregated and kept current by RadicalNotion.AI.
Stay ahead of CWE-135
Get alerted the moment a new CWE-135 vulnerability affects your stack, with AI-written analysis, severity context, and remediation guidance.