#0 __memcpy_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:265
#1 REMOTE_getbytes (xdrs=0x7ffff7e53600, buff=0x7ffff7e55664 "", bytecount=51852) at src/remote/remote.cpp:755
#2 InetXdr::x_getbytes (this=0x7ffff7e53600, buff=0x7ffff7e53690 'a' <repeats 40 times>, "\377\377\377\377", bytecount=60000) at src/remote/inet.cpp:2580
#3 xdr_opaque (xdrs=0x7ffff7e53600, p=0x7ffff7e53690 'a' <repeats 40 times>, "\377\377\377\377", len=60000) at src/common/xdr.cpp:602
#4 xdr_datum (xdrs=0x7ffff7e53600, desc=0x7fffffffc758, buffer=0x7ffff7e53690 'a' <repeats 40 times>, "\377\377\377\377") at src/common/xdr.cpp:214
#5 xdr_slice (xdrs=0x7ffff7e53600, slice=0x7ffff23c29f8, sdl=0x7ffff7e53260 "\001\006\001(\004") at src/remote/protocol.cpp:1883
#6 xdr_protocol (xdrs=0x7ffff7e53600, p=0x7ffff23c2730) at src/remote/protocol.cpp:620
#7 receive (main_port=0x7ffff7e4be40, packet=0x7ffff23c2730) at src/remote/inet.cpp:2041
#8 rem_port::receive (this=0x7ffff7e4be40, pckt=0x7ffff23c2730) at src/remote/remote.cpp:664
#9 SRVR_multi_thread (main_port=0x7ffff7e456c0, flags=2) at src/remote/server/server.cpp:1787
#10 main (argc=1, argv=0x7fffffffd9d0) at src/remote/server/os/posix/inet_server.cpp:582
Summary
An unsafe deserialization of slice packet allows any unauthenticated user to perform a buffer overflow attack, which could lead to server crash or security vulnerabilities.
Details
The main bug is in
bool_t xdr_datum(xdr_t* xdrs, const dsc* desc, UCHAR* buffer)whendescis a cstring. When parsing a cstring, compliance with the slice descriptor is not checked, i.e., if the length of the cstring exceeds the length of the descriptor (or the length of the entire slice), this cstring will be written to a buffer whose length is equal to the length of the slice, which will lead to a buffer overflow.Stacktrace when a program crashes due to buffer overflow
PoC
To reproduce the vulnerability, simply run the server and the Python script to emulate the malicious packet.
Python script
Impact
Essentially, every server is affected.