Re: [PATCH] SUNRPC: restrict integrity replies to authenticated payload
From: Chuck Lever
Date: Sun Sep 20 2026 - 14:26:10 EST
On 9/19/26 5:20 PM, Jérémy Jean wrote:
> Decode the checksum length into mic.len and truncate the decode
> stream after MIC verification so only the authenticated payload
> remains visible.
Your analysis holds, and I don't see a relevant fix already queued
up.
> + if (xdr_stream_remaining(xdr) < len - XDR_UNIT)
> + goto unwrap_failed;
This branch cannot be taken. xdr_buf_subsegment() returns -1 unless
offset + len <= rcv_buf->len, and @offset was computed as
rcv_buf->len - xdr_stream_remaining(xdr) just above. Decoding the
sequence number then drops xdr_stream_remaining() by XDR_UNIT, so
here it is at least len - XDR_UNIT. Nothing in between disturbs
that: xdr_decode_word(), read_bytes_from_xdr_buf(), and
gss_verify_mic() only read. The new "len < XDR_UNIT" test already
keeps the subtraction from wrapping, which is the other input this
check could have caught.
One observation that needs no change: gss_krb5_verify_mic_v2()
covers only cksum_len bytes of the token, so an oversized checksum
length word verifies too, and mic.len still feeds
gss_update_rslack(). rcv_buf->len bounds the value, so an attacker
gains nothing but a poor slack estimate.
The rest LGTM.
net/sunrpc/auth_gss/auth_gss.c is NFS client code, so this one goes
through Trond and Anna rather than the NFSD tree.
--
Chuck Lever (Come to NFS bake-a-thon! https://nfsv4bat.org)