In the Linux kernel, the following vulnerability has been resolved:
nfsd: preflight SEQUENCE replies before accepting a slot
nfsd4_sequence() narrows the reply buffer to the session's cached
reply limit before it accepts the slot seqid. A client may negotiate
ca_maxresponsesize_cached down to NFSD_MIN_HDR_SEQ_SZ, and
nfsd4_alloc_slot() then gives every slot a zero-length sl_data[]. A
COMPOUND tag can fill that narrowed buffer until it holds the
SEQUENCE opcode but not the status word that follows.
nfsd4_encode_operation() returns without running
nfsd4_encode_sequence(), so cstate.data_offset stays zero. It leaves
op->status at nfs_ok as well, so the COMPOUND is treated as having
succeeded.
nfsd4_store_cache_entry() declines to cache a lone SEQUENCE that
returned an error. That test reads the status the operation
reported, so it passes here. The copy starts at offset zero and
takes the whole reply, RPC and COMPOUND headers included, into the
zero-length sl_data[]. The COMPOUND tag is copied along with it, so
the client picks most of the bytes written past the end of the slot:
BUG: KASAN: slab-out-of-bounds in read_bytes_from_xdr_buf+0x1bc/0x390
Write of size 80 at addr ffff888003a549cd by task kunit_try_catch/24
__asan_memcpy+0x38/0x60
read_bytes_from_xdr_buf+0x1bc/0x390
nfsd4_sequence_done+0x5b0/0x810
nfs4svc_encode_compoundres+0x1bf/0x240
Check that the fixed-size SEQUENCE result, plus room for a following
operation's error status, fits the negotiated limit before narrowing
the buffer and consuming the slot seqid. The slot and its reply
cache are left unchanged, as RFC 8881 Section 2.10.6.1.2 requires of
an error returned from SEQUENCE.
CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
CVSS Score: 9.8
AV:N - svc_tcp_recvfrom delivers an NFSv4.1 TCP RPC to svc_process, nfsd_dispatch, and nfsd4_proc_compound, which calls nfsd4_sequence. The client supplies ca_maxresponsesize_cached in CREATE_SESSION (nfsd4_decode_channel_attrs4) and the COMPOUND tag plus SEQUENCE sa_cachethis (nfsd4_decode_sequence); that reply is what nfsd4_store_cache_entry copies past sl_data.
AC:L - The client sets ca_maxresponsesize_cached to NFSD_MIN_HDR_SEQ_SZ and a COMPOUND tag that leaves room for the SEQUENCE opcode but not its status word. nfsd4_encode_operation then returns with op->status still nfs_ok and cstate.data_offset still 0, so nfsd4_store_cache_entry copies the reply on that COMPOUND with no further timing or peer state.
PR:N - EXCHANGE_ID with SP4_NONE, CREATE_SESSION, and SEQUENCE are ALLOWED_WITHOUT_FH and never call fh_verify or check_nfsd_access. svcauth_unix_accept copies the AUTH_SYS uid from the RPC without checking it, and svcauth_null_accept accepts AUTH_NULL; svcauth_unix_set_client only maps the source address to an export.
UI:N - The attacker opens the TCP connection and sends EXCHANGE_ID, CREATE_SESSION, and the SEQUENCE COMPOUND itself. No local user must mount a share or open a file.
S:U - The overflow corrupts the nfsd4_slot allocation in the kernel that is running nfsd. It does not cross a guest-to-host or IOMMU boundary.
C:H - nfsd4_store_cache_entry leaves data_offset at 0, sets sl_datalen to the whole reply, and copies it into a zero-length sl_data[]. nfsd4_replay_cache_entry then xdr-encodes those sl_datalen bytes from sl_data into the RPC reply, so the read extends into the adjacent slab object and is returned to the client.
I:H - read_bytes_from_xdr_buf writes the reply, including the client-chosen COMPOUND tag, at slot->sl_data. With ca_maxresponsesize_cached equal to NFSD_MIN_HDR_SEQ_SZ, nfsd4_alloc_slot makes sl_data zero-length, so the 80-byte copy runs off the kmalloc'd nfsd4_slot into the next object of that slab.
A:H - The write is performed from nfs4svc_encode_compoundres via nfsd4_sequence_done on the triggering SEQUENCE. KASAN reports it as a slab-out-of-bounds write in read_bytes_from_xdr_buf, which oopses the nfsd thread and can panic the host.
| Attack Vector |
Network |
Scope |
Unchanged |
| Attack Complexity |
Low |
Confidentiality Impact |
High |
| Privileges Required |
None |
Integrity Impact |
High |
| User Interaction |
None |
Availability Impact |
High |
AV:N - svc_tcp_recvfrom delivers an NFSv4.1 TCP RPC to svc_process, nfsd_dispatch, and nfsd4_proc_compound, which calls nfsd4_sequence. The client supplies ca_maxresponsesize_cached in CREATE_SESSION (nfsd4_decode_channel_attrs4) and the COMPOUND tag plus SEQUENCE sa_cachethis (nfsd4_decode_sequence); that reply is what nfsd4_store_cache_entry copies past sl_data.
AC:L - The client sets ca_maxresponsesize_cached to NFSD_MIN_HDR_SEQ_SZ and a COMPOUND tag that leaves room for the SEQUENCE opcode but not its status word. nfsd4_encode_operation then returns with op->status still nfs_ok and cstate.data_offset still 0, so nfsd4_store_cache_entry copies the reply on that COMPOUND with no further timing or peer state.
PR:N - EXCHANGE_ID with SP4_NONE, CREATE_SESSION, and SEQUENCE are ALLOWED_WITHOUT_FH and never call fh_verify or check_nfsd_access. svcauth_unix_accept copies the AUTH_SYS uid from the RPC without checking it, and svcauth_null_accept accepts AUTH_NULL; svcauth_unix_set_client only maps the source address to an export.
UI:N - The attacker opens the TCP connection and sends EXCHANGE_ID, CREATE_SESSION, and the SEQUENCE COMPOUND itself. No local user must mount a share or open a file.
S:U - The overflow corrupts the nfsd4_slot allocation in the kernel that is running nfsd. It does not cross a guest-to-host or IOMMU boundary.
C:H - nfsd4_store_cache_entry leaves data_offset at 0, sets sl_datalen to the whole reply, and copies it into a zero-length sl_data[]. nfsd4_replay_cache_entry then xdr-encodes those sl_datalen bytes from sl_data into the RPC reply, so the read extends into the adjacent slab object and is returned to the client.
I:H - read_bytes_from_xdr_buf writes the reply, including the client-chosen COMPOUND tag, at slot->sl_data. With ca_maxresponsesize_cached equal to NFSD_MIN_HDR_SEQ_SZ, nfsd4_alloc_slot makes sl_data zero-length, so the 80-byte copy runs off the kmalloc'd nfsd4_slot into the next object of that slab.
A:H - The write is performed from nfs4svc_encode_compoundres via nfsd4_sequence_done on the triggering SEQUENCE. KASAN reports it as a slab-out-of-bounds write in read_bytes_from_xdr_buf, which oopses the nfsd thread and can panic the host.
CVSS 3.1