CVE-2026-40876: SFTP root escape via prefix-based path validation in goshs
Vulnerability summary
CVE-2026-40876 is a high (CVSS 8.8) Path Traversal vulnerability in goshs. EPSS estimates a 0.59% chance of exploitation in the next 30 days, higher than 47.5% of scored vulnerabilities. 1 public exploit is recorded.
Advisory lineage
Upstream 0 · Downstream 1 · Related 1Timeline
- 21-04-2026PublishedVulnerability first disclosed.
- 22-04-2026Last modifiedVulnerability information updated.
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.
CVSS metrics
5 scores · 3 sources · 2 versions- OSV · GoEcosystem advisory · calculated8.7HighCVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
- NVDNIST8.7HighCVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
- OSV · GoEcosystem advisory · calculated8.8HighCVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
EPSS trend
Probability
0.59%
Chance of exploitation in the next 30 days
Percentile
48%
Versus all other CVEs
30-day change
Increase +0.15 pp
From 0.44% on 22-09-2026
Known exploited
Compare KEV catalogsNot in the CISA KEV catalog.
Not in the ENISA CNW catalog.
Not in the CIRCL catalog.
Public exploits
1 foundGoshs
Maturity: poc
Weaknesses
CWE · root causeAffected systems
Github.com/patrickhener1 product
- goshs≤ 1.1.4 | All versions (No fix recorded)
Github.com/patrickhener/goshs1 product
- v2< 2.0.0
Goshs1 product
- goshs< 2.0.0 | 2.0.0:beta1 | 2.0.0:beta2 | 2.0.0:beta3 | 2.0.0:beta4 | 2.0.0:beta5
Patrickhener1 product
- goshs< 2.0.0-beta.6
4 vendors · 4 products
References
4 links- github.com/patrickhener/goshs/security/advisories/GHSA-5h6h-7rc9-3824X Refsource CONFIRMWEBAdvisoryExploitVendor Advisory