Skip to content

Mitigate timing oracle using dummy hash cache - #1116

Open
stenslae wants to merge 1 commit into
wolfSSL:masterfrom
stenslae:pr-timing-oracle
Open

Mitigate timing oracle using dummy hash cache#1116
stenslae wants to merge 1 commit into
wolfSSL:masterfrom
stenslae:pr-timing-oracle

Conversation

@stenslae

@stenslae stenslae commented Jul 21, 2026

Copy link
Copy Markdown
Member

Does a fake crypt() operation when an authentication attempt is rejected early and caches hash type at SSHD startup. CI testing is added for this change.

@stenslae stenslae self-assigned this Jul 21, 2026

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

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread apps/wolfsshd/auth.h Outdated
Comment thread apps/wolfsshd/auth.h Outdated

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

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread apps/wolfsshd/auth.c
Comment thread apps/wolfsshd/auth.c
@stenslae
stenslae requested review from wolfSSL-Fenrir-bot and removed request for wolfSSL-Fenrir-bot July 23, 2026 17:11

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

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread apps/wolfsshd/auth.c
Comment thread apps/wolfsshd/auth.c

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

Scan targets checked: wolfssh-bugs, wolfssh-src

No new issues found in the changed files. ✅

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

Scan targets checked: wolfssh-bugs, wolfssh-src

No new issues found in the changed files. ✅

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

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread apps/wolfsshd/auth.h Outdated
Comment thread apps/wolfsshd/auth.h Outdated

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

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread apps/wolfsshd/auth.c Outdated
Comment thread apps/wolfsshd/auth.c Outdated

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

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread apps/wolfsshd/auth.c Outdated
Comment thread apps/wolfsshd/auth.c Outdated

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

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 3
3 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread apps/wolfsshd/auth.c Outdated
Comment thread apps/wolfsshd/test/test_configuration.c
Comment thread apps/wolfsshd/test/test_configuration.c
Comment thread apps/wolfsshd/test/test_configuration.c
Comment thread apps/wolfsshd/test/test_configuration.c
Comment thread apps/wolfsshd/auth.c Outdated

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

Scan targets checked: wolfssh-bugs, wolfssh-src

No new issues found in the changed files. ✅

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

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 3
3 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

savedGetspnam = wsshd_getspnam_cb;
wsshd_getspnam_cb = stub_getspnam_null;

wolfSSHD_SetCachedFakeHashForTest("!$6$wolfsshtestsalt$priorFakeHash$");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 [Medium] test_AuthInit_degradedMode never exercises the getspnam-failure path · Dead error handling

wolfSSHD_SetCachedFakeHashForTest(...) sets numCachedFakeHashes=1 before calling wolfSSHD_AuthInit(), but AuthInit's getspnam("root") fallback only runs if (numCachedFakeHashes == 0), so the stubbed getspnam failure is never actually invoked; the test passes vacuously.

Fix: Reset the cache to empty (not seed it) before calling AuthInit, then separately assert degraded-mode output, to actually exercise the getspnam-NULL branch.

savedGetspnam = wsshd_getspnam_cb;
wsshd_getspnam_cb = stub_getspnam_nullPassword;

wolfSSHD_SetCachedFakeHashForTest("!$6$wolfsshtestsalt$priorFakeHash$");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 [Medium] test_AuthInit_nullPasswordField never exercises the null sp_pwdp path · Dead error handling

Seeding cachedFakeHashes via wolfSSHD_SetCachedFakeHashForTest before wolfSSHD_AuthInit() makes numCachedFakeHashes non-zero, so AuthInit's root-shadow lookup (and thus stub_getspnam_nullPassword) is skipped entirely; the intended NULL-sp_pwdp handling is never run.

Fix: Clear the cache (numCachedFakeHashes==0) before calling AuthInit so the stubbed getspnam is actually reached.

Comment thread apps/wolfsshd/auth.c

#ifndef WOLFSSHD_UNIT_TEST
WFILE* f = NULL;
char line[512];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 [Low] Real shadow password hashes left unzeroed in stack buffer · Missing ForceZero

line (and the nested dump) hold the full real password hash for every parsed /etc/shadow entry, but unlike every other password-hash buffer in this file (storedHashCpy, hashBuf, pwStr), they are never WS_FORCEZERO'd before the stack frame is reused or returned.

Fix: WS_FORCEZERO the line and dump buffers (or at least the password field) before each loop iteration ends and before returning.

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