CWE-785: Use of Path Manipulation Function without Maximum-sized Buffer

VariantIncomplete

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 MITRE
Back to CWE Lookup

Extended Description

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.

Technical Details

Structure
Simple

Applicable To

Languages
CC++
Platforms

Frequently Asked Questions

What is CWE-785: Use of Path Manipulation Function without Maximum-sized Buffer?+

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.

What are the security consequences of Use of Path Manipulation Function without Maximum-sized Buffer?+

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.

How do you prevent or mitigate Use of Path Manipulation Function without Maximum-sized Buffer?+

Recommended mitigations for CWE-785 include: Always specify output buffers large enough to handle the maximum-size possible result from path manipulation functions.

Which programming languages are affected by Use of Path Manipulation Function without Maximum-sized Buffer?+

CWE-785 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-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.

Learn More