Repository navigation
nfs: feature work, SMB parity (v26) - v26 - #16626
victorjulien wants to merge 29 commits into
Conversation
suricata-review-bot
left a comment
There was a problem hiding this comment.
AI-generated review.
Verdict: changes requested
3 findings posted as inline comments:
- Medium —
rust/src/nfs/nfs.rs:2132—tdf.total_bytes += data.len()counts the whole input passed to the chunk path, not only this chunk's file data. - Medium (follow-up) —
doc/userguide/upgrade/9.0-logging-changes.rst:150-161— The note says each listed operation produces annfsrecord, and that rules now alert once per tracked NFSv4 operation instead of once per… - Medium (follow-up) —
etc/schema.json:4920-4922— The newnfs.namebuffer returns exactlytx.file_name, which is logged asnfs.filename.
Automated at commit e3fb80324c42 using Claude Code with claude-opus-5-5/xhigh. Run: 721a129c8626a821.
| let is_last_chunk = tdf.file_tracker.get_chunk_is_last() | ||
| && !tdf.file_tracker.is_truncated(); | ||
| let cs = filetracker_update(&mut tdf.file_tracker, data, gap_size); | ||
| tdf.total_bytes += data.len() as u64; |
There was a problem hiding this comment.
Medium — tdf.total_bytes += data.len() counts the whole input passed to the chunk path, not only this chunk's file data. On the final segment of a READ or WRITE record, that input also holds the XDR fill and any pipelined records after it. On a gap, it is the full zero-filled gap buffer. As a result, nfs.read.size and nfs.write.size are inflated on ordinary multi-record transfers. Count only the file bytes this input contributes (for example, the add computed above). Also assert these fields in a suricata-verify test with a pipelined, multi-segment transfer.
| More NFSv4 compounds are tracked as transactions. CLOSE, CREATE_SESSION, | ||
| DELEGRETURN, DESTROY_CLIENTID, DESTROY_SESSION, EXCHANGE_ID, GETDEVINFO, | ||
| LAYOUTGET, LAYOUTRETURN, RECLAIM_COMPLETE and SECINFO_NO_NAME now each produce | ||
| an ``nfs`` record, so a capture that logged one NFSv4 record can log one per | ||
| operation. READ and WRITE were already tracked as file transactions, a | ||
| compound of only PUTFH and GETATTR opens no transaction, and a GETATTR after | ||
| another operation stays that operation's attribute follow-up. | ||
|
|
||
| Alerts attach to transactions, so a rule that uses NFS transaction keywords | ||
| (``nfs_version``, ``nfs_procedure``, the file keywords) now alerts once per | ||
| tracked NFSv4 operation instead of once per compound. To keep a single alert, | ||
| add ``nfs_procedure`` for the operation the rule is about. |
There was a problem hiding this comment.
Medium (follow-up) — The note says each listed operation produces an nfs record, and that rules now alert once per tracked NFSv4 operation instead of once per compound. In the code, compound_request still creates at most one non-file transaction per compound, for the op that v4_main_op_take picks. For example, SEQUENCE, PUTFH, LAYOUTRETURN, CLOSE logs only CLOSE. Before this change, such compounds had no transaction at all. The nfs_procedure advice relies on this wrong model. Describe one transaction per compound, for its main operation.
| "filename": { | ||
| "type": "string" | ||
| "type": "string", | ||
| "description": "file name of the transaction when known, else empty; a name component, not a path" |
There was a problem hiding this comment.
Medium (follow-up) — The new nfs.name buffer returns exactly tx.file_name, which is logged as nfs.filename. The filename schema entry has no "suricata": {"keywords": ["nfs.name"]} mapping, so scripts/eve-parity.py unmapped-keywords lists the new keyword. Add the mapping, as nfs_procedure and nfs.version already have.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #16626 +/- ##
==========================================
+ Coverage 83.97% 84.02% +0.05%
==========================================
Files 1008 1008
Lines 286489 288875 +2386
==========================================
+ Hits 240565 242719 +2154
- Misses 45924 46156 +232
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Information: QA ran without warnings. Pipeline = 35812 |
e3fb803 to
4a80f1a
Compare
suricata-review-bot
left a comment
There was a problem hiding this comment.
AI-generated review.
Verdict: comment
2 findings posted as inline comments:
- Medium (follow-up) —
rust/src/nfs/log.rs:256-265— In the alert/fileinfo metadata path,statusand the newstatus_codeare written even when no reply status was seen, sostatus_code… - Medium (follow-up) —
rust/src/nfs/nfs.rs:4080-4092— The new to-server|80 00|pattern probe means NFSv3/v4 over TCP is detected on any port, not only ondetection-ports.
Other findings:
- Medium (follow-up) — suricata-verify PR #3529 does not assert any of the new fields:
nfs.client_id,nfs.minorversion,nfs.status_code,read.offsetandwrite.offset. It also does not assert the newfile_overlap,request_to_clientandresponse_to_serverevents, which ship with default rules. Regressions in any of these would go unnoticed. Add field checks on an NFSv4.1 capture, and small captures for an overlapping WRITE and for a record sent in the wrong direction.
Previous feedback:
- Addressed — suricata-review-bot's comment at
rust/src/nfs/nfs.rs:2132— The chunk path now adds only the file bytes (add), and a new suricata-verify test checks READ and WRITE sizes with pipelined records. - Addressed — suricata-review-bot's comment at
doc/userguide/upgrade/9.0-logging-changes.rst:161— The upgrade note now says each compound yields one transaction for its main operation, and that rules alert once per compound. - Addressed — suricata-review-bot's comment at
etc/schema.json:4922— Thenfs.filenameschema entry now maps to thenfs.namekeyword.
Automated at commit 4a80f1a36b35 using Claude Code with claude-opus-5-5/xhigh. Run: 329440a53d95a2e3.
| if tx.nfs_status_set || !status_required { | ||
| let status = if state.nfs_version == 4 { | ||
| nfs4_status_string(tx.nfs_response_status) | ||
| } else { | ||
| nfs3_status_string(tx.nfs_response_status) | ||
| }; | ||
| js.set_string("status", &status)?; | ||
| // Numeric status code (SMB parity: status + status_code). | ||
| js.set_uint("status_code", tx.nfs_response_status as u64)?; | ||
| } |
There was a problem hiding this comment.
Medium (follow-up) — In the alert/fileinfo metadata path, status and the new status_code are written even when no reply status was seen, so status_code reads 0 (success). FILE_SYNC WRITE and COMMIT close the file on the request, so their fileinfo always reports status_code: 0, even for writes the server rejects. That contradicts the schema ("only when the reply carries a status") and the upgrade note's claim that fileinfo "carries the status". Omit status_code when nfs_status_set is false, and correct the note.
| if SCAppLayerProtoDetectPMRegisterPatternCSwPP( | ||
| IPPROTO_TCP, | ||
| ALPROTO_NFS, | ||
| b"|80||00|\0".as_ptr() as *const std::os::raw::c_char, | ||
| 2, | ||
| 0, | ||
| Direction::ToServer as u8, | ||
| Some(ffi_nfs_probe), | ||
| NFS_MIN_FRAME_LEN, | ||
| NFS_MIN_FRAME_LEN, | ||
| ) < 0 | ||
| { | ||
| SCLogDebug!("nfs pattern probe registration (ts) failed"); |
There was a problem hiding this comment.
Medium (follow-up) — The new to-server |80 00| pattern probe means NFSv3/v4 over TCP is detected on any port, not only on detection-ports. That changes which flows get app_proto: nfs, produce NFS records and match alert nfs rules. The PR description, the 9d27d6c commit message, the upgrade notes and protocols.rst do not mention this. Add an upgrade note and a suricata-verify test on a non-default port.
|
WARNING:
Pipeline = 35871 |
4a80f1a to
a280534
Compare
suricata-review-bot
left a comment
There was a problem hiding this comment.
AI-generated review.
Verdict: comment
2 findings posted as inline comments:
- Medium (follow-up) —
doc/userguide/upgrade/9.0-logging-changes.rst:200-204— The note says thefileinforecord for a WRITE closed from the request "carries the status". - Medium (follow-up) —
rust/src/nfs/nfs.rs:4143-4164—app-layer.protocols.nfs.filteris parsed only in the TCP registration, but it controls all NFS EVE logging.
Previous feedback:
- Partially addressed — suricata-review-bot's comment at
rust/src/nfs/log.rs:270—status_codeis now omitted when no reply status was seen. The upgrade note still saysfileinfocarries the status, but it logs a defaultOK. - Addressed — suricata-review-bot's comment at
rust/src/nfs/nfs.rs:4096— Any-port TCP detection is now described in the description, the commit message, the upgrade notes and the protocols guide, and a suricata-verify test covers a non-default port.
Automated at commit a28053443ab4 using Claude Code with claude-opus-5-5/xhigh. Run: 79018976d0ad1c8f.
| A file transaction for a WRITE whose last record is fully buffered is logged | ||
| when the request is parsed, before the reply has been seen. It carries no | ||
| ``status`` field, where a build that logged it at the reply showed the default | ||
| ``NFS_OK``. The matching ``fileinfo`` record is written when the file closes | ||
| and carries the status. |
There was a problem hiding this comment.
Medium (follow-up) — The note says the fileinfo record for a WRITE closed from the request "carries the status". That record is built through the metadata path before any reply arrives, so it logs the unset default: nfs.status reads OK even for a rejected FILE_SYNC WRITE. The nfs3-write-status-code test in suricata-verify PR #3529 pins this. The old default was also logged as OK, not NFS_OK. Users will read fileinfo nfs.status as the real reply status. Say that it reads OK when no reply was seen, and change NFS_OK to OK.
| if let Some(node) = conf_get_node("app-layer.protocols.nfs.filter") { | ||
| let mut list = Vec::new(); | ||
| if node.is_seq() { | ||
| if let Some(mut cur) = node.first() { | ||
| loop { | ||
| if let Some(v) = cur.value_opt() { | ||
| list.push(v.to_lowercase()); | ||
| } | ||
| match cur.next() { | ||
| Some(n) => cur = n, | ||
| None => break, | ||
| } | ||
| } | ||
| } | ||
| } else if let Some(v) = node.value_opt() { | ||
| list.push(v.to_lowercase()); | ||
| } | ||
| // key present: the list (possibly empty) fully defines the | ||
| // filter; an empty list logs everything | ||
| SCLogDebug!("nfs filter: procedures {:?}", &list); | ||
| NFS_CFG_FILTER_SET = true; | ||
| NFS_CFG_FILTER_PROCS = list; |
There was a problem hiding this comment.
Medium (follow-up) — app-layer.protocols.nfs.filter is parsed only in the TCP registration, but it controls all NFS EVE logging. When NFS is enabled only for UDP (e.g. app-layer.protocols.nfs.tcp.enabled: no), the configured list is silently ignored and the GETATTR default applies. Parse the filter in a transport-independent path, for example next to load_nfs_limit_config(), which both registrations call. Add a suricata-verify test with a UDP-only configuration.
|
Information: QA ran without warnings. Pipeline = 35876 |
a280534 to
f5213f2
Compare
suricata-review-bot
left a comment
There was a problem hiding this comment.
AI-generated review.
Verdict: comment
2 findings posted as inline comments:
- Medium (follow-up) —
rust/src/nfs/log.rs:317-320— Event-only transactions (record_overflow,response_to_server,request_to_client) are kept out ofnfsrecords because logging them… - Medium (follow-up) —
doc/userguide/upgrade/9.0-logging-changes.rst:200-203— The note says the old default status wasNFS_OK, but 8.x loggedOK.
Previous feedback:
- Partially addressed — suricata-review-bot's comment at
doc/userguide/upgrade/9.0-logging-changes.rst:204— The note now saysfileinfostatusreads the defaultOK, but it still gives the old default asNFS_OKinstead ofOK. - Addressed — suricata-review-bot's comment at
rust/src/nfs/log.rs:270—status_codeis now written only when a reply status was seen. The schema and upgrade note now sayfileinfostatusreadsOKwhen no reply was seen. - Addressed — suricata-review-bot's comment at
rust/src/nfs/nfs.rs:4164— The filter is now parsed in the shared config loader called by both TCP and UDP registration, and a UDP-only suricata-verify test covers it.
Automated at commit f5213f2cac97 using Claude Code with claude-opus-5-5/xhigh. Run: cba4f370565f04bf.
| pub extern "C" fn SCNfsLogJsonResponseMetadata( | ||
| state: &mut NFSState, tx: &NFSTransaction, js: &mut JsonBuilder, | ||
| ) -> bool { | ||
| nfs_log_response(state, tx, js, false).is_ok() |
There was a problem hiding this comment.
Medium (follow-up) — Event-only transactions (record_overflow, response_to_server, request_to_client) are kept out of nfs records because logging them would invent a procedure. Alert metadata still renders them through SCNfsLogJsonResponseMetadata and SCNfsRpcLogJsonResponse. As a result, the default rules (sids 2223010, 2223016, 2223017) alert with nfs.procedure: "NULL", nfs.status: "OK" and rpc.status: "ACCEPTED" for forged or anomalous records. Return false for tx.is_event_only in both functions, or log only rpc.xid. Add a suricata-verify check on the record_overflow alert.
| A file transaction for a WRITE whose last record is fully buffered is logged | ||
| when the request is parsed, before the reply has been seen. It carries no | ||
| ``status`` field, where a build that logged it at the reply showed the default | ||
| ``NFS_OK``. The matching ``fileinfo`` record is written when the file closes. |
There was a problem hiding this comment.
Medium (follow-up) — The note says the old default status was NFS_OK, but 8.x logged OK. It also presents the missing status as specific to WRITE file records. In fact, nfs records now omit nfs.status whenever no reply status was seen, where 8.x always logged OK. Two examples are requests whose reply never arrived and rejected RPC replies with no status word. Change NFS_OK to OK and state the general rule so EVE consumers that expect the field are warned.
|
Information: QA ran without warnings. Pipeline = 35889 |
f5213f2 to
91f2b12
Compare
suricata-review-bot
left a comment
There was a problem hiding this comment.
AI-generated review.
Verdict: comment
3 findings posted as inline comments:
- Medium (follow-up) —
rust/src/nfs/log.rs:256-270—nfs.statusandstatus_codenow depend onnfs_status_set. - Medium (follow-up) —
rust/src/nfs/nfs4.rs:142—file_overlapis raised for v2/v3 WRITEs and for READ replies, butwrite_v4()has now.offset < tdf.file_tracker.trackedcheck. - Medium (follow-up) —
rust/src/nfs/log.rs:277-282— Neither the Rust tests nor suricata-verify PR #3529 check how the new…
Previous feedback:
- Addressed — suricata-review-bot's comment at
doc/userguide/upgrade/9.0-logging-changes.rst:204— The note now says the fileinfostatusreadsOKwhen no reply was observed, and the incorrectNFS_OKwording is gone. - Addressed — suricata-review-bot's comment at
rust/src/nfs/log.rs:325— Both metadata renderers now return false for event-only transactions. A unit test and a suricata-verify check confirm record_overflow alerts carry no nfs or rpc block. - Addressed — suricata-review-bot's comment at
doc/userguide/upgrade/9.0-logging-changes.rst:203— The upgrade note now states the general omission rule, lists the no-reply and rejected-reply cases, and usesOKinstead ofNFS_OK.
Automated at commit 91f2b124901b using Claude Code with claude-opus-5-5/xhigh. Run: 2ad7ac731c58c7e8.
| if tx.nfs_status_set || !status_required { | ||
| let status = if state.nfs_version == 4 { | ||
| nfs4_status_string(tx.nfs_response_status) | ||
| } else { | ||
| nfs3_status_string(tx.nfs_response_status) | ||
| }; | ||
| js.set_string("status", &status)?; | ||
| } | ||
| // Numeric status code (SMB parity: status + status_code), but only when a | ||
| // reply status was actually seen: 0 reads as NFS3_OK, and a transaction | ||
| // closed from the request side (v3 FILE_SYNC WRITE, v4 COMMIT) has no | ||
| // reply yet, so emitting it there would claim success. | ||
| if tx.nfs_status_set { | ||
| js.set_uint("status_code", tx.nfs_response_status as u64)?; | ||
| } |
There was a problem hiding this comment.
Medium (follow-up) — nfs.status and status_code now depend on nfs_status_set. File transactions only get it from an eof READ reply or a FILE_SYNC WRITE reply. So a READ that never reaches EOF, and UNSTABLE WRITEs closed by COMMIT (the usual Linux pattern, and v4 COMMIT/CLOSE too), are logged without a status even though OK replies were seen. That contradicts the upgrade note's "no reply status has been seen" rule. Apply each READ/WRITE reply's status to the file tx, or document this case, and add a suricata-verify check.
| &r.hdr.xid, | ||
| ); | ||
| tdf.chunk_count += 1; | ||
| tdf.note_chunk_data(w.offset, w.data.len() as u64); |
There was a problem hiding this comment.
Medium (follow-up) — file_overlap is raised for v2/v3 WRITEs and for READ replies, but write_v4() has no w.offset < tdf.file_tracker.tracked check. An overlapping NFSv4 WRITE is therefore still dropped silently by the file tracker, contrary to the description and commit 0f9a544. Overlapping writes can leave the inspected file different from what the server stores. Add the check to the v4 same-handle branch. Sid 2223012 has no test coverage, so also add a suricata-verify test for v3 and v4 overlaps.
| if state.nfs_version == 4 { | ||
| js.set_uint("minorversion", state.minorversion as u64)?; | ||
| if let Some(ref cid) = state.client_id { | ||
| js.set_hex("client_id", cid)?; | ||
| } | ||
| } |
There was a problem hiding this comment.
Medium (follow-up) — Neither the Rust tests nor suricata-verify PR #3529 check how the new nfs.minorversion and nfs.client_id fields are logged. client_id has three sources (SETCLIENTID, EXCHANGE_ID, CREATE_SESSION), and nfs4-01 already carries v4.1 session traffic. A regression in either field would go unnoticed. Pin both fields in the nfs4-01 nfs record checks. Also add one check for a nonzero nfs.status_code: current tests only check that it is absent.
|
Information: QA ran without warnings. Pipeline = 35890 |
91f2b12 to
9511e5c
Compare
suricata-review-bot
left a comment
There was a problem hiding this comment.
AI-generated review.
Verdict: comment
2 findings posted as inline comments:
- Medium (follow-up) —
rust/src/nfs/nfs4.rs:723-727—compound_response()only runs whenxidmap.procedure == NFSPROC4_COMPOUND, so thisNFSPROC4_WRITEtest never matches and… - Medium (follow-up) —
rust/src/nfs/nfs.rs:1658-1664— In the new-tx arm, a FILE_SYNC WRITE whose record is still partial never getsresponse_done.
Previous feedback:
- Partially addressed — suricata-review-bot's comment at
rust/src/nfs/log.rs:270— READ and v3 WRITE replies now set the file tx status. v4's handle lookup never runs, so pipelined v4 WRITE replies for earlier chunks are still dropped. - Partially addressed — suricata-review-bot's comment at
rust/src/nfs/nfs4.rs:150— write_v4() now raises file_overlap and a v4 suricata-verify test asserts it. No suricata-verify test covers a v3 overlapping WRITE. - Addressed — suricata-review-bot's comment at
rust/src/nfs/log.rs:282— nfs4-01 now pins minorversion and client_id. nfs3-write-status-code and nfs3-write-chunk-status check a nonzero status_code.
Automated at commit 9511e5c2d0c4 using Claude Code with claude-opus-5-5/xhigh. Run: 134f3cb89d4990a0.
| let write_handle = if xidmap.procedure == NFSPROC4_WRITE { | ||
| xidmap.file_handle.as_slice() | ||
| } else { | ||
| &[] | ||
| }; |
There was a problem hiding this comment.
Medium (follow-up) — compound_response() only runs when xidmap.procedure == NFSPROC4_COMPOUND, so this NFSPROC4_WRITE test never matches and write_handle is always empty. As a result, v4 WRITE replies reach the file tx only through file_last_xid, which belongs to the newest chunk. With pipelined WRITEs, an error reply to an earlier chunk is dropped and the tx logs a later OK. That breaks the upgrade note's first-status rule. Pass the handle when the compound carried a WRITE, and add a v4 counterpart of nfs3-write-chunk-status.
| if is_last && !queue_exceeded { | ||
| tx.is_last = true; | ||
| /* if this is a partial record we will close the tx | ||
| * when we've received the final data */ | ||
| if !is_partial { | ||
| tx.request_done = true; | ||
| tx.response_done = true; |
There was a problem hiding this comment.
Medium (follow-up) — In the new-tx arm, a FILE_SYNC WRITE whose record is still partial never gets response_done. The chunk path's to-server completion sets only request_done and is_file_closed, and the reply path only copies the status. A single-RPC WRITE that spans TCP segments, which is common for small files (W2 in nfs3-record-slack-transfer-size), therefore stays open until flow end. Once more than max-tx (default 1024) pile up, eviction raises too_many_transactions. Set response_done on is_last regardless of is_partial, as the found arm does, or in the chunk path. Add a test.
|
WARNING:
Pipeline = 35893 |
9511e5c to
fc41cf5
Compare
suricata-review-bot
left a comment
There was a problem hiding this comment.
AI-generated review.
Verdict: comment
Previous feedback:
- Partially addressed — suricata-review-bot's comment at
rust/src/nfs/nfs4.rs:150— write_v4() now raises file_overlap and a v4 suricata-verify test covers it; the v3 WRITE and READ overlap paths still have no test. - Addressed — suricata-review-bot's comment at
rust/src/nfs/log.rs:270— Every READ reply record now sets the status, WRITE replies reach the file transaction through the recorded chunk xids, and the upgrade note describes this. - Addressed — suricata-review-bot's comment at
rust/src/nfs/nfs4.rs:727— compound_response() now passes the WRITE file handle when the reply carries a WRITE op, and a v4 chunk-status suricata-verify test was added. - Addressed — suricata-review-bot's comment at
rust/src/nfs/nfs.rs:1664— The new-transaction arm now sets response_done for a FILE_SYNC write on is_last, even while the record is still partial.
No high- or medium-severity findings.
Automated at commit fc41cf5fbf44 using Claude Code with claude-opus-5-5/xhigh. Run: dad9888481df3120.
|
Information: QA ran without warnings. Pipeline = 35907 |
fc41cf5 to
381d7f2
Compare
suricata-review-bot
left a comment
There was a problem hiding this comment.
AI-generated review.
Verdict: approve
Previous feedback:
- Addressed — suricata-review-bot's comment at
rust/src/nfs/nfs4.rs:150— write_v4() now raises file_overlap below the tracked high-water mark, and suricata-verify adds v3, v4 write and read overlap tests asserting the anomaly.
No high- or medium-severity findings.
Automated at commit 381d7f2ee7e0 using Claude Code with claude-opus-5-5/xhigh. Run: 4b52e28145604239.
|
Information: QA ran without warnings. Pipeline = 35910 |
381d7f2 to
e393ee1
Compare
suricata-review-bot
left a comment
There was a problem hiding this comment.
AI-generated review.
Verdict: approve
No high- or medium-severity findings.
Automated at commit e393ee1f22ff using Claude Code with claude-opus-5-5/xhigh. Run: ea499ddfc59bee70.
A record mark's 31-bit length field was taken at face value, so a hostile or corrupt stream could claim a gigabyte-sized record and the parser would try to allocate it. The claim is bounded to the field width with a 64 MiB floor, independent of the stream size limits, and exceeding it is a record_overflow anomaly rather than a memory spike. Ticket: OISF#9401
READ and WRITE advertise maxread and maxwrite through GETATTR and FSINFO. The compound's ceilings are fattr4 values, so take them from the attribute list rather than only from FSINFO, and keep the v4 transaction's own record of what the server advertised. A write that lands on bytes another write already filled is not an out-of-order chunk, it is overlapping data: log it with a file_overlap event instead of quietly rebuilding the file, and complete a transaction that takes several writes only once all of its data has arrived. Ticket: OISF#9401
The v3 procedures that take a bare filehandle (READ, READLINK, READDIR, FSSTAT, FSINFO, PATHCONF) and those that take a handle plus a name did not parse their arguments at all, so the transaction carried neither handle nor name and the record logged an empty file identity. Parse them, including the attribute blocks they sit in: fattr3 as RFC 1813 lays it out (size3 is a uint64, so the block is 4 + 80 bytes), with ftype3 restricted to 0..6 so that a zero-filled attribute block parses and anything outside it looks like a misaligned stream. entry3 is read as its name, cookie and the attribute block that trails the name. NFS also gets its own stream depth setting, so it no longer inherits the global value. Ticket: OISF#9471, OISF#9469
NFS over TCP was probed on the ports it is configured for, so a server elsewhere went undetected and nothing was logged for the flow. Register a to-server pattern for the RPC call header - message type CALL and rpcvers 2, eight bytes at offset 8 - and let the probing parser decide: the record mark, the program number at offset 16, the version and the procedure are all checked there. The pattern has to be rare, and its window short. A stream the probe refuses is not concluded where it stands: it stays undecided until the to-server data reaches pp_max_len, which is 36 for TCP to-server (SMB's MIN_REC_SIZE), so anchoring on the two bytes of a record mark instead left every shorter flow with no app_proto at all. Keeping the window inside 16 bytes is what app-layer-http2.c does for the same reason: a pattern the engine can only weigh up after 20 bytes breaks the app-layer unit tests. To server only, because a REPLY carries no program number. Ticket: OISF#9470
NFS logged little per transaction and hid most of it. Each transaction now gets its own record with the fields that make it useful: read and write records carry the first chunk offset, the total bytes and the eof flag; the v4 records carry the minor version and the client id, the way SMB reports its dialect and session; procedure names come from one shared helper per version instead of several copies of the same match. Logging is configurable per procedure with app-layer.protocols.nfs.filter: a list of names, matched case-insensitively against the transaction's version-specific name. When the key is absent the historical default applies and v3 GETATTR is filtered out; an empty list logs every procedure. NFS is in the default ruleset now, so the records are matchable. Ticket: OISF#9403
Two sticky buffers for rules: nfs.name matches the name a transaction carries (LOOKUP and friends learn it, and the handle keeps it attached to later reads and writes) and nfs.handle matches the raw file handle. nfs.name covers more than file.name: it works with the file store off and covers transactions that never open a file. COMMIT is absent because it opens no transaction, and RENAME reports its source; the target is in the event's rename.to. v2 gets its own request parsing with the same file identity wiring as v3, in v2's own opcode space (LOOKUP is 4 there, not 3). v2 WRITE stays a plain record: RFC 1094 has neither COMMIT nor a stable flag, so a file transaction opened there would never see a completion signal. Ticket: OISF#9402
CREATE_SESSION and SEQUENCE were read against draft structures, so a v4.1 compound's session identity came out wrong or empty. Parse them as RFC 5661 defines them, and take the client id from whichever of EXCHANGE_ID, CREATE_SESSION or (for v4.0) SETCLIENTID the session actually established. Also sync the nfs object in etc/schema.json with the fields the records emit, and replace the shared static-mut references in the config path with raw-pointer reads: the filter list is written once during configuration and never mutated again. Ticket: OISF#9401
Two rules the transaction model needs stated explicitly: a trailing GETATTR is a secondary operation and does not take over a compound whose main op is already decided, and a compound of only PUTFH and GETATTR opens no transaction, as in mainline. Without them a status poll decided what a compound reported. Same principle, three places: a v4 transaction now completes on every parsed reply, taking the main op's status when the reply carries one and the compound status when it does not - the old path only completed when a status word was there, which left the transaction open for good; an EXCHANGE_ID reply does not replace a client id already observed for the flow; and the v4 ceilings saturate rather than wrap when an attribute value is beyond u32. Two v3 corrections for traffic that is valid but was rejected: ftype3 takes 7, which is FIFO in RFC 1813 and what servers send, and entry3 carries no attributes at all - they appear only in entryplus3 - so reading one made a real readdir reply look malformed. Ticket: OISF#9400
A WRITE reply carries no file data and the reply path's xid lookup skips file transactions, so nothing else can complete a WRITE transaction. A record whose data was fully buffered is complete at parse time; one still pending is completed by the chunk path once the rest of the data arrives. That is what keeps a split terminal WRITE from logging a short file (the 40006 and 8009 captures), and v4 WRITE follows the same rule, keyed on the record's own data rather than the tracker. Alert and fileinfo metadata keep nfs.status even when the status came from the request side, since both dump the transaction's state. The version is set on the transaction from the request, so one that completes before any reply reports the version it came from. A 0 size limit means unlimited for the record bound, which is not the same as leaving the limit unset. A transaction standing for an event rather than a call is the exception: it has no procedure, no status and no transaction id worth logging, and the fields would be whatever the bytes behind a forged record mark looked like. Both metadata renderers return false for it, so an alert on record_overflow or a direction event carries no nfs or rpc block. The main nfs record already skipped these transactions. The reply side finds the transaction a WRITE belongs to by xid, then by handle, in v3 and v4 alike: a write in several chunks has several xids in flight, so matching on the newest drops a reply to an earlier one, and two writes to one handle would take each other's replies. Transactions therefore keep the xids of the records that fed them. A record reports the first error any of its replies carried, and otherwise the first status seen, so an accept cannot hide a rejection and a rejection cannot be hidden by an accept. In v4 the compound's procedure is COMPOUND, so the WRITE op in the reply marks the case, not the xid map entry. A FILE_SYNC write whose record was still pending now sets the response side as the branch for an open transaction does, instead of staying open until the flow is evicted. Ticket: OISF#9400
The upgrade notes, the keyword reference and the configuration reference: the transaction records NFS now emits, nfs.name placed next to file.name, the record bound and the size limits, the fileinfo checksum policy for gapped records, and that v2 WRITE stays a plain record. Also drops the dead code an abandoned approach left behind - a WRITE extent arm for a version that never reaches it - and moves the GETATTR comment to where GETATTR is handled. Ticket: OISF#9402
Unit tests for the sticky buffer getters, for the transaction logging filter (made testable by passing the configuration in rather than reading globals), and descriptions for every nfs field in etc/schema.json. An argument parse failure used to raise malformed_data on whichever transaction happened to be last in the state: on the first record of a flow there is none and the event is silently dropped, and on later records it lands on an unrelated transaction. Raise it on the transaction the record creates, in v3 including the LOOKUP parse that lives in a helper of its own, and in the v2 path. Ticket: OISF#9400
etc/schema.json gains a description for every nfs field. Three were wrong about the code and are fixed: nfs.id is one more than the tx_id on the alert and fileinfo records for the same transaction; nfs.hhash is the CRC32 (IEEE) of the whole handle, not of its first bytes; nfs.client_id has three sources, not one. And the precise wording for nfs.name: the buffer holds the raw bytes, the event's nfs.filename holds them lossily converted, so for a name that is not valid UTF-8 they differ. Ticket: OISF#9402
A name length read from the wire was taken on trust, so v2 names were accepted whatever they claimed to be. v3 names are not a defect: RFC 1813 3.2 declares filename3<> and nfspath3<> with no length bound and leaves rejection to the server through NFS3ERR_NAMETOOLONG. RFC 1094 2.3.7 does bound a v2 name, filename<MAXNAMLEN>, with 3.5 setting MAXNAMLEN to 255. Check the length on the v2 request path and raise malformed_data past the limit. The name is kept on the transaction either way, so nfs.name and nfs.filename still match on it, and it is the logger that decides what to write. parse_nfs3_name inherited that bound from an early draft and rejected long names outright; that goes too. Ticket: OISF#9402
A v3 name can be as large as the reassembly buffer allows, so the writer could hand a megabyte to one field and a record past the 10 MiB MemBuffer limit to the log, where the record is dropped entire. Give the NFS logger the budget the DNS logger has: 128 KiB per record, 8 KiB per string. A string over the cap is written shortened with the in-value marker; a field the budget will not take is left out and named with a *_truncated key, so a dropped field is not read as an absent one. The budget is charged for what gets written rather than for what was parsed: a rename source is logged twice, as filename and as rename.from, and charging the parsed length dropped the field with the record nowhere near its limit. Ticket: OISF#9402
Say which limit applies where, so a truncated field is not mistaken for a missing one: 8 KiB per string and 128 KiB per record at the logger, and the 255 byte name bound at the parser for v2 only, because RFC 1813 3.2 leaves v3 names unbounded. Ticket: OISF#9402
app-layer.protocols.nfs.filter was parsed in the TCP registration, but the logger applies it to every NFS record, so a config with nfs.tcp.enabled: no never installed it and silently kept the built-in default of dropping v3 GETATTR. max-names and max-requests are on the same footing: both size maps that live on the parser state and that UDP uses too. Reading all three in load_nfs_limit_config(), which both registrations call, gives a config with one transport the same behaviour as a config with both. stream- depth stays with TCP as it only bounds reassembly there, and max-tx stays with UDP. Ticket: OISF#9403
A READ wrote its status to the transaction only with the record that ended the transfer. A read that stops short of EOF - a short read, or one whose last record never arrives - was logged without a status, even though every record the server did send carried one. The status now comes from the first record that carries one, or from a later one that reports an error; which record ends the transfer still decides the done flags. The xid now follows the record that last added data rather than the one that ended it, so read.last_xid reports what the schema says and matches the write side. Ticket: OISF#9371
That part of the upgrade notes was a run of dense paragraphs, and the status rule came last although three of the earlier paragraphs depend on it: a record can be written before its reply arrives, and then carries no status at all. Lead with the status rule and its exceptions, then give the compound changes, the port-independent detection, the size bounds, and the new fields, events and keywords a heading each. While reordering, state the exceptions the old text left implicit: an alert and a fileinfo record keep a status, and it reads OK until a reply status is seen. Also correct two statements it had wrong: an RPC-level rejection carries no NFS status, and nfs.truncated also marks a shortened value, not only a record that hit its limit. Ticket: OISF#9402
A reply whose reply_stat is MSG_DENIED carries a reject_stat and either the version range the server accepts or an auth_stat. It has no verifier and no accept_stat, but the reply parsers read the accept layout unconditionally: the deny body was taken for a verifier, the length check failed, and the record was reported as malformed. Parse the deny body per RFC 5531 9 and expose the reject_stat as reject_state. Two further defects kept such a reply from being handled even once it parsed: the record-marking floor of 24 bytes rejected the 20 byte auth_error form before the reply parser ran, and the reply was dispatched to the version handlers, which read the absent program body as malformed. Report the denial on the transaction its call opened: a READ file tx by handle, a WRITE file tx by xid and then handle, anything else the call's own tx. Bytes past the deny body are not RFC 5531: flag them and skip the claimed tail in the partial-record paths, so they never reach the READ data path as file data. set_reply_status keeps the two statuses apart now, so the result does not depend on the order of the replies: a denial is never replaced, and the NFS status is the first NFS error, else the first status carried. The UDP reply parser read reply_stat after the verifier, which only worked because every capture so far carries a zero verifier. Ticket: OISF#9371
The name of an object is in the request (RFC 1094), its handle in the reply: LOOKUP, CREATE and MKDIR answer with a diropres, a handle and the attributes. Nothing read that handle, so the handle to name map stayed empty on the v2 path and every later handle-only operation - GETATTR, SETATTR, READLINK, READDIR, STATFS, READ - logged no file name. Read the handle from those replies, pair it with the request's name and carry it on the transaction. A READLINK on a handle a LOOKUP named now logs that name, and the LOOKUP record carries the handle itself. A reply rejected at the message level carries no diropres, so v2 and v3 now score the transaction and stop instead of reading an empty body as a malformed one. A name over the RFC 1094 bound is flagged on the request that carried it, not again on every later operation that resolves it. Ticket: OISF#9402
A compound can answer PUTFH, WRITE, GETATTR with WRITE OK and GETATTR NFS4ERR_IO. The response side picks the last significant op for the transaction status, so the trailing GETATTR won and an UNSTABLE write was logged as failed although the server stored it. Keep the WRITE op's own result for the file transaction; the main-op selection still drives everything else. Ticket: OISF#9400
RFC 1813 2.6 defines filename3 without a length bound, and the request side no longer caps names either. The entry parsers rejected anything over 1024 bytes, which stopped the entry chain: the long entry and every entry after it lost their handle to name mapping, and later operations on those handles logged no name. Let the parser take the length and leave the bound to the logger, which caps what it writes. Ticket: OISF#9371
The record budget charged input bytes, but a control byte is written as a six byte \u0001 escape. A RENAME with two 8 KiB names of 0x01 was accepted by the parser and emitted 147456 bytes of JSON against a documented 131072 byte record limit, with nfs.truncated left false. Charge the length the value takes once escaped, and the truncation marker when the field cap shortened it. Ticket: OISF#9402
A reply rejected at the message level (GARBAGE_ARGS, PROC_UNAVAIL) is not a denial, and it also carries no program body. The v2 and v3 handlers learned to stop on it, but the v4 dispatcher did not: the empty body was parsed as a COMPOUND, raised malformed_data and left the request transaction open until eviction - and the CLOSE and session transactions this series adds are newly subject to it. Own the case in the dispatcher for every version: score the transaction through the same routing a denial uses, and keep the empty body away from the version handlers. Ticket: OISF#9371
A compound can answer PUTFH, READ, GETATTR with READ OK and GETATTR NFS4ERR_IO. The response side picked the last significant op for the transaction status, so the trailing GETATTR won and the READ was logged as failed - the same for CLOSE and DELEGRETURN. The request side already treats GETATTR as a secondary op. A GETATTR no longer displaces an op that was already selected; a compound of only PUTFH and GETATTR still selects it. Ticket: OISF#9400
PROG_MISMATCH is the one accept_stat that carries a body: the version range the server supports (RFC 5531 9). The reply parser stopped after the accept_stat, so those eight bytes became program data and a body- less reply was reported as malformed - which hits a v4 call answered by a server without v4. Consume the range with the header, the way the denied branch consumes reject_stat. Ticket: OISF#9371
The budget now charges escaped output, so the length helper has to agree with what the builder writes for every byte, and the truncation case has to be exercised with a value over the cap rather than at it. The guide also says the 8 KiB field cap is measured before escaping. Ticket: OISF#9402
Replies without a program body no longer reach the version handlers, so the accepted flag is constant there; drop it and say what the empty-body check is now for. The plain READDIR entry parser lost its name bound with the readdirplus one, so cover it too. Ticket: OISF#9371
eda8273 to
d43a6f5
Compare
suricata-review-bot
left a comment
There was a problem hiding this comment.
AI-generated review.
Verdict: comment
2 findings posted as inline comments:
- Medium (new) —
rust/src/nfs/nfs3.rs:357— The malformed-data fix for Redmine #9371 only covers requests that create a… - Medium (new) —
etc/schema.json:5000— The schema saysrename.from_truncated,rename.to_truncatedandrpc.creds.machine_name_truncated(also lines 5008 and 5787) are set…
Limitations:
- Only the key test definitions in suricata-verify PR #3529 were read in full, not all 151 changed files, so coverage of the remaining tests was not verified.
Previous feedback:
- Addressed — suricata-review-bot's comment at
rust/src/nfs/nfs2.rs:64— v2 LOOKUP, CREATE and MKDIR replies now store the handle-to-name mapping, so later handle-only v2 operations and READ resolve the name.
Redmine tickets not yet In Review: #9400 (In Progress), #9401 (In Progress), #9471 (In Progress), #9469 (In Progress), #9470 (In Progress), #9403 (Assigned), #9402 (In Progress), #9371 (In Progress). Please set them to In Review.
Automated at commit d43a6f52a6ee using Claude Code with claude-opus-5-5/xhigh. Run: 7334b87d9ba43854.
| Err(_) => { | ||
| // tail tolerated (see above), but the anomaly stays | ||
| // observable | ||
| self.set_event(NFSEvent::MalformedData); |
There was a problem hiding this comment.
Medium (new) — The malformed-data fix for Redmine #9371 only covers requests that create a transaction. Several failure paths still call set_event(): v3 READ/WRITE/COMMIT and v2 READ argument failures (nfs3.rs:96,103,168, nfs2.rs:113), and every v3 reply-side failure, including the new READDIR, SETATTR and FSINFO branches. The pattern predates this change. A malformed WRITE as a flow's first record raises no malformed_data, and a malformed pipelined reply flags an unrelated transaction. Raise these events with set_event_new_tx() or on the xid's transaction, and add an SV case for them.
| }, | ||
| "from_truncated": { | ||
| "type": "boolean", | ||
| "description": "set when the source name was shortened to fit the record budget" |
There was a problem hiding this comment.
Medium (new) — The schema says rename.from_truncated, rename.to_truncated and rpc.creds.machine_name_truncated (also lines 5008 and 5787) are set when the value was "shortened to fit the record budget". In fact, set_bounded_string() sets these keys only when the field is dropped entirely. A shortened value just carries the [truncated N additional bytes] marker. The text contradicts the upgrade notes and filename_truncated, so consumers will expect a value that is absent. Reword these descriptions to match filename_truncated.
NFSv2, v3 and v4 parsing and their EVE records are reworked.
Parser:
app_proto: nfs, produce records and matchalert nfsrules. Other ONC RPC services (mountd, rpcbind, nlockmgr) are not claimed, their calls carry a different program number.file_overlapinstead of merging silently.record_overflow.Logging:
nfs.minorversion,nfs.client_id,nfs.eof,nfs.offset,nfs.size,nfs.status_code, andrpc.creds.machine_name.[truncated N additional bytes], a dropped one is named by a*_truncatedkey, and the record setsnfs.truncated.app-layer.protocols.nfs.filterlists procedure names to keep out of the log; v3 GETATTR is the default, an empty list logs everything.app-layer.protocols.nfs.stream-depthoverridesstream.reassembly.depthfor NFS streams.Keywords:
nfs.nameandnfs.handlesticky buffers, plus procedure name matching innfs_procedure.Also: NFS added to the default ruleset,
etc/schema.jsonand the userguide updated, v2 names over the 255 byte protocol limit flagged as malformed.Tickets: #9400, #9401, #9402, #9403, #9371, #9469, #9470, #9471.
SV_BRANCH=OISF/suricata-verify#3529