/

CVE-2026-40884

Severity:

CRITICAL RISK

(9.8)

Authentication Bypass in goshs SFTP Service with

CVE-2026-40884

Analyzed

Vulnerability type

Category:

Authentication Bypass

CWE:

CWE-306

Impact:

Unauthorized Access to Files over SFTP

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

goshs contains an authentication bypass in its SFTP subsystem when the empty-username basic-auth syntax is used (e.g., -b ':pass' together with -sftp).

In this configuration, goshs fails to install any SFTP password handler, allowing unauthenticated network attackers to connect to the SFTP service and access files without providing a password.

Affected context

This vulnerability arises when goshs is deployed as an SFTP server with basic authentication configured using the documented empty-username syntax.

Specifically, it affects instances started with -sftp and a basic-auth flag like -b ':pass', where the intention is to protect access with only a password.

In that mode, the HTTP/basic-auth configuration appears valid, but the SFTP layer silently lacks a password handler, leaving SFTP connections effectively unauthenticated.

Exploit preconditions

  • Attack surface: Network-accessible SFTP service exposed by goshs
  • Required access: Ability to reach the SFTP port over the network; no prior authentication is required
  • Trigger point: SFTP connection attempts to an instance started with -sftp and basic auth configured as -b ':pass' or similar empty-username syntax
  • Why exploitation is possible: The SFTP subsystem does not install any password handler for this configuration, so it treats connections as authenticated without validating credentials

Why this happens

The underlying issue is a mismatch between authentication configuration semantics and their enforcement in the SFTP subsystem.

When goshs is started with the empty-username basic-auth syntax (-b ':pass') alongside -sftp, the server accepts the configuration but does not bind an authentication handler to the SFTP layer.

This behavior maps to CWE-306: Missing Authentication for Critical Function, because a security-sensitive capability—remote file access over SFTP—is exposed without effective authentication when a specific configuration pattern is used.

Potential impact

  • Unauthenticated read access to files exposed via the goshs SFTP service
  • Unauthenticated write, modification, or deletion of files if the SFTP configuration permits it
  • Potential disclosure of sensitive data stored in directories served by SFTP
  • Use of the SFTP service as an entry point for further compromise of systems that trust the integrity of those files

General mitigation guidance

Mitigation centers on ensuring that all externally reachable services enforce explicit authentication independent of convenience configuration shortcuts.

Recommended defensive patterns include:

  • Avoiding ambiguous or special-case authentication syntaxes (such as empty usernames) for critical services like SFTP
  • Validating that each enabled protocol (HTTP, SFTP, etc.) has its own authentication checks properly wired, rather than relying on shared configuration assumptions
  • Implementing secure defaults so that, if authentication configuration is incomplete or ambiguous, the service refuses to start or disables the affected protocol
  • Restricting SFTP exposure to trusted networks and running with least-privilege accounts and minimal file system access
  • Using layered access controls such as firewalls, VPNs, and OS-level permissions in addition to application-level authentication

How teams detect issues like this

Detection typically combines configuration review with behavioral validation:

  • Reviewing startup scripts, service units, and container arguments for goshs instances that use -sftp in combination with basic-auth flags like -b ':pass' or other empty-username patterns
  • Incorporating configuration linting or policy-as-code checks that flag SFTP deployments lacking explicit credential mappings
  • Performing security testing that attempts SFTP connections without credentials to verify that authentication is actually enforced
  • Using infrastructure and network monitoring to detect anonymous SFTP sessions, unusual file access patterns, or SFTP traffic originating from untrusted sources

Static analysis is less applicable here because this is primarily a configuration-driven authentication gap, but automated configuration scanners and CI checks can help surface risky patterns before deployment.

Sources

SourceLink
github.comgithub.com/patrickhener/goshs/security/advisories/GHSA-c29w-qq4m-2gcv

Frequently asked

questions

Yes. If the goshs SFTP service is reachable over the network and is started with -sftp plus an empty-username basic-auth configuration like -b ':pass', an attacker can connect remotely without a password.

No. The core issue is that no SFTP password handler is installed for this configuration, so SFTP connections are treated as authenticated without requiring any credentials.

Ensure that every enabled protocol—especially SFTP—has explicit, enforced authentication configured, and fail closed when authentication configuration is incomplete or ambiguous. Avoid special-case syntaxes that may not be applied consistently across subsystems.

Design authentication flows so that configuration is validated per protocol, enforce secure defaults that block startup on misconfiguration, and incorporate automated checks that flag high-risk authentication patterns. Regularly test externally exposed services with unauthenticated probes to confirm that access controls operate as intended.

Find out what's already
exploitable in your codebase.