You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] system/vncviewer: rfb_negotiate_security never bounds the server-supplied security-type count against sizeof(types), overflowing the 16-byte stack array types[16] (pre-auth stack buffer overflow) #3942
During the RFB 3.7+ security handshake the server sends a one-byte count of security types,
followed by that many type bytes. rfb_negotiate_security() reads the count straight off the
socket into a uint8_t and uses it as the length of a recv into the fixed 16-byte stack array types[16], with no upper-bound check (only the == 0 case is special-cased).
So line 551 can recv up to 255 bytes into types[16], a 239-byte stack overflow of
attacker-chosen content that smashes the saved-register / return-address region of the frame.
There is no bound at all (not even a DEBUGASSERT) between the 1-byte read of num_types and
its use as the copy length.
This runs before authentication: vncviewer_main.c:191 rfb_connect() → vncviewer_main.c:208 rfb_handshake() → rfb_protocol.c:772 rfb_negotiate_security(). A
malicious VNC server (the server a viewer connects to) or an on-path attacker injecting into the
TCP stream triggers it on the first handshake, with no credentials.
Steps:
Build and run the vncviewer app and connect to an attacker-controlled / MITM'd VNC server.
In the RFB 3.7+ security handshake, have the server send a security-type count of e.g. 0xff
followed by that many bytes.
rfb_negotiate_security() writes those bytes past types[16].
An AddressSanitizer build reports a stack-buffer-overflow WRITE past the 16-byte types array.
Expected: a count larger than the viewer's buffer is rejected or read in capped chunks. Actual: up to 255 attacker bytes are written past types[16] on the stack, before auth.
Suggested fix: reject or clamp num_types to sizeof(types) before the recv — the viewer
only needs to know whether None / VNC Auth is offered, so it can read in capped chunks and
discard the remainder like rfb_discard_exact already does elsewhere.
Activity
system/vncviewer: scan security types in chunks to prevent stack over…
system/vncviewer: scan security types in chunks to prevent stack over…
system/vncviewer: scan security types in chunks to prevent stack over…
system/vncviewer: scan security types in chunks to prevent stack over…