Skip to content

Harden password and keyboard-interactive auth - #1366

Open
ejohnstown wants to merge 3 commits into
wolfSSL:masterfrom
ejohnstown:userauth-hardening
Open

ejohnstown wants to merge 3 commits into
wolfSSL:masterfrom
ejohnstown:userauth-hardening

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

Three changes keep userauth secrets from leaking through the transport
or through timing.

  • the server refuses password and keyboard-interactive auth over the
    none cipher
  • the client pads password and INFO_RESPONSE packets to 64 bytes
  • wolfsshd holds a failed attempt to a per-user minimum time, modeled
    on OpenSSH sshd

Issue: F-10578, F-13390, F-11938

Copilot AI balanced review requested due to automatic review settings November 2, 2026 18:56

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.

🟡 Changes recommended

Keyboard-interactive authentication responses can still reach the authentication callback in cleartext after a rekey to none, requiring transport checks in both directions and a regression test for this sequence.

1 open issue
What changed in this PR

This PR hardens wolfSSH authentication against cleartext secret handling, packet-length disclosure, and timing differences in wolfsshd failures.

Changes:

  • Rejects password and keyboard-interactive requests when either transport direction negotiates none.
  • Pads client password and keyboard-interactive response packets to 64-byte boundaries.
  • Adds per-user minimum failure delays in wolfsshd, with regression and unit coverage.
File Description
wolfssh/​internal.h Tracks negotiated none ciphers in both directions.
tests/​unit.c Tests secret-auth refusal over cleartext transports.
tests/​regress.c Checks secret-packet padding across transport modes.
src/​internal.c Adds cleartext-auth restrictions and secret-packet padding.
apps/​wolfsshd/​test/​test_configuration.c Tests failure-delay calculation and enforcement.
apps/​wolfsshd/​auth.h Declares delay helpers and the test sleep hook.
apps/​wolfsshd/​auth.c Implements keyed per-user delays for failed authentication.

Review effort: Balanced

Comment thread src/internal.c Resolved
With WOLFSSH_ALLOW_NONE_CIPHER, a server whose NEWKEYS installed the
none cipher in either direction answers password and
keyboard-interactive requests, and an INFO_RESPONSE after a rekey to
none, with USERAUTH_FAILURE before the userauth callback sees a secret,
and leaves both methods out of the method list.

- DoNewKeys() and SendNewKeys() record a none cipher per direction
- a refused request or response clears authId, so a later INFO_RESPONSE
  is rejected
- unit tests drive both methods with each direction cleartext, and a
  rekey to none with a prompt outstanding

Issue: F-10578
The client pads a password USERAUTH_REQUEST and a keyboard-interactive
INFO_RESPONSE up to a multiple of 64 bytes, as OpenSSH does, so the
packet length no longer tracks the secret's length to the cipher block.

- BundlePacketPad() adds whole blocks of padding up to a bucket
- regress test checks 1 to 64 byte secrets over the none cipher,
  AES-CTR with HMAC, and AES-GCM

Issue: F-13390
DefaultUserAuth() holds a failed attempt to a per-user minimum, modeled
on OpenSSH sshd: 5 ms plus up to 4.29 ms from a keyed hash of the
username, doubled while the time already spent exceeds it, and skipped
past 5 s. It sleeps and rechecks until the minimum has passed. The
library itself stays non-blocking.

- wolfSSHD_AuthInit() draws the per-daemon key before any fork
- the hash is SHA-256, else SHA-512 or SHA-384; with none, the floor
- Windows times the wait with QueryPerformanceCounter
- tests for the delay range, the doubling, an early-waking sleep, and
  a failing request

Issue: F-11938

@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 #1366

Scan targets checked: wolfssh-src, wolfssh-bugs
Not reviewed (no scan target covers them): apps/wolfsshd/auth.h
Coverage: 2 of 6 in-scope changed file(s) opened by the reviewer; not opened: apps/wolfsshd/test/test_configuration.c, tests/regress.c, tests/unit.c, wolfssh/internal.h

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

@ejohnstown
ejohnstown requested review from wolfSSL-Bot and removed request for wolfSSL-Bot November 2, 2026 21:14
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