The product invokes a function for normalizing paths or file names, but it provides an output buffer that is smaller than the maximum possible size, such as PATH_MAX.
View on MITREPassing an inadequately-sized output buffer to a path manipulation function can result in a buffer overflow. Such functions include realpath(), readlink(), PathAppend(), and others.
Always specify output buffers large enough to handle the maximum-size possible result from path manipulation functions.
No detection method information available for this CWE.
In this example the function creates a directory named "output\<name>" in the current directory and returns a heap-allocated copy of its name.
For most values of the current directory and the name parameter, this function will work properly. However, if the name parameter is particularly long, then the second call to PathAppend() could overflow the outputDirectoryName buffer, which is smaller than MAX_PATH bytes.
CWE-785: Use of Path Manipulation Function without Maximum-sized Buffer is a Common Weakness Enumeration (CWE) entry maintained by MITRE. The product invokes a function for normalizing paths or file names, but it provides an output buffer that is smaller than the maximum possible size, such as PATH_MAX. Passing an inadequately-sized output buffer to a path manipulation function can result in a buffer overflow. Such functions include realpath(), readlink(), PathAppend(), and others.
If exploited, CWE-785 (Use of Path Manipulation Function without Maximum-sized Buffer) it can compromise Integrity, Confidentiality and Availability, leading to outcomes such as Modify Memory, Execute Unauthorized Code or Commands and DoS: Crash, Exit, or Restart.
Recommended mitigations for CWE-785 include: Always specify output buffers large enough to handle the maximum-size possible result from path manipulation functions.
CWE-785 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-785 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.