Forty Defects in Seven NETCONF Implementations: the Chunked Framing Layer

We tested seven NETCONF implementations and uncovered 40 defects. The chunk framing that sits between the transport and the XML parser accounts for most of them, in every implementation tested, and the size it declares is narrowed to a signed 32-bit integer in four of the seven.

NETCONF configures routers, switches and the management planes of network operating systems, and it carries XML over a byte stream that has no message boundaries of its own.

The protocol supplies those boundaries itself. The older base version ends each message with a fixed delimiter sequence; the current one prefixes every chunk with a declared size, written in decimal between two markers. Between the transport and the XML parser, therefore, sits a small amount of hand-written code that reads a number and then trusts it.

We tested seven implementations and uncovered 40 defects. They cover servers, client libraries, an SDN controller's management plugin and a network operating system's configuration daemon.

Every one of the seven has at least one defect in that framing layer, and in four of them the declared chunk size is narrowed to a signed 32-bit integer somewhere between being parsed and being used.

Integer truncation of the declared chunk size

Product A accumulates the chunk size into a 32-bit signed integer with no range check at all, so a size large enough to wrap arrives at the allocation as a value the code never tested for.

Product D has the same defect twice, once in each base version. The current version's chunk size is truncated past the width it is parsed into, and the older version's framing has no size cap and additionally narrows the length to a signed integer.

Product B sends its chunk countdown through a signed integer on the way to being decremented, with the same effect.

Product E is the plainest case. An unbounded chunk-size header forces an allocation of several gigabytes immediately, before any of the message body has arrived.

The common structure is that the size is validated, if at all, against the protocol's stated maximum rather than against the type that will hold it or the memory that will be reserved.

No cap on total message size

Chunk framing bounds each chunk. It does not bound the number of chunks, and four of the seven never apply a total.

Product B has no message-size cap anywhere. Product E caps nothing in either of its two framing readers. Product F bounds each chunk correctly and never bounds the message, so a client that sends conformant chunks indefinitely grows the server's buffer without ever sending anything malformed.

Product G does apply a cap, at 64 KiB, and the session then dies without a diagnostic on either side.

This is the defect class that a protocol-conformant client can reach. Nothing about the traffic is wrong; there is simply more of it than the receiver has anywhere to put.

Framing desynchronisation from a marker inside the content

Two implementations re-cut the stream on a marker sequence that appears in a message's own payload.

Product B desynchronises its server-side framing state when the chunk-end sequence appears in the data. Product G has the same defect, and in its case the sequence is carried inside the content the client supplied, so the client chooses where the server believes the message ends.

The result is a stream the two ends have cut differently. What follows is read as a frame header by one party and as content by the other, which is the condition that makes everything after it attacker-positioned.

Product G also never consumes the chunk header on multi-chunk messages, so a message arriving in more than one chunk is corrupted by construction, and answers a single request with two reply frames, the second of them not legal under the framing it claims.

The client-side readers

Three of the seven are client libraries, and they parse what a server sends with less care than the servers parse requests.

Product B's client reader returns a fragment as though it were a whole reply, concatenates chunked frames that should have stayed separate, and discards a reply that happened to share a read with another one.

Product C discards whatever followed the end-of-message delimiter in the same read, and drops a partial tail in a way that ends an active subscription while reporting success to the caller.

Product E has a node-filtering branch that is missing the null checks its sibling branch performs.

A NETCONF client is a management station or an orchestrator, and it is connected to the devices it manages. A defect reached by a server's reply is reached by any device on the managed estate.

The authentication boundary, and what sits in front of it

NETCONF runs over SSH, which means most of the surface above is behind authentication, and the honest reading of these 40 defects is that they are reachable by an authenticated but unprivileged user, or by a management station or device that has been taken over.

Product G's leaked SSH client per login is the one finding in this set that fires before authentication completes.

Two others do not need a credential for a different reason. Product A runs every message it receives through a DOM parser with no external-entity hardening, and Product G puts request-supplied text into replies unescaped, and then partly un-escapes reply data on the way out. Both are defects in handling what the other end sent, so on a client they are reached by the server, which is the party a client has no control over.

Product F has two findings that are unreachable in the stock build and are recorded as such.

Finding these with Penzzer

NETCONF has a protocol-aware target for a server and for a client. Select Network Configuration Protocol (NETCONF) to drive a server, or Network Configuration Protocol Server (NETCONF) to listen and have a client under test connect, which is how the three client libraries above are reached.

| Attack module | What it drives | | --- | --- | | Message framing abuse | The chunk header and the end-of-message delimiter: declared sizes against what arrives, markers inside content, chunk counts against any total, and both base versions negotiated against each other |

‍

A run also generates its cases from the protocol's own structure, walking the chunk header, the capability exchange and the RPC envelope through the boundaries where readers break. The framing layer is a good illustration of why that matters: the defects above are not in the XML, they are in the decimal number in front of it, and the field that carries it has three interesting values and one wrong type.

Because the transport is SSH, a campaign against a server is run with a credential, and the result to watch for is not only a crash but a session that ends without a diagnostic, a reply that does not parse, and a stream the two ends have cut in different places.

What this article is, and is not

The 40 defects above are a sample of what this kind of testing surfaces, not a description of Penzzer's NETCONF coverage. They are what seven specific implementations happened to get wrong.

The attack library spans defect classes well beyond what this article shows: memory safety, information disclosure, resource exhaustion, availability, hangs and algorithmic complexity, input validation, protocol state logic, type and format handling, and error handling. Across the 106 protocols with a protocol-aware target, a run also generates its test cases from the structure of the protocol itself.

The same limit applies in reverse. What a test looks for is a property of the test, not a claim about your device.

If your product speaks NETCONF

Three questions about the framing, which is where the evidence here points.

Does the declared chunk size stay in the type it was parsed into all the way to the allocation, rather than being narrowed on the way? Is there a cap on the total message as well as on each chunk, and does exceeding it produce a diagnostic rather than a silent close? And can the framing markers appear in a message's own content without changing where the receiver believes the message ends?

The fourth question is about direction. Your client parses replies from every device you manage, and on the evidence here the client readers are the weaker half.

Other Post
Uncover Hidden Vulnerabilities

Identify security flaws before attackers do, automatically and at scale with Penzzer's intelligent fuzzing engine.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.