---
title: "CWE-130: Improper Handling of Length Parameter Inconsistency"
url: https://radicalnotion.ai/cwe/cwe-130
type: cwe
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."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-130: Improper Handling of Length Parameter Inconsistency

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 155
- **Of those, in CISA KEV:** 1
- **New in 2026:** 79
- **CWE catalog version:** 4.21

## 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.

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

- length manipulation
- length tampering

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Applicable platforms

**Languages:** C (Sometimes), C++ (Sometimes)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality, Integrity | Read Memory, Modify Memory, Varies by Context | - |

## Potential mitigations

### Implementation

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.

### Implementation

Do not let the user control the size of the buffer.

### Implementation

Validate that the length of the user-supplied data is consistent with the buffer size.

## Detection methods

### Automated Static Analysis

Automated 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.)

Effectiveness: High

## Demonstrative examples

### Example 1

In the following C/C++ example, the method processMessageFromSocket() will get a message from a socket, save the message into a buffer, and place the contents of the buffer into a structure that contains the message length and the message body. Then a for loop is used to copy the message body into a local character string, which will be passed to another method for processing.

Bad code:

```c
int processMessageFromSocket(int socket) {
    // initialize variable to represent the failure case by default
    int success = -1;
    char buffer[BUFFER_SIZE];
    char message[MESSAGE_SIZE];

    // get message from socket and store into buffer
    // for clarity of this example, ignore the possibility that buffer > BUFFER_SIZE
    if (getMessage(socket, buffer, BUFFER_SIZE) > 0) {

        // place contents of the buffer into message structure
        ExMessage *msg = recastBuffer(buffer);

        // copy message body into string for processing
        int index;
        for (index = 0; index < msg->msgLength; index++) {
            message[index] = msg->msgBody[index];
        }
        message[index] = '\0';
        // process message
        success = processMessage(message);
    }
    return success;
}
```

However, the message length variable (msgLength) from the structure is used as the condition for ending the for loop without validating that msgLength accurately reflects the actual length of the message body (CWE-606). If msgLength indicates a length that is longer than the size of a message body (CWE-130), then this can result in a buffer over-read by reading past the end of the buffer (CWE-126).

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2014-0160 | 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. |
| CVE-2009-2299 | Web application firewall consumes excessive memory when an HTTP request contains a large Content-Length value but no POST data. |
| CVE-2001-0825 | 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. |
| CVE-2001-1186 | 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. |
| CVE-2001-0191 | 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. |
| CVE-2003-0429 | 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. |
| CVE-2000-0655 | 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. |
| CVE-2004-0492 | 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. |
| CVE-2004-0201 | 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 |
| CVE-2003-0825 | Name service 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 |
| CVE-2004-0095 | 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. |
| CVE-2004-0826 | 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. |
| CVE-2004-0808 | 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. |
| CVE-2002-1357 | 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. |
| CVE-2004-0774 | 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. |
| CVE-2004-0989 | Multiple buffer overflows in xml library that may allow remote attackers to execute arbitrary code via long URLs. |
| CVE-2004-0568 | 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. |
| CVE-2003-0327 | 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. |
| CVE-2003-0345 | 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. |
| CVE-2004-0430 | 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. |
| CVE-2005-0064 | PDF viewer allows remote attackers to execute arbitrary code via a PDF file with a large /Encrypt /Length keyLength value. |
| CVE-2004-0413 | 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. |
| CVE-2004-0940 | Is effectively an accidental double increment of a counter that prevents a length check conditional from exiting a loop. |
| CVE-2002-1235 | Length field of a request not verified. |
| CVE-2005-3184 | Buffer overflow by modifying a length value. |

## Real CVEs with this weakness (sample of 12 of 155)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2025-14847 | Zlib compressed protocol header length confusion may allow memory read | high | 8.7 | - | Yes | 2025-12-19 |
| CVE-2026-109390 | - | critical | 9.8 | - | No | 2026-10-12 |
| CVE-2026-89613 | ntfs: reject invalid empty mapping pairs | critical | 9.8 | - | No | 2026-09-11 |
| CVE-2026-72211 | ntfs: grow index root value before reparent header update | critical | 9.8 | - | No | 2026-08-15 |
| CVE-2022-2714 | Improper Handling of Length Parameter Inconsistency in francoisjacquet/rosariosis | critical | 9.8 | - | No | 2022-09-06 |
| CVE-2021-38445 | OCI OpenDDS Secure Improper Handling of Length Parameter Inconsistency | critical | 9.8 | - | No | 2022-05-05 |
| CVE-2021-20588 | Improper Handling of Length Parameter Inconsistency in Mitsubishi Electric FA Engineering Software Products | critical | 9.8 | - | No | 2021-02-19 |
| CVE-2026-67292 | FreeRDP before 3.29.0 WebSocket Ping Buffer Over-disclosure | critical | 9.3 | - | No | 2026-08-01 |
| CVE-2026-31635 | rxrpc: fix oversized RESPONSE authenticator length check | critical | 9.3 | - | No | 2026-04-24 |
| CVE-2023-5778 | Missing Length Check | critical | 9.2 | - | No | 2026-09-18 |
| CVE-2026-54466 | websocket-driver: Message corruption via abuse of protocol length headers | critical | 9.2 | - | No | 2026-07-17 |
| CVE-2026-9054 | Invalid IP packets cause a kernel panic | critical | 9.2 | - | No | 2026-05-22 |

## Related attack patterns (CAPEC)

- [CAPEC-47](https://radicalnotion.ai/capec/capec-47): Buffer Overflow via Parameter Expansion

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-119](https://radicalnotion.ai/cwe/cwe-119) | Improper Restriction of Operations within the Bounds of a Memory Buffer |
| Parent | [CWE-240](https://radicalnotion.ai/cwe/cwe-240) | Improper Handling of Inconsistent Structural Elements |
| Can precede | [CWE-805](https://radicalnotion.ai/cwe/cwe-805) | Buffer Access with Incorrect Length Value |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Length Parameter Inconsistency | - | - |
| Software Fault Patterns | Tainted Input to Command | SFP24 | - |

## Frequently asked questions

### What is CWE-130?

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.

### What CVEs are caused by CWE-130?

155 recorded CVEs are attributed to CWE-130, including CVE-2025-14847, CVE-2026-109390 and CVE-2026-89613. 1 is listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.

### How do you prevent CWE-130?

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.

### How is CWE-130 detected?

Automated Static Analysis: Automated 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.)

### What are the consequences of CWE-130?

Exploiting CWE-130 can lead to: Read Memory, Modify Memory, Varies by Context.

### Is CWE-130 actively exploited?

Yes. 1 CWE-130 vulnerability is in CISA's KEV catalog of actively exploited flaws, out of 155 recorded CVEs.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/130.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-130). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
