CVE-2026-40876
Description
goshs is a SimpleHTTPServer written in Go. Prior to 2.0.0-beta.6, goshs contains an SFTP root escape caused by prefix-based path validation. An authenticated SFTP user can read from and write to filesystem paths outside the configured SFTP root, which breaks the intended jail boundary and can expose or modify unrelated server files. The SFTP subsystem routes requests through sftpserver/sftpserver.go into DefaultHandler.GetHandler() in sftpserver/handler.go, which forwards file operations into readFile, writeFile, listFile, and cmdFile. All of those sinks rely on sanitizePath() in sftpserver/helper.go. helper.go uses a raw string-prefix comparison, not a directory-boundary check. Because of that, if the configured root is /tmp/goshsroot, then a sibling path such as /tmp/goshsroot_evil/secret.txt incorrectly passes validation since it starts with the same byte prefix. This vulnerability is fixed in 2.0.0-beta.6.
Weakness
- CWE-22: Improper Limitation of a Pathname to a Restricted Directory
CISA SSVC decision points
| Exploitation | poc |
|---|---|
| Automatable | no |
| Technical impact | total |
| Scored | 2026-04-22 |
Timeline
- 2026-04-14GitHub advisory published (GHSA-5h6h-7rc9-3824)7 days before publication
- 2026-04-21Published by the CNA19:34 UTC
- 2026-04-22CISA SSVC decision recorded1 day after publication
Exploit and advisory records
GitHub advisory GHSA-5h6h-7rc9-3824, affected packages:
| Package | Vulnerable versions | Fixed in |
|---|---|---|
| Go github.com/patrickhener/goshs | through 1.1.4 | |
| Go github.com/patrickhener/goshs/v2 | before 2.0.0 | 2.0.0 |
Affected products
Products listed as vulnerable. Upgrade to the version under "Fixed in", or a later one.
| Product | Vulnerable versions | Fixed in |
|---|---|---|
| goshs goshs | before 2.0.0fixed in 2.0.02.0.0no fix listed | 2.0.0not listed |
References
Get more CVE data from the API.
curl 'https://api.contrastcyber.com/cve_lookup/CVE-2026-40876'curl 'https://api.contrastcyber.com/cve_risk_score/CVE-2026-40876'curl 'https://api.contrastcyber.com/cve_exploit/CVE-2026-40876'curl 'https://api.contrastcyber.com/cve_products/CVE-2026-40876'
Sources
- Vulnerability data from the National Vulnerability Database (NIST) and the CVE Program. CVE records: Copyright © 1999-2026, The MITRE Corporation, used under the CVE Program Terms of Use. CVE® is a registered trademark of The MITRE Corporation.
- CWE definitions: Copyright © 2006-2026, The MITRE Corporation, used under the CWE Terms of Use. CWE is a trademark of The MITRE Corporation.
- OWASP Top 10 categories by the OWASP Foundation (CC BY 3.0).
- EPSS scores by FIRST.org EPSS, used with attribution.
- KEV catalog and SSVC decisions by CISA.
- Advisory data from the GitHub Advisory Database through OSV.dev (CC BY 4.0).
- Exploit metadata from the Exploit Database (GPL-2.0-only, metadata only).
- Nuclei template names from nuclei-templates (MIT).