CVE-2026-42091: Github.com/patrickhener/goshs/v2 Goshs Has Cross-Origin Arbitrary File Vulnerability

MODERATE
Advisory Identifier: GHSA-rhf7-wvw3-vjvm
CVSS 6.5
CWE-352
Published
Advisory Summary

CVE-2026-42091 is a MODERATE (CVSS 6.5) goshs has cross-origin arbitrary file vulnerability (CWE-352: Cross-Site Request Forgery (CSRF)) affecting Github.com/patrickhener/goshs/v2 libraries in the Go ecosystem. The issue involves goshs has cross-origin arbitrary file write via missing csrf on put and wildcard cors. Remediation is available by upgrading affected packages to version 2.0.2.

CVE-2026-42091 at a Glance

CVE Identifier CVE-2026-42091
GHSA Identifier GHSA-rhf7-wvw3-vjvm
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-352: Cross-Site Request Forgery (CSRF)
Affected Product Github.com/patrickhener/goshs/v2
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 6.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-42091

To remediate this vulnerability, upgrade all affected Github.com/patrickhener/goshs/v2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/patrickhener/goshs/v2 fixed: 2.0.2
Upgrade github.com/patrickhener/goshs/v2 to 2.0.2
github.com/patrickhener/goshs fixed: Latest secure release
Upgrade github.com/patrickhener/goshs to Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/patrickhener/goshs/v2

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-42091, inspect your project dependencies for Github.com/patrickhener/goshs/v2:

inspect dependencies for github.com/patrickhener/goshs/v2

Analyze the terminal output to locate any version of Github.com/patrickhener/goshs/v2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.2), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-352: Cross-Site Request Forgery (CSRF), where the web application does not, or cannot, sufficiently verify whether a request was intentionally provided by the user who sent the request, which could have originated from an unauthorized actor. In Github.com/patrickhener/goshs/v2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary The PUT upload handler (`httpserver/updown.go`) lacks the CSRF token validation that was added to the POST upload handler during the GHSA-jrq5-hg6x-j6g3 fix. Combined with the unconditional `Access-Control-Allow-Origin: *` on the OPTIONS preflight handler (`httpserver/server.go`), any website can write arbitrary files to a goshs instance through the victim's browser — bypassing network isolation (e.g. localhost, internal network). ### Details **Root Cause 1 — Missing CSRF on PUT** (`httpserver/updown.go:19`) When GHSA-jrq5-hg6x-j6g3 was fixed (commit `e3c3d37`), `checkCSRF()` was added to the POST `upload()` function (line 78) but not to the PUT `put()` function directly above it in the same file. This means PUT requests are accepted without any CSRF token. ```go // POST — protected func (fs *FileServer) upload(w http.ResponseWriter, req *http.Request) { if !fs.checkCSRF(w, req) { return } // ... } // PUT — unprotected func (fs *FileServer) put(w http.ResponseWriter, req *http.Request) { // No checkCSRF call // ... } ``` **Root Cause 2 — Wildcard CORS** (`httpserver/server.go:126`) The OPTIONS handler unconditionally returns permissive CORS headers: ```go w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Allow-Methods", "POST, PUT, OPTIONS") w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization") ``` This allows any website's JavaScript to pass the browser's CORS preflight check and send PUT requests to the goshs server. ### PoC [poc.zip](https://github.com/user-attachments/files/26828829/poc.zip) Please extract the uploaded compressed file before proceeding 1. bash poc.sh <img width="543" height="376" alt="스크린샷 2026-04-17 오후 11 08 13" src="https://github.com/user-attachments/assets/a695cbc8-133e-4e80-a2f5-9fe9fd36b569" /> ### Impact - Arbitrary file write to the goshs webroot from any website the victim visits - File overwrite — existing files can be silently replaced

CVE-2026-42091 Affected Github.com/patrickhener/goshs/v2 Versions

2 component(s)
Fixed Versions:
2.0.2
Product / Package Ecosystem Affected Versions Fixed Version
github.com/patrickhener/goshs/v2
Go
< 2.0.2
2.0.2
github.com/patrickhener/goshs
Go
≤ 1.1.4

References

Frequently Asked Questions

What is CVE-2026-42091?
CVE-2026-42091 is a security vulnerability in Github.com/patrickhener/goshs/v2 involving goshs has Cross-Origin Arbitrary File Write via Missing CSRF on PUT and Wildcard CORS under CWE-352: Cross-Site Request Forgery (CSRF).
Which Github.com/patrickhener/goshs/v2 versions are affected?
Affected versions include releases prior to 2.0.2 across affected packages: github.com/patrickhener/goshs/v2, github.com/patrickhener/goshs.
What version fixes CVE-2026-42091?
Upgrading to 2.0.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/patrickhener/goshs/v2 affected?
Yes, github.com/patrickhener/goshs/v2 is affected in releases prior to 2.0.2. Upgrade your dependency to 2.0.2 or later.
Is github.com/patrickhener/goshs affected?
Yes, github.com/patrickhener/goshs is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2026-42091?
CVE-2026-42091 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2026-42091?
CVE-2026-42091 is classified under CWE-352: Cross-Site Request Forgery (CSRF) (The web application does not, or cannot, sufficiently verify whether a request was intentionally provided by the user who sent the request, which could have originated from an unauthorized actor.).
How can I check Go dependencies for CVE-2026-42091?
Run the dependency tree command: 'inspect dependencies for github.com/patrickhener/goshs/v2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-rhf7-wvw3-vjvm",
  "modified" : "2026-05-04T20:11:00Z",
  "published" : "2026-04-23T14:28:14Z",
  "aliases" : [ "CVE-2026-42091" ],
  "summary" : "goshs has Cross-Origin Arbitrary File Write via Missing CSRF on PUT and Wildcard CORS",
  "details" : "### Summary\nThe PUT upload handler (`httpserver/updown.go`) lacks the CSRF token validation that was added to the POST upload handler during the GHSA-jrq5-hg6x-j6g3 fix. Combined with the unconditional `Access-Control-Allow-Origin: *` on the OPTIONS preflight handler (`httpserver/server.go`), any website can write arbitrary files to a goshs instance through the victim's browser — bypassing network isolation (e.g. localhost, internal network).\n\n### Details\n**Root Cause 1 — Missing CSRF on PUT** (`httpserver/updown.go:19`)\n\nWhen GHSA-jrq5-hg6x-j6g3 was fixed (commit `e3c3d37`), `checkCSRF()` was added to the POST `upload()` function (line 78) but not to the PUT `put()` function directly above it in the same file. This means PUT requests are accepted without any CSRF token.\n\n```go\n// POST — protected \nfunc (fs *FileServer) upload(w http.ResponseWriter, req *http.Request) {\n    if !fs.checkCSRF(w, req) { return }\n    // ...\n}\n\n// PUT — unprotected \nfunc (fs *FileServer) put(w http.ResponseWriter, req *http.Request) {\n    // No checkCSRF call\n    // ...\n}\n```\n\n**Root Cause 2 — Wildcard CORS** (`httpserver/server.go:126`)\n\nThe OPTIONS handler unconditionally returns permissive CORS headers:\n\n```go\nw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\nw.Header().Set(\"Access-Control-Allow-Methods\", \"POST, PUT, OPTIONS\")\nw.Header().Set(\"Access-Control-Allow-Headers\", \"Content-Type, Authorization\")\n```\n\nThis allows any website's JavaScript to pass the browser's CORS preflight check and send PUT requests to the goshs server.\n\n### PoC\n[poc.zip](https://github.com/user-attachments/files/26828829/poc.zip)\n\nPlease extract the uploaded compressed file before proceeding\n\n1. bash poc.sh\n<img width=\"543\" height=\"376\" alt=\"스크린샷 2026-04-17 오후 11 08 13\" src=\"https://github.com/user-attachments/assets/a695cbc8-133e-4e80-a2f5-9fe9fd36b569\" />\n\n\n\n\n### Impact\n- Arbitrary file write to the goshs webroot from any website the victim visits\n- File overwrite — existing files can be silently replaced",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/patrickhener/goshs/v2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/patrickhener/goshs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "1.1.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/patrickhener/goshs/security/advisories/GHSA-rhf7-wvw3-vjvm"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-42091"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/patrickhener/goshs/commit/0e715b94e10c3d1aa552276000f15f104dee2f32"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/patrickhener/goshs"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/patrickhener/goshs/releases/tag/v2.0.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-352" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-23T14:28:14Z",
    "nvd_published_at" : "2026-05-04T18:16:31Z"
  }
}