DEV Community

jeffrey
jeffrey

Posted on

basic-ftp must contain CRLF failures at the command boundary

basic-ftp must contain CRLF failures at the command boundary

An FTP client is a protocol parser even when it is embedded in a larger Node.js service. CVE-2026-126346 shows that a CR/LF value in a password or resumed-download path can escape the expected error path and terminate the process.

The CVE affects basic-ftp before 6.2.3. In Client.login(), an attacker-influenced password reaches the PASS command after a server sends a 331 response. In a resumed download, an attacker-influenced remote path reaches RETR after a 350 response to REST. A carriage return or line feed produces an uncaught exception instead of a contained command error.

The security result is primarily denial of service. A server, tenant input or automation workflow that can influence those values may crash the Node.js process. The library should reject control characters before a protocol command is assembled or written.

Upgrade to basic-ftp 6.2.3 or later. Applications should also validate passwords and remote paths at their own trust boundary. Passwords may contain many characters, but they do not need CR or LF. Remote paths should reject NUL, CR and LF and should be normalized against the intended FTP root.

Place the client call behind a catch boundary that converts protocol errors into a bounded failure response. Do not let an unhandled promise rejection bring down a worker. If the same process handles several tenants, isolate FTP jobs or restart workers through a supervisor with rate limits.

Review logs for PASS or RETR attempts containing escaped CR/LF, repeated 331 or 350 responses and worker exits near a resumed download. Avoid logging the actual password. A sanitized event should record the account identifier, remote host and path category.

The patch is the primary fix. The application-level rule remains useful because FTP command grammar is line based over many implementations. Treat any CR/LF reaching a command builder as a defect, even when the current library catches it.

References

Top comments (0)