Report allocated port in tcpip-forward success reply#1009
Open
yosuke-wolfssl wants to merge 1 commit into
Open
Report allocated port in tcpip-forward success reply#1009yosuke-wolfssl wants to merge 1 commit into
yosuke-wolfssl wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates wolfSSH’s TCP port forwarding (RFC 4254 §7.1) handling so that when a client requests tcpip-forward with bind port 0, the server can return the actually allocated port in SSH_MSG_REQUEST_SUCCESS.
Changes:
- Change
WS_CallbackFwdport parameter toword32*(in/out) so callbacks can write back an allocated port. - Plumb the port pointer through global-request forwarding and channel-open forwarding call sites.
- Update example forwarding callbacks to discover OS-assigned ports via
getsockname(), and add a regression test ensuring the success reply carries the allocated port.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
wolfssh/ssh.h |
Changes forwarding callback typedef to accept an in/out port pointer and documents the port-0 behavior. |
src/internal.c |
Passes port by pointer into forwarding callback so the selected port can be echoed in request-success. |
src/ssh.c |
Updates forwarding-related callback invocation to pass a port pointer. |
examples/echoserver/echoserver.c |
Updates example forwarding callback to dereference port pointer and use getsockname() for port-0 binds. |
ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/echoserver.c |
Same forwarding callback updates for the ESP-IDF example. |
tests/regress.c |
Adds a regression test validating that port-0 requests return an allocated port in the success reply. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9f11df7 to
6c972e6
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1009
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
When an SSH client sends a tcpip-forward global request with bind port 0, RFC 4254 §7.1 requires the server to allocate an unprivileged port and return the actual port in the SSH_MSG_REQUEST_SUCCESS reply. wolfSSH passed the port to the forwarding callback by value, so the remote-setup handler had no way to communicate the chosen port back. SendGlobalRequestFwdSuccess() then echoed the requested 0, which is invalid per spec.
Addressed by f_5573.
Changes
API impact (breaking)
This changes the public WS_CallbackFwd typedef in wolfssh/ssh.h:
Any external application implementing a forwarding callback must update its 4th parameter to word32* (and dereference it). This was a deliberate choice to make RFC-compliant behavior the default rather than adding a separate _ex variant.