{"id":"CVE-2026-40876","published":"2026-04-21T19:34:19Z","modified":"2026-04-22T13:29:26Z","title":"SFTP root escape via prefix-based path validation in goshs","vendor":"patrickhener","product":"goshs","tier":"tail","description":{"text":"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.","provenance":"source","from":"CVE.org"},"cvss":{"score":8.7,"severity":"HIGH","version":"4.0","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","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.00615,"percentile":0.43683,"provenance":"source"},"cwes":[{"id":"CWE-22","name":"Improper Limitation of a Pathname to a Restricted Directory"}],"references":[{"url":"https://github.com/patrickhener/goshs/security/advisories/GHSA-5h6h-7rc9-3824","tags":["x_refsource_CONFIRM"]}],"priority":{"score":14.8,"factors":[{"name":"EPSS percentile","points":8.74},{"name":"CVSS severity","points":6.09}]},"vendorSlug":"patrickhener","affectedVersions":[{"vendor":"patrickhener","product":"goshs","versions":["< 2.0.0-beta.6"]}],"ssvc":{"exploitation":"poc","automatable":"no","technicalImpact":"total","timestamp":"2026-04-22T13:29:05.910872Z","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"Go","package":"github.com/patrickhener/goshs","vulnerableRanges":["<=1.1.4","all versions"],"patched":[],"from":["GHSA-5h6h-7rc9-3824","GO-2026-5146"],"provenance":"source"},{"ecosystem":"Go","package":"github.com/patrickhener/goshs/v2","vulnerableRanges":["<2.0.0"],"patched":["2.0.0"],"from":["GHSA-5h6h-7rc9-3824","GO-2026-5146"],"provenance":"source"}],"summary":{"text":"The goshs SFTP subsystem contains a path traversal flaw in its path validation logic (sanitizePath in sftpserver/helper.go, which uses a raw string-prefix comparison rather than a directory-boundary check), affecting versions before 2.0.0-beta.6. An authenticated SFTP user with network access to the server can read and write files outside the configured SFTP root, such as sibling directories whose names share the root's prefix, without any user interaction or special configuration.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T21:35:55Z"},"euvd":{"id":"EUVD-2026-24260","exploited":false,"provenance":"source"},"lineage":{"packageHistory":[{"cve":"CVE-2026-40883","published":"2026-04-21","fixed":"2.0.0-beta.6","kev":false,"link":{"from":"CVE-2026-40883","to":"CVE-2026-40876","relation":"successor","confidence":"low","kind":"sequence","orderedBy":"description","evidence":[{"kind":"version-step","provenance":"source","package":"Go:github.com/patrickhener/goshs/v2","fromFixed":"2.0.0-beta.6","toFixed":"2.0.0","daysApart":0}]}},{"cve":"CVE-2026-40885","published":"2026-04-21","fixed":"2.0.0-beta.6","kev":false},{"cve":"CVE-2026-40876","published":"2026-04-21","fixed":"2.0.0","kev":false},{"cve":"CVE-2026-40884","published":"2026-04-21","fixed":"2.0.0","kev":false},{"cve":"CVE-2026-42091","published":"2026-05-04","fixed":"2.0.2","kev":false,"link":{"from":"CVE-2026-40876","to":"CVE-2026-42091","relation":"successor","confidence":"low","kind":"sequence","evidence":[{"kind":"version-step","provenance":"source","package":"Go:github.com/patrickhener/goshs/v2","fromFixed":"2.0.0","toFixed":"2.0.2","daysApart":13}]}},{"cve":"CVE-2026-54719","published":"2026-07-28","fixed":"2.1.1","kev":false}],"package":"Go:github.com/patrickhener/goshs/v2"}}