MEDIUM · CVSS 3.1 5.9EPSS 2.9% · 88th percentileCWE-248CWE-755
CVE-2026-126346: basic-ftp: Uncaught exception crashes the Node.js process when a password (or resumed-download path) contains CR/LF
Published 2026-11-12 · Updated 2026-11-12 · Also known as GHSA-r4jh-29pc-gfqr
Summary
An uncaught exception in the basic-ftp library crashes the entire Node.js process when control characters (CR/LF) are present in an FTP password or a resumed download path. Engineering teams maintaining applications that use basic-ftp versions prior to 6.2.3 with untrusted input should update immediately.
Who is affected
Affected deployments are Node.js applications using basic-ftp where untrusted user input is passed as an FTP password or a remote path for resumed downloads. The condition requires an attacker to supply a string containing CR, LF, or NUL characters which triggers a synchronous throw inside a socket data event handler. This results in a Denial of Service via process termination if the application lacks a global uncaughtException handler.
Exploitability
The vulnerability is remotely exploitable over a network with high complexity, requiring no privileges or user interaction, resulting in a high availability impact as indicated by CVSS 3.1 base score 5.9. The EPSS score is 0.017 (773rd percentile), and it is not currently listed in the CISA Known Exploited Vulnerabilities catalog.
Remediation
Upgrade the npm basic-ftp package to version 6.2.3 or later.
Validate user-supplied inputs such as passwords and remote paths for control characters before passing them to the library.
How to check your project
Check the package.json or lockfile for references to the npm package 'basic-ftp' with a version lower than 6.2.3.
Search the codebase for imports of 'basic-ftp' and usages of Client.login() or downloadTo() handling untrusted input.
Automated analysis of the published advisory data, generated 2026-11-18. Not human-reviewed; verify against the official advisory. How this works.
When a password or resumed-download path contains control characters like CR, LF, or NUL, FTPContext.send() throws an error inside a socket data event response handler. Because this is unhandled by a try/catch or promise rejection in that synchronous chain, it causes an uncaught exception.
Does this flaw allow remote code execution or command injection?
No. The CRLF guard correctly blocks command injection; however, it throws an unhandled exception leading to a Denial of Service through process termination.
What is the fixed version for this vulnerability?
The vulnerability is fixed in basic-ftp version 6.2.3.
Original advisory description
### Summary
Client.login() calls FTPContext.send() from inside the control-socket data event handler. send() throws on CR, LF or NUL, and nothing catches the throw. A password containing \r\n therefore raises an uncaught exception and terminates the whole Node.js process. It does not reject the returned promise. Any application that passes untrusted input as the FTP password can be crashed remotely with one request. The same pattern exists in the REST/RETR path of downloadTo() when the remote path contains control characters.
### Details
The CRLF guard (FTPContext.send, src/FtpContext.ts ~L233) correctly refuses to send commands containing \r, \n or \0:
```ts
send(command: string) {
if (/[\r\n\0]/.test(command)) {
throw new Error(`Invalid command: Contains control characters. (${command})`);
}
```
That works when send() is called from handle(), because it runs inside a Promise executor and the throw becomes a rejection. But in two places send() runs inside a response handler, which is called synchronously from the socket’s data event:
Client.login() (src/Client.ts ~L246-248): after the server answers 331 to USER, the handler calls this.ftp.send("PASS " + password). The USER command was already sent and is valid, so the password is only checked at this point. The call chain is socket.on("data") → _onControlSocketData → _passToHandler → responseHandler → send() → throw. No try/catch exists anywhere in that chain, so it becomes an uncaughtException.
downloadTo() (src/transfer.ts ~L368-370): when startAt > 0, the initial command is REST n, which contains no user-controlled text. When the server answers 350, the handler calls config.ftp.send("RETR " + config.remotePath). This remotePath was never checked before. A path with a control character throws in the data handler in the same way. (Found by code reading, not reproduced.)
Because the exception happens during data event dispatch, it can’t be handled with try/catch or .catch() around client.access() or downloadTo(). The application only survives if it has a global process.on("uncaughtException") handler.
### Proof of concept
Tested on Node.js v22.22.0 against basic-ftp 6.2.2 (built from source). It uses a minimal mock FTP server on localhost:
```js
const net = require("net")
const ftp = require("basic-ftp")
const srv = net.createServer(s => {
s.write("220 hi\r\n")
s.on("data", d => {
const c = d.toString()
if (c.startsWith("USER")) s.write("331 pw\r\n")
else if (c.startsWith("PASS")) s.write("230 ok\r\n")
else s.write("200 ok\r\n")
})
})
srv.listen(0, async () => {
const c = new ftp.Client(2000)
try {
await c.access({
host: "127.0.0.1",
port: srv.address().port,
user: "bob",
password: "x\r\nDELE important" // attacker-controlled value
})
} catch (e) {
console.log("rejected:", e.message) // never reached
}
console.log("handled gracefully") // never reached
process.exit(0)
})
```
Result: the process terminates with an uncaught exception and neither catch nor the final console.log runs:
```
Error: Invalid command: Contains control characters. (PASS x
DELE important)
at FTPContext.send (dist/FtpContext.js:189:19)
at Object.responseHandler (dist/Client.js:186:26)
at FTPContext._passToHandler (dist/FtpContext.js:322:24)
at FTPContext._onControlSocketData (dist/FtpContext.js:312:18)
at Socket.<anonymous> (dist/FtpContext.js:133:44)
```
The server in the PoC is benign. Any normal FTP server that replies 331 to USER triggers the same crash.
### Impact
Denial of service (uncaught exception, process termination), CWE-248.
It affects applications that pass untrusted or user-influenced values as the FTP password, or as the remote path of a resumed download. Examples are web apps or services that let users enter their own FTP credentials, or file-transfer or backup tools driven by user-supplied paths. One request crashes the whole Node.js process and every other client it serves. It needs no authentication to the FTP server and no special server behaviour. The attacker only needs control over the string. Confidentiality and integrity are not affected, and the CRLF guard still blocks command injection.
Suggested fix:
In FTPContext._passToHandler(), wrap the handler call in a try/catch that rejects the task and calls closeWithError(err).
Validate password in login(), and remotePath in _downloadToStream(), before any I/O and reject early.