CWE-130: Improper Handling of Length Parameter Inconsistency

What is CWE-130?

CWE-130 is Improper Handling of Length Parameter Inconsistency. The flaw arises when 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. The database currently holds 39 vulnerabilities mapped to CWE-130 and 1 of them are in the CISA Known Exploited Vulnerabilities catalog.

Analyzing data...

OWASP Top 10 Rank-
Related CVES (365 days)39
AbstractionBase
Likelihood of exploit-

Vulnerabilities mapped to CWE-130

39 vulnerabilities1850% increase year over year

Vulnerabilities in CISA KEV for CWE-130

1 vulnerabilities

Official definition

ByMitre CWE

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.

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.

Characteristics

Alternate terms

  • length manipulation
  • length tampering

Modes of introduction

  • Implementation

Common consequences

ImpactScopeExplanation
Read Memory, Modify Memory, Varies by ContextConfidentiality, Integrity-

Risk mitigations

  1. ImplementationWhen 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.
  2. ImplementationDo not let the user control the size of the buffer.
  3. ImplementationValidate that the length of the user-supplied data is consistent with the buffer size.

Detection methods

MethodApproachEffectiveness
Automated Static AnalysisAutomated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)High

Representative vulnerabilities

Below are representative vulnerabilities related to this CWE, prioritized by severity.

Sources (2)

CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.

Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.