{"cve":"CVE-2026-40876","nvd":{"published":"2026-04-21T20:17:01.263","modified":"2026-10-26T22:10:00.163","status":"Analyzed","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_v4":{"vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":8.7},"cvss_v3":{"version":"3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8},"cwes":["CWE-22"],"references":["https://github.com/patrickhener/goshs/security/advisories/GHSA-5h6h-7rc9-3824","https://github.com/patrickhener/goshs/security/advisories/GHSA-5h6h-7rc9-3824"],"products":["goshs:goshs"],"source":"nvd","synced_at":"2026-10-26T22:26:44.656832877+00:00"},"epss":{"cve":"CVE-2026-40876","score":0.00439,"percentile":0.37919,"date":"2026-10-26"},"kev":null,"osv":[{"id":"GHSA-5h6h-7rc9-3824","url":"https://osv.dev/vulnerability/GHSA-5h6h-7rc9-3824","summary":"SFTP root escape via prefix-based path validation in goshs","modified":"2026-06-25T18:56:10.990686940Z","packages":[{"ecosystem":"Go","name":"github.com/patrickhener/goshs","purl":"pkg:golang/github.com/patrickhener/goshs","ranges":["<=1.1.4"],"fixed":[]},{"ecosystem":"Go","name":"github.com/patrickhener/goshs/v2","purl":"pkg:golang/github.com/patrickhener/goshs/v2","ranges":["<2.0.0"],"fixed":["2.0.0"]}]},{"id":"GO-2026-5146","url":"https://osv.dev/vulnerability/GO-2026-5146","summary":"SFTP root escape via prefix-based path validation in goshs in github.com/patrickhener/goshs","modified":"2026-06-25T18:45:25.239468942Z","packages":[{"ecosystem":"Go","name":"github.com/patrickhener/goshs","purl":"pkg:golang/github.com/patrickhener/goshs","ranges":["all versions"],"fixed":[]},{"ecosystem":"Go","name":"github.com/patrickhener/goshs/v2","purl":"pkg:golang/github.com/patrickhener/goshs/v2","ranges":["<2.0.0"],"fixed":["2.0.0"]}]}],"attribution":["This product uses the NVD API but is not endorsed or certified by the NVD.","EPSS scores: FIRST Exploit Prediction Scoring System, https://www.first.org/epss","Known exploited vulnerabilities: CISA Known Exploited Vulnerabilities Catalog, https://www.cisa.gov/known-exploited-vulnerabilities-catalog","Package advisories: OSV (https://osv.dev), from the GitHub Advisory Database, PyPA, Go, RustSec and other ecosystem databases, under CC-BY 4.0 or CC0","CVE records: the CVE Program's CVE List (https://www.cve.org), under its terms of use (https://www.cve.org/Legal/TermsOfUse). CVE is a registered trademark of The MITRE Corporation; this product is not affiliated with the CVE Program."]}