This vulnerability occurs when software incorrectly measures the length of strings containing multi-byte or wide characters, leading to buffer overflows, data corruption, or crashes.
Many programming languages and systems use multi-byte character encodings (like UTF-8) or wide characters (like UTF-16) where a single logical character can be made of multiple bytes. Standard string length functions (like strlen in C) often count bytes, not characters, which creates a mismatch. When security checks or memory allocations rely on this incorrect count, buffers can be overrun or under-read, creating a critical entry point for attacks. Developers encounter this when handling international text, file paths, or user input without using encoding-aware functions. To prevent it, always use dedicated library functions designed for your specific character encoding (like mbstowcs or wcslen for wide strings) and validate that memory operations account for the maximum possible bytes per character, not just the count of logical units.
Impact: 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.
Impact: Read MemoryDoS: Crash, Exit, or RestartDoS: 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.
Impact: 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.
Strategy: Input Validation
Strategy: Libraries or Frameworks
cbash