Project

General

Profile

Actions

Security #9194

closed
JI JI

nfs/tcp: evasion when partial WRITE drops the XDR pad when it straddles a segment

Security #9194: nfs/tcp: evasion when partial WRITE drops the XDR pad when it straddles a segment

Added by Jason Ish about 1 month ago. Updated 7 days ago.

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

ec4acded84ba8bc60adda0d50ec181dc16285c78

Severity:
LOW
Disclosure Date:
01/07/2027

Description

Summary

On a default NFS TCP flow, a partial WRITE whose file data is not a multiple of 4 bytes records the 1 to 3 XDR pad bytes only on the file tracker. The stream cursor ts_chunk_left counts file data alone. If the TCP segment ends on the last data byte, the next segment starts with the pad. The outer filetracker_update sees chunk_left == 0 and returns without consuming the pad, so the following RPC record is parsed off by those bytes and NFS detection on that flow does not recover. A LOOKUP that alerts when the pad shares a segment with the file data produces no alert once the pad is split off, even though those bytes are on the capture interface and the process stays up. Unpack the attachment and run ./verify.sh.

Affected Versions

Confirmed on jasonish/suricata:latest, Suricata 8.0.7 RELEASE, with the stock NFS parser enabled and TCP detection on port 2049. No NFS setting was turned off. The same tc_chunk_left accounting exists on the partial READ-reply path. This run exercised the WRITE path only.

Preconditions

The sensor must see the TCP stream. Default NFS TCP detection on port 2049 is enough. The sender is any host on a path the sensor captures. No Suricata account and no rule or protocol toggle is required. The WRITE record must be at least 512 bytes so the partial-record path runs, the file length must not be a multiple of 4, and one segment boundary must fall between the last file-data byte and the XDR pad. UDP does not use this path.

Security Impact

NFS parsing on that TCP flow loses alignment. A later record that matches an NFS procedure rule is not raised. Proven here: a 415-byte WRITE (1 pad byte) followed by the same NFSv3 LOOKUP alerts once when the pad rides with the data, and zero times when the pad is the first byte of the next segment. The sink accepted all 612 bytes on both flows, and Suricata's own pcap on the sniffed bridge contains the LOOKUP name on the attack flow. The process was still running afterward (exit code 0, not OOM-killed). Not proven: the READ-reply direction, cross-flow bleed, or a daemon crash.

Vulnerable Code

rust/src/nfs/nfs.rs, partial WRITE. The pad is computed and handed to the file tracker, then omitted from the stream cursor:

let pad = w.file_len % 4;
if pad != 0 {
fill_bytes = 4 - pad;
}
// ...
self.ts_chunk_left = w.file_len - w.file_data.len() as u32;

On the next segment the outer update bails before the tracker can eat fill_bytes:

if chunk_left == 0 {
return 0;
}

FileTransferTracker::update in rust/src/filetracker.rs consumes the pad only from bytes already in the current buffer (extra after chunk_left). A pad that arrives later never reaches that code once the outer function has returned. The READ reply path sets tc_chunk_left from data_len - data.len() the same way.

Call Chain

nfs_parse_request -> NFSState::parse_tcp_data_ts (rust/src/nfs/nfs.rs:2268) -> parse_tcp_partial_data_ts (rust/src/nfs/nfs.rs:2153) for a short segment of a record of at least 512 bytes -> process_partial_write_request_record -> process_write_record (rust/src/nfs/nfs.rs:1148), which stores fill_bytes on the tracker and sets ts_chunk_left at rust/src/nfs/nfs.rs:1322.

Next segment: parse_tcp_data_ts calls NFSState::filetracker_update (rust/src/nfs/nfs.rs:2281), which returns 0 at rust/src/nfs/nfs.rs:1583 because ts_chunk_left is 0. FileTransferTracker::update (rust/src/filetracker.rs:379) is not asked to consume the remaining pad. The record parser then reads the pad as the next RPC fragment header.

Payload

One NFSv3 WRITE over TCP, AUTH_NULL, 415 data bytes (length mod 4 is 3, so one 0x00 pad), record size 516. Attack segments are 515 bytes (header plus all file data) then 1 pad byte plus a 96-byte LOOKUP whose filename is NFSXDRPAD. The control sends the 516-byte record intact, then the same LOOKUP bytes. The second segment of the attack begins 00 80 00 00, the pad glued to the real fragment header 80 00 00 5c.

Reproduction

Image jasonish/suricata:latest (8.0.7). Bridge br-nfsxdr on network suri-nfsxdr, subnet 172.31.8.0/24. The sink listens at 172.31.8.20:2049 and only records the bytes it accepts. Suricata uses host networking and sniffs br-nfsxdr because the sensor has to see traffic forwarded on that bridge. Checksum validation is disabled (-k none) so offloaded bridge checksums are not dropped. The closed-flow timeout is set to 5 seconds so the log is readable before the checker finishes. It is not required to trigger the bug.

./verify.sh

control ... lookup_alerts=1 ... nfs_tx=[WRITE version 3, LOOKUP filename NFSXDRPAD version 3]
attack ... lookup_alerts=0 ... app_got=612 app_marker=True suricata_pcap_pkts=1 seg2_prefix=008000005ca11c00
suricata_state=true running 0 false
VERDICT: PASS

Fix Recommendation

When a partial WRITE or READ still owes XDR padding, count the unconsumed pad in the stream cursor (ts_chunk_left / tc_chunk_left), or teach the outer filetracker_update to call the tracker whenever get_fill_bytes() is non-zero even if chunk_left is already 0. The bytes consumed for the pad must advance the TCP cursor before the next RPC header is parsed. Apply the same accounting on the to-client READ reply path.


Files


Subtasks 1 (0 open — 1 closed)

Security #9195: nfs/tcp: evasion when partial WRITE drops the XDR pad when it straddles a segment (8.0.x backport)ClosedOISF DevActions

JI Updated by Jason Ish about 1 month ago Actions #1

  • Severity set to LOW
  • Label Needs backport to 8.0 added

Low, parser errors out; by default should fail closed in IPS mode.

OT Updated by OISF Ticketbot about 1 month ago Actions #2

  • Subtask #9195 added

OT Updated by OISF Ticketbot about 1 month ago Actions #3

  • Label deleted (Needs backport to 8.0)

JI Updated by Jason Ish about 1 month ago Actions #5

Provisional GHSA impact

A valid NFSv3 TCP WRITE whose XDR padding starts in a later TCP segment can desynchronize Suricata's NFS parser and stop NFS inspection for the rest of that flow.

  • Raw TCP inspection continues.
  • The default IPS exception policy drops the affected flow.

JI Updated by Jason Ish about 1 month ago Actions #6

  • Status changed from New to In Review

MR1384

JI Updated by Jason Ish about 1 month ago Actions #7

  • Assignee changed from OISF Dev to Jason Ish

JI Updated by Jason Ish about 1 month ago Actions #8

  • GHSA set to GHSA-fgph-7mhp-x3gf

SB Updated by Shivani Bhardwaj about 1 month ago Actions #9

  • Subject changed from nfs: TCP partial WRITE drops the XDR pad when it straddles a segment, and inspection of that flow stops to nfs/tcp: evasion when partial WRITE drops the XDR pad when it straddles a segment

JI Updated by Jason Ish 26 days ago Actions #10

  • Status changed from In Review to Resolved

JI Updated by Jason Ish 26 days ago Actions #11

  • Status changed from Resolved to Closed

JI Updated by Jason Ish 25 days ago Actions #12

  • Git IDs updated (diff)

JI Updated by Jason Ish 7 days ago Actions #13

  • Private changed from Yes to No
Actions

Also available in: PDF Atom