Security mailing lists by PureSourceCode

CVE-2026-40876

HIGH 8.7CVSS 4.0

SFTP root escape via prefix-based path validation in goshs

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.

Published
21 Apr 2026
Last modified
26 Oct 2026
Assigned by
security-advisories@github.com
NVD status
Analyzed
Weakness
CWE-22
Also known as
GHSA-5h6h-7rc9-3824GO-2026-5146
Sources
NVDJSONOSV GHSA-5h6h-7rc9-3824JSONOSV GO-2026-5146JSON

Scores

SourceScored byVersionScoreVector / decision
NVD security-advisories@github.com (Secondary) CVSS 4.0 HIGH 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/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 GitHub CVSS 4.0 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
NVD nvd@nist.gov (Primary) CVSS 3.1 HIGH 8.8 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
OSV GitHub CVSS 3.1 HIGH 8.8 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Affected

SourceVendor / ecosystemProduct / packageAffected versionsFixed in
NVD goshs goshs
cpe:2.3:a:goshs:goshs:*:*:*:*:*:go:*:*
< 2.0.0 2.0.0
NVD goshs goshs
cpe:2.3:a:goshs:goshs:2.0.0:beta1:*:*:*:go:*:*
= 2.0.0
NVD goshs goshs
cpe:2.3:a:goshs:goshs:2.0.0:beta2:*:*:*:go:*:*
= 2.0.0
NVD goshs goshs
cpe:2.3:a:goshs:goshs:2.0.0:beta3:*:*:*:go:*:*
= 2.0.0
NVD goshs goshs
cpe:2.3:a:goshs:goshs:2.0.0:beta4:*:*:*:go:*:*
= 2.0.0
NVD goshs goshs
cpe:2.3:a:goshs:goshs:2.0.0:beta5:*:*:*:go:*:*
= 2.0.0
OSV Go github.com/patrickhener/goshs <= 1.1.4
OSV Go github.com/patrickhener/goshs/v2 < 2.0.0 2.0.0
OSV Go github.com/patrickhener/goshs all versions

References

History

  • 25 Nov 2026 21:02 UTC · NVD: first stored (published 21 Apr 2026)
  • 25 Nov 2026 20:14 UTC · OSV: first stored (published 25 Jun 2026)
  • 25 Nov 2026 20:13 UTC · OSV: first stored (published 14 Apr 2026)
An unhandled error has occurred. Reload ×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.