Project

General

Profile

Actions

Security #9196

closed
JI JI

nfs/tcp: evasion on fragmented NFSv3 FILE_SYNC WRITE

Security #9196: nfs/tcp: evasion on fragmented NFSv3 FILE_SYNC WRITE

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:

d31582843a92268b94751387998e34b0180a5441

Severity:
LOW
Disclosure Date:
01/07/2027

Description

Summary

On a default NFSv3 TCP flow, a WRITE whose stable field is FILE_SYNC (2) sets is_last immediately. If that record is still incomplete, the new file transaction is closed on the first segment while ts_chunk_left stays equal to the unread file length. The next segment is not consumed as file data. It is parsed as a fresh RPC header, the parse fails, and AppLayerResult::err() turns application-layer parsing off for the rest of the TCP flow. A following NFSv3 REMOVE that matches nfs_procedure:12 then produces no alert. The same REMOVE alerts when stable is DATA_SYNC, and when the FILE_SYNC WRITE arrives in one segment. Unpack the attachment and run ./verify.sh.

Affected Versions

Confirmed on Suricata 8.0.7 RELEASE from jasonish/suricata:latest, IDS mode, with the stock NFS parser enabled and no extra NFS options. TCP detection stays on the built-in port 2049. The FILE_SYNC shortcut is not behind a configuration flag.

Preconditions

The sensor must see the TCP flow and select the NFS parser. With the default config that is traffic to TCP 2049. The attacker needs no account on the sensor and no change to the NFS settings. The WRITE record must be at least 512 bytes so the partial-record path runs, the first segment must contain a parseable WRITE header but not the whole file blob, and stable must be 2. This reproduction sniffs a Docker bridge, so Suricata is started with -k none. That only accepts frames whose checksums were left incomplete by bridge offload. It does not change NFS parsing.

Security Impact

For the attacked TCP flow, NFS transactions stop being created after the bad continuation, so transaction rules such as nfs_procedure no longer match later records on that flow. The Suricata process keeps running. The follow-up REMOVE bytes are present on the bridge capture and were accepted by the peer. A new TCP connection is parsed normally. This run does not show a crash, and it does not claim that payload rules which never consult an NFS transaction are bypassed. The same stable 2 shortcut exists in the NFSv4 write path and was not exercised here.

Vulnerable Code

rust/src/nfs/nfs.rs, in process_write_record:

// for now assume that stable FILE_SYNC flags means a single chunk
let is_last = w.stable == 2;

On the new file transaction that flag closes the transaction before the record is complete:

if is_last && !queue_exceeded {
tx.is_last = true;
tx.request_done = true;
tx.is_file_closed = true;
}

The unread tail is still recorded:

self.ts_chunk_left = w.file_len - w.file_data.len() as u32;

get_file_tx_by_handle only returns a transaction with is_file_closed false, so the continuation takes the None => consumed = 0 arm in filetracker_update. Those bytes stay in the RPC parse loop. A header error returns AppLayerResult::err(), and AppLayerParserParse calls StreamTcpDisableAppLayer.

Call Chain

nfs_parse_request (rust/src/nfs/nfs.rs:2812) -> parse_tcp_data_ts (:2268) -> parse_tcp_partial_data_ts (:2152) -> process_partial_write_request_record (:1339) -> process_write_record (:1148, is_last at :1160, close at :1289, ts_chunk_left at :1322). Next segment: parse_tcp_data_ts (:2281) -> filetracker_update (:1745, consumed 0) -> RPC header failure (:2386) -> AppLayerResult::err() -> StreamTcpDisableAppLayer (src/app-layer-parser.c:1728).

Payload

One NFSv3 WRITE (procedure 7), RPC record mark covering the full record, stable 2, 800 bytes of file data. The first TCP segment is the RPC and WRITE header plus 48 data bytes (149 bytes in this build). The second segment is the remaining 752 data bytes. After that segment is acknowledged, an NFSv3 REMOVE (procedure 12) carries the filename NFSSYNC_REMOVE_MARKER. The rule is nfs_procedure:12.

Reproduction

Image jasonish/suricata:latest (8.0.7). Bridge br-nfssync, network suri-nfssync, subnet 172.31.10.0/24. The peer listens on 172.31.10.10:2049. Suricata sniffs br-nfssync from the host network namespace.

./verify.sh

Observed on this run:

control data_sync_split alerts=1 marker_on_bridge=true bridge_segments=3
control file_sync_oneshot alerts=1 marker_on_bridge=true bridge_segments=2
attack file_sync_split alerts=0 marker_on_bridge=true marker_at_app=true followup_bytes_at_app=true bridge_segments=3 suricata_running=true
VERDICT: PASS

Fix Recommendation

Do not treat stable 2 as proof that the WRITE record has arrived. Keep is_file_closed and request_done clear until w.file_data.len() w.file_len, and leave the transaction visible to get_file_tx_by_handle while ts_chunk_left is non-zero. The existing completion path in filetracker_update can close the transaction once the tracker finishes. If a continuation cannot be attached to an open file transaction, consume or skip the outstanding ts_chunk_left bytes instead of parsing them as a new RPC header, and do not return AppLayerResult::err() for that mismatch. Apply the same rule to write_v4 in rust/src/nfs/nfs4.rs, which copies the stable == 2 assumption.


Files


Subtasks 1 (0 open — 1 closed)

Security #9197: nfs/tcp: evasion on fragmented NFSv3 FILE_SYNC WRITE (8.0.x backport)ClosedOISF DevActions

Related issues 1 (0 open — 1 closed)

Related to Suricata - Bug #8009: NFSv3: File extraction bug when stable equal with FILE_SYNCClosedOISF DevActions

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

  • Status changed from New to Triaged
  • Severity set to LOW
  • Label Needs backport to 8.0 added

Low. Looks like the parser errors out cause a lack of visibility.

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

  • Subtask #9197 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 #4

  • Related to Bug #8009: NFSv3: File extraction bug when stable equal with FILE_SYNC added

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

  • Status changed from Triaged to In Review

MR1384

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

  • Assignee changed from OISF Dev to Jason Ish

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

  • GHSA set to GHSA-mcc8-ww79-gg9j

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

  • Subject changed from nfs: NFSv3 FILE_SYNC WRITE split across TCP segments disables the flow parser, so later NFS records are not alerted to nfs/tcp: evasion on fragmented NFSv3 FILE_SYNC WRITE

JI Updated by Jason Ish 26 days ago Actions #9

  • Status changed from In Review to Resolved

JI Updated by Jason Ish 26 days ago Actions #10

  • Status changed from Resolved to Closed

JI Updated by Jason Ish 25 days ago Actions #11

  • Git IDs updated (diff)

JI Updated by Jason Ish 7 days ago Actions #12

  • Private changed from Yes to No
Actions

Also available in: PDF Atom