The product does not correctly calculate the length of strings that can contain wide or multi-byte characters.
View on MITREThis 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.
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.
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.
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.)
No detection method information available for this CWE.
The following example would be exploitable if any of the commented incorrect malloc calls were used.
The output from the printf() statement would be:
No relationship information available for this CWE.
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.
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).
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.)
CWE-135 commonly affects C and C++. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.
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.