CWE-130: Improper Handling of Length Parameter Inconsistency (Base)

Description: The product parses a formatted message or structure, but it does not handle or incorrectly handles a length field that is inconsistent with the actual length of the associated data.

Extended Description: If an attacker can manipulate the length parameter associated with an input such that it is inconsistent with the actual length of the input, this can be leveraged to cause the target application to behave in unexpected, and possibly, malicious ways. One of the possible motives for doing so is to pass in arbitrarily large input to the application. Another possible motivation is the modification of application state by including invalid data for subsequent properties of the application. Such weaknesses commonly lead to attacks such as buffer overflows and execution of arbitrary code.


Alternate Terms: ::TERM:length manipulation::TERM:length tampering::

Applicable Platforms: ::LANGUAGE NAME:C:LANGUAGE PREVALENCE:Sometimes::LANGUAGE NAME:C++:LANGUAGE PREVALENCE:Sometimes::LANGUAGE CLASS:Not Language-Specific:LANGUAGE PREVALENCE:Undetermined::

Modes of Introduction: ::PHASE:Implementation::



Common Consequences: ::SCOPE:Confidentiality:SCOPE:Integrity:IMPACT:Read Memory:IMPACT:Modify Memory:IMPACT:Varies by Context::


Potential Mitigations: ::PHASE:Implementation:DESCRIPTION:When processing structured incoming data containing a size field followed by raw data, ensure that you identify and resolve any inconsistencies between the size field and the actual size of the data.::PHASE:Implementation:DESCRIPTION:Do not let the user control the size of the buffer.::PHASE:Implementation:DESCRIPTION:Validate that the length of the user-supplied data is consistent with the buffer size.::

Observed Examples: ::REFERENCE:CVE-2014-0160:DESCRIPTION:Chain: Heartbleed bug receives an inconsistent length parameter (CWE-130) enabling an out-of-bounds read (CWE-126), returning memory that could include private cryptographic keys and other sensitive data.:LINK:https://www.cve.org/CVERecord?id=CVE-2014-0160::REFERENCE:CVE-2009-2299:DESCRIPTION:Web application firewall consumes excessive memory when an HTTP request contains a large Content-Length value but no POST data.:LINK:https://www.cve.org/CVERecord?id=CVE-2009-2299::REFERENCE:CVE-2001-0825:DESCRIPTION:Buffer overflow in internal string handling routine allows remote attackers to execute arbitrary commands via a length argument of zero or less, which disables the length check.:LINK:https://www.cve.org/CVERecord?id=CVE-2001-0825::REFERENCE:CVE-2001-1186:DESCRIPTION:Web server allows remote attackers to cause a denial of service via an HTTP request with a content-length value that is larger than the size of the request, which prevents server from timing out the connection.:LINK:https://www.cve.org/CVERecord?id=CVE-2001-1186::REFERENCE:CVE-2001-0191:DESCRIPTION:Service does not properly check the specified length of a cookie, which allows remote attackers to execute arbitrary commands via a buffer overflow, or brute force authentication by using a short cookie length.:LINK:https://www.cve.org/CVERecord?id=CVE-2001-0191::REFERENCE:CVE-2003-0429:DESCRIPTION:Traffic analyzer allows remote attackers to cause a denial of service and possibly execute arbitrary code via invalid IPv4 or IPv6 prefix lengths, possibly triggering a buffer overflow.:LINK:https://www.cve.org/CVERecord?id=CVE-2003-0429::REFERENCE:CVE-2000-0655:DESCRIPTION:Chat client allows remote attackers to cause a denial of service or execute arbitrary commands via a JPEG image containing a comment with an illegal field length of 1.:LINK:https://www.cve.org/CVERecord?id=CVE-2000-0655::REFERENCE:CVE-2004-0492:DESCRIPTION:Server allows remote attackers to cause a denial of service and possibly execute arbitrary code via a negative Content-Length HTTP header field causing a heap-based buffer overflow.:LINK:https://www.cve.org/CVERecord?id=CVE-2004-0492::REFERENCE:CVE-2004-0201:DESCRIPTION:Help program allows remote attackers to execute arbitrary commands via a heap-based buffer overflow caused by a .CHM file with a large length field:LINK:https://www.cve.org/CVERecord?id=CVE-2004-0201::REFERENCE:CVE-2003-0825:DESCRIPTION:Name services does not properly validate the length of certain packets, which allows attackers to cause a denial of service and possibly execute arbitrary code. Can overlap zero-length issues:LINK:https://www.cve.org/CVERecord?id=CVE-2003-0825::REFERENCE:CVE-2004-0095:DESCRIPTION:Policy manager allows remote attackers to cause a denial of service (memory consumption and crash) and possibly execute arbitrary code via an HTTP POST request with an invalid Content-Length value.:LINK:https://www.cve.org/CVERecord?id=CVE-2004-0095::REFERENCE:CVE-2004-0826:DESCRIPTION:Heap-based buffer overflow in library allows remote attackers to execute arbitrary code via a modified record length field in an SSLv2 client hello message.:LINK:https://www.cve.org/CVERecord?id=CVE-2004-0826::REFERENCE:CVE-2004-0808:DESCRIPTION:When domain logons are enabled, server allows remote attackers to cause a denial of service via a SAM_UAS_CHANGE request with a length value that is larger than the number of structures that are provided.:LINK:https://www.cve.org/CVERecord?id=CVE-2004-0808::REFERENCE:CVE-2002-1357:DESCRIPTION:Multiple SSH2 servers and clients do not properly handle packets or data elements with incorrect length specifiers, which may allow remote attackers to cause a denial of service or possibly execute arbitrary code.:LINK:https://www.cve.org/CVERecord?id=CVE-2002-1357::REFERENCE:CVE-2004-0774:DESCRIPTION:Server allows remote attackers to cause a denial of service (CPU and memory exhaustion) via a POST request with a Content-Length header set to -1.:LINK:https://www.cve.org/CVERecord?id=CVE-2004-0774::REFERENCE:CVE-2004-0989:DESCRIPTION:Multiple buffer overflows in xml library that may allow remote attackers to execute arbitrary code via long URLs.:LINK:https://www.cve.org/CVERecord?id=CVE-2004-0989::REFERENCE:CVE-2004-0568:DESCRIPTION:Application does not properly validate the length of a value that is saved in a session file, which allows remote attackers to execute arbitrary code via a malicious session file (.ht), web site, or Telnet URL contained in an e-mail message, triggering a buffer overflow.:LINK:https://www.cve.org/CVERecord?id=CVE-2004-0568::REFERENCE:CVE-2003-0327:DESCRIPTION:Server allows remote attackers to cause a denial of service via a remote password array with an invalid length, which triggers a heap-based buffer overflow.:LINK:https://www.cve.org/CVERecord?id=CVE-2003-0327::REFERENCE:CVE-2003-0345:DESCRIPTION:Product allows remote attackers to cause a denial of service and possibly execute arbitrary code via an SMB packet that specifies a smaller buffer length than is required.:LINK:https://www.cve.org/CVERecord?id=CVE-2003-0345::REFERENCE:CVE-2004-0430:DESCRIPTION:Server allows remote attackers to execute arbitrary code via a LoginExt packet for a Cleartext Password User Authentication Method (UAM) request with a PathName argument that includes an AFPName type string that is longer than the associated length field.:LINK:https://www.cve.org/CVERecord?id=CVE-2004-0430::REFERENCE:CVE-2005-0064:DESCRIPTION:PDF viewer allows remote attackers to execute arbitrary code via a PDF file with a large /Encrypt /Length keyLength value.:LINK:https://www.cve.org/CVERecord?id=CVE-2005-0064::REFERENCE:CVE-2004-0413:DESCRIPTION:SVN client trusts the length field of SVN protocol URL strings, which allows remote attackers to cause a denial of service and possibly execute arbitrary code via an integer overflow that leads to a heap-based buffer overflow.:LINK:https://www.cve.org/CVERecord?id=CVE-2004-0413::REFERENCE:CVE-2004-0940:DESCRIPTION:Is effectively an accidental double increment of a counter that prevents a length check conditional from exiting a loop.:LINK:https://www.cve.org/CVERecord?id=CVE-2004-0940::REFERENCE:CVE-2002-1235:DESCRIPTION:Length field of a request not verified.:LINK:https://www.cve.org/CVERecord?id=CVE-2002-1235::REFERENCE:CVE-2005-3184:DESCRIPTION:Buffer overflow by modifying a length value.:LINK:https://www.cve.org/CVERecord?id=CVE-2005-3184::



Notes: ::TYPE:Relationship:NOTE:This probably overlaps other categories including zero-length issues.::