Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b8b9d4a
nfs4: give the remaining compound operations their own transactions
victorjulien Nov 7, 2026
a623098
nfs: cap the RPC record mark length and log record_overflow
victorjulien Nov 7, 2026
9c32007
nfs: honour the v4 size ceilings and flag overlapping file data
victorjulien Nov 7, 2026
2f55ace
nfs: parse the v3 record arguments and make stream depth configurable
victorjulien Nov 7, 2026
ddd9969
nfs: find NFS over TCP on ports that are not configured
victorjulien Nov 13, 2026
9f36638
eve: rework the NFS transaction records
victorjulien Nov 7, 2026
c04edcf
nfs: add the name and handle buffers and parse v2 requests
victorjulien Nov 7, 2026
ba03a65
nfs: parse the v4.1 session operations per RFC 5661
victorjulien Nov 7, 2026
298116f
nfs: the v4 compound model, and where valid traffic was mis-handled
victorjulien Nov 7, 2026
812a69e
nfs: complete WRITE transactions from the request side
victorjulien Nov 7, 2026
4b88981
doc: the NFS changes for 9.0, and the notes in the right place
victorjulien Nov 7, 2026
bac51d0
nfs: test the new code, and raise malformed data where it belongs
victorjulien Nov 7, 2026
1703735
nfs: describe the fields and correct three that were wrong
victorjulien Nov 7, 2026
5ec2d73
nfs: bound a v2 name at the spec limit
victorjulien Nov 7, 2026
91b622e
nfs: bound what the logger writes
victorjulien Nov 7, 2026
aa78154
nfs: document the logger bounds
victorjulien Nov 7, 2026
a2de53e
nfs: read the transport-independent settings once per config
victorjulien Nov 13, 2026
29518ff
nfs: take a read reply's status from the record that carries it
victorjulien Nov 14, 2026
3666f3e
doc: tighten the NFS logging changes section
victorjulien Nov 25, 2026
04057a7
nfs/rpc: parse a denied reply instead of failing on it
victorjulien Nov 26, 2026
bce035c
nfs2: name an object from the handle its LOOKUP reply returned
victorjulien Nov 26, 2026
0ed1d60
nfs4: report the write's status on the write's transaction
victorjulien Nov 27, 2026
aeb3a76
nfs3: no protocol length limit on READDIRPLUS names
victorjulien Nov 27, 2026
55b7cd7
nfs: charge the log budget for escaped output
victorjulien Nov 27, 2026
544e8a3
nfs: finish transactions answered without a program body
victorjulien Nov 27, 2026
1bbefc0
nfs4: GETATTR is secondary on the response side too
victorjulien Nov 27, 2026
5682b5d
nfs/rpc: consume the PROG_MISMATCH version range
victorjulien Nov 27, 2026
94c8d35
nfs: pin the escaped-length accounting against JsonBuilder
victorjulien Nov 27, 2026
d43a6f5
nfs3: drop the stale accept guard and cover plain READDIR names
victorjulien Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions doc/userguide/configuration/suricata-yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,15 @@ order file data.
max-write-queue-size: 64mb
max-write-queue-cnt: 64

filter:
- GETATTR
- SETATTR

# Stream reassembly size for NFS; when unset the global
# stream.reassembly.depth applies, 0 tracks the whole stream
stream-depth: 0


The `max-read-size` option can be set to control the max size of accepted
READ responses. Events will be raised if READ responses claim or carry too
much data. A value of 0 disables the checks.
Expand All @@ -1942,6 +1951,11 @@ The `max-write-size` option can be set to control the max size of accepted
WRITE request records. Events will be raised if a WRITE request claims too
much data. A value of 0 disables the checks.

Disabling the two checks does not remove the bound on a single RPC record:
an NFS record mark is a 31 bit byte count (RFC 5531 11), so a record claiming
more than 64 MiB - or more than the largest configured size limit, when that is
higher - abandons the flow with the ``record_overflow`` event either way.

The `max-metadata-size` option can be set to control how much of a partial
NFSv3 LOOKUP, READDIRPLUS or CREATE reply may be buffered towards the size its
RPC record claims, so the file handle to filename mapping is kept. A value of 0
Expand Down Expand Up @@ -1971,6 +1985,15 @@ event is raised.
`max-write-queue-size` and `max-write-queue-cnt` are as the READ variants,
but then for WRITEs.

The `filter` option lists procedure names to keep out of the EVE output,
matched case insensitively. When not set, v3 GETATTR is filtered by
default (it is the most frequent NFSv3 procedure and rarely interesting
alone); set an empty list to log every procedure.

`stream-depth` overrides the global `stream.reassembly.depth` for NFS
streams. When unset the global value applies, as before; 0 tracks the
stream completely.

Comment on lines +1993 to +1996

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this was added, but the config option isn't present in the nfs settings example.


Configure DCERPC
~~~~~~~~~~~~~~~~
Expand Down
21 changes: 16 additions & 5 deletions doc/userguide/output/eve/eve-json-format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -623,11 +623,22 @@ Examples
Event type: fileinfo
--------------------

Note that the checksum values for ``md5``, ``sha1``, and ``sha256`` are
available when

* The command line option ``disable-hashing`` was not used
* There are no gaps (areas missing)
Checksum values (``md5``, ``sha1`` and ``sha256``) and file state
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* The command line option ``disable-hashing`` disables all checksums.
* Files with gaps (areas missing) and truncated files are reported with
``state`` set to ``TRUNCATED`` and, when gaps are present, ``gaps`` set
to ``true``.
* By default gapped files are **not** hashed: the ``md5``, ``sha1`` and
``sha256`` values are omitted.
* With ``force-hash`` configured, a **stored** gapped file gets a
``sha256`` value. Note that the missing gap data is zero-filled before
hashing, so the value identifies the reconstructed byte stream, not
the original file. ``md5`` and ``sha1`` are not computed for gapped
files even when forced.
* A gapped file that is not stored (no ``filestore`` and no
``force-filestore``) gets no checksums at all, even with ``force-hash``.

Fields
~~~~~~
Expand Down
36 changes: 36 additions & 0 deletions doc/userguide/protocols/protocols.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,42 @@ Transactions in the SMB implementation are `bidirectional`. There are different
that has a single DCEPRC request and its matching response


NFS
---

Support per version and transport:

* NFSv2: over UDP only. NFSv2 over TCP is not protocol-detected, see the
limitation below.
* NFSv3: over UDP and over TCP.
* NFSv4: over TCP only (RFC 7530 3.1 requires a reliable callback channel).

NFS over TCP is detected without regard to the port: besides the port-based
probing parser, a pattern probe matches the ONC RPC call header (message type
CALL, rpcvers 2) on the to-server stream, and the probe then confirms the NFS
program number, version and procedure. So NFS on a non-default port is parsed
and logged, and ``alert nfs`` rules apply to it, where 8.x left such a flow
undetected. Traffic to the other ONC RPC services (mountd, rpcbind, nlockmgr) is
not claimed: their calls carry a different program number, and replies carry
none, which is why the probe is to-server only.

Known limitation: NFSv2 over TCP is not protocol-detected. The RFCs permit
NFSv2 to run over a TCP transport (record-marked ONC RPC), and the parser
handles such traffic correctly when it reaches the parser (for example via a
port-based or forced protocol match), but the protocol probe only accepts
NFSv3 and NFSv4 on TCP. This is a deliberate limitation: NFSv2 over TCP is
exceedingly rare in practice -- virtually all real-world NFSv2 traffic is
carried over UDP, where it is detected and parsed normally.

Rule Keywords
^^^^^^^^^^^^^

NFS rule keywords are documented in the rule guide :ref:`NFS Rule Keywords`.

In addition to these specific keywords, file transactions can be inspected with
the :ref:`File Rule Keywords`.


Further Reading
~~~~~~~~~~~~~~~

Expand Down
65 changes: 65 additions & 0 deletions doc/userguide/rules/nfs-keywords.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _NFS Rule Keywords:

NFS Keywords
============

Expand Down Expand Up @@ -37,3 +39,66 @@ Unlike the other keywords, the usage of range is inclusive.
Syntax::

nfs_procedure:(mode) <number or string>

nfs.name
--------

Match on the name the NFS transaction carries, when known. The name is
learned from LOOKUP and friends and associated with the file handle, so
READ and WRITE transactions on that handle carry it too. It is the
name the event reports as ``nfs.filename``: the buffer holds the raw bytes,
the event holds them lossily converted to UTF-8, so for a name that is not
valid UTF-8 they differ. It is a name component, not a path - NFS switches
to the handle once the directory walk is done.

Examples::

nfs.name; content:"secret.txt"; endswith;
nfs.name; content:".crypter"; nocase;

``nfs.name`` is a 'sticky buffer'.

``nfs.name`` can be used as ``fast_pattern``.

For a READ or WRITE that opens a file, the generic :doc:`file-keywords`
keyword ``file.name`` matches the same bytes: it asks the file engine for
the name recorded at open. Prefer ``file.name`` there. ``nfs.name`` is the
wider of the two: it also covers the requests that name a file without
transferring it (LOOKUP, CREATE, REMOVE, RENAME, READDIR, READLINK, LINK,
SYMLINK, MKNOD, SETATTR), and the handle-only ones carry whatever the
handle map resolved for that handle.

Two limits to know about. A RENAME carries its source name in the
transaction and the target in ``rename.to`` of the event, so the buffer
holds the source only. And a COMMIT makes no transaction of its own - it
completes the WRITE it refers to - so there is nothing there for
``nfs.name`` to match; match the WRITE instead.
Comment on lines +71 to +75

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As these are limitations, I it's better to have something like a note that stands out more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree, these are not so important that they should draw your attention before anything else


Signature Example:

.. container:: example-rule

alert nfs any any -> any any (msg:"NFS nfs.name usage"; \
:example-rule-options:`nfs.name; content:"secret.txt";` \
classtype:bad-unknown; sid:1; rev:1;)

nfs.handle
----------

This keyword allows to match the file handle of the NFS transaction,
when known. File handles are binary and server-specific.

``nfs.handle`` is a 'sticky buffer': use :ref:`content` with hex escapes
to match on it.

``nfs.handle`` can be used as ``fast_pattern``. The handle is the raw
file handle; the NFS event logs a hash of it as ``nfs.hhash``, which is not
what this buffer matches.

Signature Example:

.. container:: example-rule

alert nfs any any -> any any (msg:"NFS nfs.handle usage"; \
:example-rule-options:`nfs.handle; content:"|01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10|";` \
classtype:bad-unknown; sid:1; rev:1;)
2 changes: 2 additions & 0 deletions doc/userguide/rules/payload-keywords.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Payload Keywords
Payload keywords inspect the content of the payload of a packet or
stream.

.. _content:

content
-------

Expand Down
4 changes: 4 additions & 0 deletions doc/userguide/rules/smb-keywords.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ SMB Keywords

SMB keywords used in both SMB1 and SMB2 protocols.

SMB registers no name buffer of its own, because its names always come with a
file, a pipe (``smb.named_pipe``) or a share (``smb.share``); SMB file names
are matched with ``file.name`` (see :doc:`file-keywords`).

smb.named_pipe
--------------

Expand Down
5 changes: 5 additions & 0 deletions doc/userguide/upgrade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ Logging Changes
duplicate attribute types. See :ref:`IKE logging changes
<9.0-ike-logging-changes>`

- NFSv4 compound operations are now tracked as transactions, so an NFS
capture can produce many more ``nfs`` records than before. New fields, new
events and the WRITE status timing are covered in :ref:`NFS logging changes
<9.0-nfs-logging-changes>`

- Ethertype values (``ether.ether_type``) are now logged matching the network order value.
E.g., previously, ``ether_type`` values were logged in host order; an ethertype value of ``0xfbb7``
(network order) was logged as `47099`` (``0xb7fb``). This ethertype value will be logged as ``64439``.
Expand Down
166 changes: 166 additions & 0 deletions doc/userguide/upgrade/9.0-logging-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,169 @@ Example - Client Proposal
}
}
}

.. _9.0-nfs-logging-changes:

NFS
***

Comment on lines +144 to +149

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll come back to review this bit. It feels... quite verbose.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've worked with claude for an easier to read version of this (here 2275a94), but didn't take into account the reviews for that part on this PR. I'll go back to it and incorporate those.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem already up-to-date with the latest review iteration, in case you want to incorporate anything from it.

nfs.status is logged only when a reply carried one
==================================================

In 8.x, ``nfs.status`` was always logged and read ``OK`` by default. In an
``nfs`` record it is now left out when no reply status was seen; treat a
missing ``nfs.status`` there as "no reply status". The ``nfs`` block of an
alert and of a ``fileinfo`` record still carries ``status``, ``OK`` until a
reply status is seen. ``status_code`` follows the record rule everywhere: it
appears only once a reply status was seen.

This happens when:

* a WRITE whose last record is fully buffered is logged as the request is
parsed, before any reply;
* the reply never arrives;
* the reply is rejected at the RPC layer.

When a status is logged, it is:

* the first NFS error carried by any reply to the request, or else
* the status of the first reply that carried one.

A request split into several records can be answered more than once. If one
reply reports success and another an NFS error, the record reports the error,
whatever the order. A reply that fails at the RPC message level
(``GARBAGE_ARGS``, ``PROC_UNAVAIL`` and the like) carries no NFS status, so it
does not override one. ``rpc.status`` behaves the other way round: once a reply
to the request was denied, the record reports ``DENIED`` there, whatever order
the replies arrived in.

Special cases:

* A READ that stops before EOF is logged with the status of the replies that
did arrive.
* An UNSTABLE WRITE closed by a COMMIT reports its own reply status only if
that reply arrived before the COMMIT. The COMMIT closes the record, so a
later reply is not logged.

The ``fileinfo`` record for such a file is written when the file closes. It
describes the file, not an RPC reply:

* its ``status`` reads ``OK`` unless an error reply arrived before the file
closed;
* its ``status_code`` appears only once a reply status was seen.

More NFSv4 operations are logged
================================

A compound carrying any of the operations below now produces an ``nfs`` record:

- CLOSE,
- CREATE_SESSION,
- DELEGRETURN,
- DESTROY_CLIENTID,
- DESTROY_SESSION,
- EXCHANGE_ID,
- GETDEVINFO,
- LAYOUTGET,
- LAYOUTRETURN,
- RECLAIM_COMPLETE,
- SECINFO_NO_NAME

In 8.x it produced none.

Unchanged:

* Each compound still yields one transaction, for its main operation. READ
and WRITE also get a file transaction.
* A compound of only PUTFH and GETATTR yields no transaction.
* A GETATTR after another operation stays part of that operation.

Rules that use NFS transaction keywords (``nfs_version``, ``nfs_procedure``,
the file keywords) can now alert on these compounds too. They still alert
once per compound, not once per operation. To match a single operation, add
``nfs_procedure``.

NFS over TCP is detected on any port
====================================

NFS is no longer detected only on the configured ports. Suricata now
recognizes NFS calls on the to-server stream by the ONC RPC call header and
program number.

NFS on an unusual port now:

* gets ``app_proto: nfs``;
* produces ``nfs`` records;
* can match ``alert nfs`` rules.

In 8.x such flows went undetected. Other ONC RPC services (mountd, rpcbind,
nlockmgr) use a different program number and are not claimed.

Size limits on logged records
=============================

RFC 1813 (section 3.2) sets no length limit on NFSv3 names, so a name can be
as large as the reassembly buffer. The logger now caps what it writes:

* Each string field: 8 KiB of the value, before JSON escaping. A shortened
value ends with ``[truncated N additional bytes]``; a field of control bytes
can take up to 48 KiB once each is escaped.
* Each ``nfs`` record: 128 KiB. ``nfs.truncated`` (or ``rpc.truncated``) is
set when a value was shortened or the record limit was reached. Each field
left out at the limit gets a ``<field>_truncated`` key.

NFSv2 names are limited to 255 bytes (RFC 1094). Only these are checked when
parsing: a longer one raises ``malformed_data`` but is still available to
``nfs.name`` and ``nfs.filename``.

New fields and events
=====================

New fields in ``nfs`` records:

* ``nfs.minorversion`` and ``nfs.client_id``: NFSv4.1 session identity.
* ``nfs.status_code``: the numeric value of ``nfs.status``. Like
``nfs.status``, it is logged only once a reply status was seen. A
transaction closed before its reply never shows ``0`` (OK).

NFSv4 status names now come from the v4 table instead of the v3 table.

New events, with default rules in ``rules/nfs-events.rules``:

* ``fsinfo_too_large``
* ``record_overflow``
* ``file_overlap``
* ``internal_error``
* the direction sanity events
* ``malformed_data``, for corrupted UDP records

The same file also adds default rules for eight events that 8.x raised
without one: ``non_existing_version``, ``read_queue_size_exceeded``,
``read_queue_cnt_exceeded``, ``write_queue_size_exceeded``,
``write_queue_cnt_exceeded``, ``write_request_too_large``,
``read_response_too_large`` and ``truncated_file_data``. A configuration that
loads this file sees alerts for them after the upgrade.

Alerts for ``record_overflow`` and the direction events have no ``nfs`` or
``rpc`` block. These transactions stand for an event, not a call, so there
is no procedure, status or valid transaction id to report.

Overlapping file data
=====================

``file_overlap`` flags a READ or WRITE chunk that starts before the end of
the data already tracked for the file. When a flow overlaps, the two sizes
differ:

* the ``nfs`` record's ``size`` counts the bytes the calls carried, so the
overlap is counted twice;
* ``fileinfo`` reports what the file tracker kept, which is the smaller
value.

Read both together.

New keywords
============

``nfs.name`` and ``nfs.handle`` match the file name and file handle of NFS
records.
Loading
Loading