Skip to content

wolfsshd: apply ForceCommand to SFTP and SCP - #1344

Open
ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:force-cmd-bypass
Open

ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:force-cmd-bypass

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

wolfsshd applied a configured ForceCommand only to shell and exec
sessions. It now confines SFTP and SCP too, as sshd_config(5) describes,
and refuses a config line too long for its buffer.

  • Any ForceCommand other than a bare "internal-sftp" denies the SFTP
    subsystem, and any ForceCommand denies SCP. Options after
    internal-sftp are refused, since none is applied.
  • Configs that relied on SFTP alongside another ForceCommand lose it.
  • Config lines up to 1023 bytes load; a longer one fails the load
    instead of taking effect cut short.

Issue: ZD-22623

A ForceCommand other than a bare "internal-sftp" now denies the SFTP
subsystem, and any ForceCommand denies SCP, as sshd_config(5) describes
it: a forced command applies to shell, command, and subsystem execution.
The session dispatch checks the configured command alongside a
certificate's, so either one on its own confines the session.

- the subsystem arm and both SCP arms consult the configured
  ForceCommand, not only a certificate's force-command
- "internal-sftp" followed by options denies SFTP, since no option is
  applied, while the shell still refuses it as "internal-sftp"
- every site testing for "internal-sftp" now shares one predicate
- root's transfer refusal no longer points at ForceCommand internal-sftp,
  which does not permit SCP
- tests require a ForceCommand to deny SFTP and SCP, read the daemon's
  decisions from its log, and pair a configured internal-sftp with a cert

Issue: ZD-22623
ConfigLoad() reports a line too long for its buffer and fails the load.
A cut line used to take effect with whatever fitted, since what is left
of it is read as a line of its own and a leftover of two bytes or less
is skipped as blank. The buffer is 1024 bytes now, so a long path or
forced command still loads.

- one byte is read past a full buffer, so a line that ends exactly
  there, at a newline or the end of the file, is not taken for a cut one
- the size is WOLFSSHD_MAX_LINE_SIZE in configuration.h, shared with
  the test
- test_configuration covers a long line, lines that exactly fill the
  buffer, and a line cut to leave a blank-looking remainder

Issue: ZD-22623
Copilot AI balanced review requested due to automatic review settings October 28, 2026 18:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1344

Scan targets checked: wolfssh-src, wolfssh-bugs
Not reviewed (no scan target covers them): apps/wolfsshd/configuration.h, apps/wolfsshd/test/sshd_forcedcmd_test.sh, apps/wolfsshd/test/sshd_ossh_cert_test.sh
Coverage: 2 of 3 in-scope changed file(s) opened by the reviewer; not opened: apps/wolfsshd/test/test_configuration.c

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants