wolfsshd: fix peer-controlled over-read in Windows pseudo-console resize#1005
Open
yosuke-wolfssl wants to merge 2 commits into
Open
wolfsshd: fix peer-controlled over-read in Windows pseudo-console resize#1005yosuke-wolfssl wants to merge 2 commits into
yosuke-wolfssl wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a Windows-specific information disclosure / crash risk in wolfsshd by ensuring the initial pseudo-console resize VT escape sequence cannot cause a peer-controlled over-read of a stack buffer when written via WriteFile.
Changes:
- Enlarges the stack buffer used to build the initial
ESC[8;...tresize sequence for ConPTY. - Switches formatting to
WSNPRINTFwith%ufor the peer-suppliedword32dimensions. - Adds return-value clamping logic intended to prevent
WriteFilefrom using an out-of-range byte count.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1005
Scan targets checked: none
Failed targets: wolfssh-bugs, wolfssh-src
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.
Description
In the Windows variant of SHELL_Subsystem, the initial pty-resize VT escape sequence was formatted into a 20-byte stack buffer and the snprintf return value was passed unchecked to WriteFile.
heightRows and widthChar are word32 values supplied by the authenticated peer via pty-req. For large decimal dimensions, C99 snprintf returns the length it would have written (>20), so WriteFile reads past the end of the 20-byte stack buffer, leaking adjacent stack contents into the pseudo-console fed to the child shell. With legacy MSVC _snprintf truncation semantics (returns -1), the cast to DWORD becomes ~4 GiB and can crash with an access violation.
Changes
Addressed by f_4581