Project

General

Profile

Actions

Security #9188

closed
JI JI

nfsv3/tcp: partial WRITE with count 0 desynchronizes the parser

Security #9188: nfsv3/tcp: partial WRITE with count 0 desynchronizes the parser

Added by Jason Ish about 2 months ago. Updated 7 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Affected Versions:
Label:
CVE:
Git IDs:

fd7acaae9433279e6dae1779140e2c0835b27afc

Severity:
LOW
Disclosure Date:
01/07/2027

Description

Summary

On default NFSv3 over TCP, a WRITE record whose fragment is larger than the bytes in hand and whose count is 0 is handled on the partial-record fast path and then discarded with an early return. That return does not create a chunk promise and does not set_skip to the record boundary. The current segment is reported as fully consumed, so the next segment is parsed as a fresh RPC header. The bytes are not a header, the parser returns a hard error, and Suricata disables application-layer inspection for that flow. A later NFSv3 REMOVE that alerts on an intact flow produces no alert, even though the continuation reached the bridge and the peer. The process stays up. Unpack the attachment and run ./verify.sh.

Affected Versions

Confirmed on jasonish/suricata:latest, which reports Suricata 8.0.7 RELEASE, with the image default. NFS TCP detection and parsing are enabled, and the registered port is 2049. The default max-write-size (16 MiB) does not cover this case, because the count 0 return happens before that check. The same early return exists for an NFSv3 READ reply with count 0. This run triggers the WRITE path.

Preconditions

The sensor must see the TCP connection. No NFS credential is required. AUTH_NULL is enough for protocol detection and for the WRITE fast path. The flow has to be identified as NFS first, which a normal NULL procedure does. The WRITE record must span TCP segments. The first segment must be long enough to parse the WRITE header (at least 44 bytes, and in this case the 76-byte header) while remaining shorter than the record. The record size must be at least 512 bytes and the procedure must be WRITE, which is the gate for the partial fast path. count must be 0, which forces file_len to 0.

Security Impact

Application-layer inspection of that flow stops. Rules that match a later NFS transaction, here nfs_procedure 12 (REMOVE), do not fire. Other flows are unaffected, and the process does not crash. Payload bytes still cross the bridge. This is a detection bypass for the blinded flow, not code execution and not a crash. The to-client READ twin was not exercised as its own run.

Vulnerable Code

rust/src/nfs/nfs.rs, WRITE early return, before any chunk state or skip:

if w.count == 0 {
return 0;
}

The partial fast path treats that success as consuming the whole input:

if rec_size >= 512 && cur_i.len() >= 44 {
if phdr.procedure == NFSPROC3_WRITE {
match parse_nfs3_request_write(hdr.prog_data, false) {
Ok((_, ref w)) => {
self.process_partial_write_request_record(flow, hdr, w);
return AppLayerResult::ok();
}

process_partial_write_request_record only inserts an xid map and calls process_write_record. On a complete record the caller still advances by rec_size, so count 0 is harmless there. On a partial record AppLayerResult::ok() consumes only the bytes already delivered. The fragment tail is neither file data nor skipped. The next call starts at parse_rpc_request_partial, fails the header, and returns AppLayerResult::err(). The C parser then calls StreamTcpDisableAppLayer for the flow. The READ reply has the same early return when reply.count 0, and the partial READ path returns AppLayerResult::ok() the same way.

Call Chain

parse_tcp_data_ts (rust/src/nfs/nfs.rs, record loop) -> parse_tcp_partial_data_ts when rec_size exceeds the input -> WRITE fast path at the rec_size >= 512 and cur_i.len() >= 44 gate -> parse_nfs3_request_write -> process_partial_write_request_record -> process_write_record count 0 return -> AppLayerResult::ok() -> next segment parse_rpc_request_partial error -> AppLayerResult::err() -> StreamTcpDisableAppLayer in src/app-layer-parser.c.

Payload

Three RPC records on one TCP connection to port 2049, AUTH_NULL, NFSv3. A 44-byte NULL procedure identifies the flow. Then a 512-byte last-fragment WRITE (procedure 7) whose header is 76 bytes, stable 1, and count/file_len 0, with 436 trailing fragment bytes that are not a valid RPC header. Then a 76-byte REMOVE (procedure 12) whose name is NFSC0_CANARY_HIT. The attack delivers NULL, waits, delivers only the 76-byte WRITE header, waits, then delivers the 436-byte tail plus the REMOVE. The non-split control sends the same bytes with the WRITE and REMOVE in one segment. The other control uses the same split but sets count and file_len to 436 so the tail is a chunk and the REMOVE stays aligned.

Reproduction

Image jasonish/suricata:latest (8.0.7 RELEASE) sniffs bridge br-nfsc0 on 172.31.7.0/24. The peer listens at 172.31.7.10:2049. Host networking is required so the sensor can see the bridge. -k none is there because bridge capture shows offloaded checksums. NFS settings are the image default.

./verify.sh
nonsplit_null=1
nonsplit_remove=1
count_null=1
count_remove=1
attack_null=1
attack_remove=0
attack_payload_pkts=3
attack_parser_error=True
attack_marker_later=True
attack_sink_marker=True
suricata_running=true
VERDICT: PASS

fast.log shows signature 9901701 and 9901702 on both controls, and only 9901701 on the attack flow. The attack flow also logs an NFS malformed_data anomaly. The bridge capture has three payload segments toward port 2049 (44, 76, 512) and the marker is in the third. The sink accepted all 632 bytes.

Fix Recommendation

On the TCP count 0 return in process_write_record, skip the unread tail of the RPC record before returning. pending = prog_data_size - prog_data.len() is 0 for a complete record, so the caller that advances by rec_size does not skip twice. For a partial record pending is the fragment tail. set_skip(ToServer, pending) makes the next input land on the following RPC. Do the same for the NFSv3 READ reply count 0 return, toward the client. count 0 does not mean the fragment is finished. The fragment length is independent of count.


Files


Subtasks 1 (0 open — 1 closed)

Security #9225: nfsv3/tcp: partial WRITE with count 0 desynchronizes the parser (8.0.x backport)ClosedOISF DevActions

Related issues 1 (0 open — 1 closed)

Related to Suricata - Security #9190: nfs: partial NFSv3 record checks fatally disable app-layer inspectionClosedJason IshActions
Actions

Also available in: PDF Atom