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
-sftpand 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
-sftpin 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.

