Repository navigation
system/vncviewer: scan security types in chunks to prevent stack overflow - #3949
Merged
xiaoxiang781216 merged 1 commit intoNov 1, 2026
Merged
Conversation
Swatantra-66
force-pushed
the
vncviewer/security-types-bound
branch
from
October 30, 2026 21:27
f527ab3 to
4eae928
Compare
…flow During the RFB security handshake, the server sends a 1-byte count of supported security types (num_types, up to 255). rfb_negotiate_security() previously passed num_types directly to rfb_recv_exact() into a fixed 16-byte stack array types[16], allowing a malicious server or network attacker to overflow the stack buffer by up to 239 bytes before authentication. Rather than truncating the list or rejecting counts greater than 16, receive and scan the security types in chunks of up to sizeof(types). This inspects all server-offered security types without unbounded stack growth. If RFB_SEC_NONE is found, any remaining unread types are drained via rfb_discard_exact() to keep the stream synchronized. Fixes apache#3942. Assisted-by: Google Gemini Signed-off-by: Swatantra Yadav <[email protected]>
Swatantra-66
force-pushed
the
vncviewer/security-types-bound
branch
from
October 31, 2026 09:07
4eae928 to
6222975
Compare
acassis
approved these changes
Oct 31, 2026
xiaoxiang781216
approved these changes
Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3942 by bounding stack usage when reading security types during the RFB handshake.
During the RFB 3.7+ security handshake,
rfb_negotiate_security()received the 1-byte server-supplied countnum_types(1..255) and calledrfb_recv_exact(sockfd, types, num_types)into a fixed 16-byte stack buffertypes[16]. A malicious or malfunctioning server could send up to 255 bytes, causing an unauthenticated 239-byte stack buffer overflow.This fix:
sizeof(types)(16 bytes) at a time, preventing stack buffer overflow regardless ofnum_types.None>VNC Auth).Noneis selected, drains any remaining types viarfb_discard_exact(sockfd, remaining)to keep the RFB stream synchronized.Impact
vncviewer.Testing
nuttx/tools/checkpatch.sh(0 warnings, 0 errors).num_typesis smaller than, equal to, and larger thansizeof(types).