Описание
goshs SFTP authentication bypass via empty password (incomplete fix of CVE-2026-40884)
Summary
Start goshs v2.1.3 with -b 'admin:' -sftp. No -fkf. SFTP accepts connections without password. CVE-2026-40884 blocks the empty-username variant (-b ':pass'). The empty-password variant bypasses that fix.
CVE-2026-40884
CVE-2026-40884 (GHSA-c29w-qq4m-2gcv, Apr 13 2026) reported the empty-username case: -b ':pass' with -sftp. sftpserver.go:85 uses &&:
Empty username → Username != "" false → PasswordHandler nil. No -fkf means PublicKeyHandler also nil. gliderlabs/ssh sees all handlers nil and sets NoClientAuth = true. Unauthenticated access.
Patrickhener fixed it with a sanity check at sanity/checks.go:114-118:
HasPrefix(":") catches empty username. It does not catch empty password.
Empty Password Bypass
Same && at sftpserver.go:85. Same nil handler. Different input:
Username = "admin",Password = ""Username != "" && Password != ""→ false. Password is empty.PasswordHandlernot set. No-fkf→PublicKeyHandlernot set.- gliderlabs/ssh →
NoClientAuth = true.
CVE-2026-40884 patched the symptom (empty username) with input validation. Root cause (&&) stayed in the code. v2.1.3 still has it. That makes any unanticipated input format exploitable.
PoC
Root Cause
&& blocks PasswordHandler when either field is empty. || installs it when either field is set.
Incomplete Fix
Patrickhener added HasPrefix(":") at sanity/checks.go:116. Two gaps remain:
&&still atsftpserver.go:85in v2.1.3- No
HasSuffix(":")check for empty password
Impact
- Unauthenticated SFTP file access (read, write, delete, rename)
- Same impact as CVE-2026-40884 via a different input
- Exploitable with
-b 'user:'and no-fkf
Affected
All goshs versions including v2.1.3. CVE-2026-40884 fix does not cover this variant.
Recommended Fix
&&→||atsftpserver/sftpserver.go:85HasSuffix(":")check atsanity/checks.go- Shared auth handler setup for HTTP and SFTP code paths
Пакеты
github.com/patrickhener/goshs/v2
= 2.1.3
2.1.4
goshs.de/goshs/v2
= 2.1.3
2.1.4
Связанные уязвимости
goshs is a feature-rich single-binary file server for red teamers and developers. From 2.1.3 until 2.1.4, the sftpserver/sftpserver.go password handler used Username != "" && Password != "", so running goshs with -b 'admin:' -sftp and no -fkf left both SFTP authentication handlers unset and allowed unauthenticated file access. This issue is fixed in version 2.1.4.