SFTP root escape via prefix-based path validation in goshs
CVE-2026-40876GHSA-5h6h-7rc9-3824
What to do
Partial vendor fix. Follow the primary source's mitigation guidance and check back for a fix.
This page has no inventory attached, so it cannot say whether you are affected. A vendor fix is not proof that your deployment is fixed.
Affected packages
Go github.com/patrickhener/goshs/v2
- Affected
- < 2.0.0
- Fixed in
- 2.0.0
Go github.com/patrickhener/goshs
- Affected
- <= 1.1.4
- Fixed in
- no fixed version recorded
Sources
- GitHub Advisory Database and maintainer security advisories on GitHub
GitHub-reviewed advisory GHSA-5h6h-7rc9-3824 lists affected ranges: Go github.com/patrickhener/goshs >=0 =0 <2.0.0
VerifiedObserved Structured GitHub Advisory Database record (type=reviewed) from the GitHub REST API.
Severity and exploitation
- Exploitation
- No confirmed exploitation recorded. Patch Next marks exploitation only from CISA KEV.
- CVSS 4.0
- 8.7 · 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 source
- EPSS
- CVE-2026-40876: 0.44% estimated exploitation activity in the next 30 days; percentile 38.23 (FIRST EPSS, 2026-11-03). This is a model estimate, not proof of exploitation or customer exposure.
Source description
As published by the source; long descriptions are shortened.
Summary 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. Details The SFTP subsystem routes requests through sftpserver/sftpserver.go:99-126 into DefaultHandler.GetHandler() in sftpserver/handler.go:90-112, which forwards file operations into readFile, writeFile, listFile, and cmdFile. All of those sinks rely on sanitizePath() in sftpserver/helper.go:47-59. The vulnerable logic is: This is 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/goshsrootevil/secret.txt incorrectly passes validation since it starts with the same byte prefix. That unsafe value then reaches filesystem sinks including: - os.Open in sftpserver/helper.go:80-94 - os.Create in…
Dates and revisions
- Published by the source
- Last modified by the source
- Source last checked
- Revision 1 · created ·
Published from ghsa record GHSA-5h6h-7rc9-3824
Agent brief
Preview the exact text before you copy it. Commands are read-only suggestions; review them before running anything.
# Patch Next advisory brief: CVE-2026-40876 Advisory: SFTP root escape via prefix-based path validation in goshs IDs: CVE-2026-40876, GHSA-5h6h-7rc9-3824 Record: https://patchnext.com/advisories/cve-2026-40876 (revision 1, source checked 26 Oct 2026, 15:19 UTC) Inventory: none attached. This brief comes from a public page and does not say whether any deployment is affected. Severity: High (CVSS 8.7) Exploitation: no confirmed exploitation recorded. Patch Next confirms exploitation only from CISA KEV. Vendor response: Partial vendor fix; fixed versions by package: github.com/patrickhener/goshs/v2 2.0.0. A vendor fix does not mean a deployment is fixed. ## Affected components - Go github.com/patrickhener/goshs/v2: affected < 2.0.0; fixed in 2.0.0 - Go github.com/patrickhener/goshs: affected <= 1.1.4 ## Suggested inspection (read-only) - Go github.com/patrickhener/goshs/v2: check the installed version with your package manager. - Go github.com/patrickhener/goshs: check the installed version with your package manager. ## Supported action No complete vendor fix is recorded. Follow the primary source's mitigation guidance and check this record again before closing anything. ## Required regression checks - Run the test suite and a production build. - Exercise the features that depend on github.com/patrickhener/goshs/v2, github.com/patrickhener/goshs. - Repeat the inspection and confirm that only fixed versions remain installed. ## Rollback considerations - Keep the previous lockfile and deployment artifact. Rolling back reinstates the vulnerable version, so apply any documented mitigation while you fix forward. ## Unresolved questions - Which deployments run an affected version? - Exploitation status can change. Check again before lowering the priority. - Mark the work resolved only after the fixed version is verified in production. ## Sources - Verified: https://github.com/advisories/GHSA-5h6h-7rc9-3824 (GitHub-reviewed advisory GHSA-5h6h-7rc9-3824 lists affected ranges: Go github.com/patrickhener/goshs >=0 =0 <2.0.0) Commands are suggestions: review each one before running it.
Loading voting…