|
|
Message-ID: <e2f6e608-e47b-42e2-8926-95a00b24dac4@oracle.com>
Date: Fri, 4 Dec 2026 11:17:36 +0100
From: "Casper H.S. Dik - Senior Principal Software Engineer"
<casper.dik@...cle.com>
To: oss-security@...ts.openwall.com
Subject: Re: Sun RPC cross-request information
disclosure due to stale buffer read
Turns out there are quite a few issues adding a field to the XDR structure.
Apparently. quite a few bits of software where XDR is located as of a
structure or on the stack; this is not really an issue for 64 bit code
as there was a 32 bit hole at the end of "struct XDR"; this is not the
case in 32 code.
To fix the problem without changing the XDR structure you either need to
zero the rest of the buffer or move the data to the end of the buffer
and set the pointer to that point:
rlen &= ~3; /* align on 4 bytes */
either
/* RPC call may not fail but gets 0s */
bzero(xdrs->x_base + rlen, xdrs->x_handy - rlen);
or
/* RPC call fails when truncated. */
memmove(xdrs->x_base + xdrs->x_handy - rlen,
xdrs->x_base, rlen);
XDR_SETPOS(xdrs, xdrs->x_handy - rlen);
Attached an update of tst-udp-stale.c which changes the return of the
PROC_EXIT rpc call trying to send 200 ints which would fail under the
original proposed fix.
Casper
On 12/3/26 14:56, Casper H.S. Dik - Senior Principal Software Engineer
wrote:
> Hi Florian,
>
> Thanks for the report.
>
> Looking through the old source code archive, so like that most have
> existed in SunOS 3.0, around 1984.
>
> There are several copied in Solaris itself today and I have located
> three different version; the original version work on sockets and
> later STREAM based networking.
>
>
> Unfortunately, the proposed fix is not correct.
>
> diff --git a/sunrpc/svc_udp.c b/sunrpc/svc_udp.c
> --- a/sunrpc/svc_udp.c
> +++ b/sunrpc/svc_udp.c
> @@ -297,9 +297,15 @@ svcudp_recv (SVCXPRT *xprt, struct rpc_msg *msg)
> if (rlen < 16) /* < 4 32-bit ints? */
> return FALSE;
> xdrs->x_op = XDR_DECODE;
> - XDR_SETPOS (xdrs, 0);
> + if (!XDR_SETPOS (xdrs, 0))
> + return FALSE;
> + /* Bound decode to bytes received in this datagram. */
> + xdrs->x_private = xdrs->x_base;
> + xdrs->x_handy = (u_int) rlen;
> if (!xdr_callmsg (xdrs, msg))
> return FALSE;
>
> The xdrs structure has three important fields when it comes to
> consuming data and one implicit field:
>
> * x_base: the address of the buffer
> * x_private: the address of where we are currently are in the buffer
> * x_handy: how much we have consumed.
> * the size of the buffer; it only be derived: x_bufsize = x_handy +
> (x_private - x_base)
>
>
> By changing x_handy, we lose the the size of the buffer and we can no
> longer send a reply larger than he size of the (small) request. By
> changing the reply of PROC_EXIT in tst-udp-stale.c to be much bigger,
> we can no longer send such a reply.
>
> The bad news is that the actual use of "x_handy" is *after* we
> returned from svcudp_recv() and so need to find another way to restore
> the size of x_handy; I suggest adding a field x_bufsize to struct XDR
> and set it when we create an XDR and restore x_handy when we call
> XDR_SETPOS(xdrs, 0).
>
> Casper
>
>
View attachment "tst-udp-stale2.c" of type "text/x-csrc" (8313 bytes)
Powered by blists - more mailing lists
Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.