-
Notifications
You must be signed in to change notification settings - Fork 121
wolfsshd: refuse sessions it cannot serve #1237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ejohnstown
wants to merge
2
commits into
wolfSSL:master
Choose a base branch
from
ejohnstown:ccb-phase2-7
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| #!/bin/sh | ||
|
|
||
| # sshd local test: a subsystem the daemon does not serve is refused at the | ||
| # request, so the client sees CHANNEL_FAILURE rather than a session that | ||
| # is accepted and then dropped. Uses the system OpenSSH client, since the | ||
| # in-tree clients only ask for sftp. | ||
|
|
||
| # Not named PWD: the shell rewrites that variable on every cd, so a saved | ||
| # copy would not survive the cd to the repository root below. | ||
| TESTDIR=`pwd` | ||
| cd ../../.. | ||
|
|
||
| USER=`whoami` | ||
| PRIVATE_KEY="./keys/hansel-key-ecc.pem" | ||
|
|
||
| if [ -z "$1" ] || [ -z "$2" ]; then | ||
| echo "expecting host and port as arguments" | ||
| echo "./sshd_bad_subsystem_test.sh 127.0.0.1 22222" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! command -v ssh >/dev/null 2>&1; then | ||
| echo "OpenSSH client not found, skipping" | ||
| exit 77 | ||
| fi | ||
|
|
||
| # OpenSSH refuses a key file other users can read. | ||
| KEY=`mktemp` | ||
| cat "$PRIVATE_KEY" > "$KEY" | ||
| chmod 600 "$KEY" | ||
| OUT=`mktemp` | ||
|
|
||
| ssh_to_sshd() { | ||
| ssh -p "$2" -i "$KEY" -o IdentitiesOnly=yes -o StrictHostKeyChecking=no \ | ||
| -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=publickey \ | ||
| -o BatchMode=yes -o ConnectTimeout=5 "$USER@$1" "$3" "$4" | ||
| } | ||
|
|
||
| # Control: the same client and key can run a command. | ||
| ssh_to_sshd "$1" "$2" "echo ok" > "$OUT" 2>&1 | ||
| RESULT=$? | ||
| if [ "$RESULT" != "0" ] || ! grep -q "^ok" "$OUT"; then | ||
| echo "Control exec through OpenSSH failed ($RESULT):" | ||
| cat "$OUT" | ||
| rm -f "$KEY" "$OUT" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # A subsystem nothing serves: the client reports the refusal and exits | ||
| # non-zero. | ||
| ssh_to_sshd "$1" "$2" -s no-such-subsystem > "$OUT" 2>&1 | ||
| RESULT=$? | ||
| if [ "$RESULT" = "0" ]; then | ||
| echo "Expecting the unknown subsystem request to fail" | ||
| cat "$OUT" | ||
| rm -f "$KEY" "$OUT" | ||
| exit 1 | ||
| fi | ||
| if ! grep -q "subsystem request failed" "$OUT"; then | ||
| echo "Expecting the client to report the refused subsystem request:" | ||
| cat "$OUT" | ||
| rm -f "$KEY" "$OUT" | ||
| exit 1 | ||
| fi | ||
|
|
||
| rm -f "$KEY" "$OUT" | ||
| cd "$TESTDIR" | ||
| exit 0 |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SCP prefix is granted as a valid exec request · Logic errors
SessionRequestCb()grants every exec command starting withscp, so an SCP-only daemon accepts names such asscpbackupand routes them into SCP handling. Known #11664 is the downstream classifier; this is the new daemon policy gate.Suggested fix: Require a length-aware
scptoken boundary before granting, and reject embedded-NUL or otherwise unparseable SCP commands.Basis: OpenBSD scp(1) SYNOPSIS defines
scpas the command name followed by options and operands, not as a prefix of another command name.