basic-ftp CRLF command injection (CVE-2026-39983)
CVE-2026-39983
basic-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(), ...
Overview
A command injection vulnerability, tracked as CVE-2026-39983, exists in the basic-ftp library for Node.js. This library is a widely used FTP client. The flaw allows an attacker who controls a file path parameter-such as one derived from user input-to inject arbitrary FTP commands into the control connection.
Vulnerability Details
The vulnerability stems from insufficient sanitization of file path arguments passed to high-level API methods like cd(), remove(), uploadFrom(), and list(). The library’s protectWhitespace() helper function only protects against leading spaces, leaving carriage return and line feed (\r\n) sequences untouched. When the FtpContext.send() method constructs the final FTP command, it appends its own \r\n sequence to terminate the command. If an attacker-supplied path contains \r\n, it splits the intended single command, allowing the following text to be executed as a new, separate FTP command. This grants the attacker the ability to issue any command the FTP server permits, such as deleting files, uploading malicious content, or retrieving sensitive data.
Impact
With a high CVSS score of 8.6, this vulnerability poses a significant risk. The attack vector is network-based, requires no privileges or user interaction, and is of low complexity. An attacker exploiting this flaw could achieve remote command execution on the FTP server’s context, leading to data theft, data destruction, or a compromised server that could be used as a foothold for further attacks. For organizations handling sensitive data transfers via FTP, this is a critical security concern. You can find reports on related data breach incidents at breach reports.
Remediation and Mitigation
The primary and immediate action is to upgrade the basic-ftp package to version 5.2.1 or later, where this vulnerability has been fixed.
Actionable Steps:
- Update: Run
npm update basic-ftpin your project directory to install version 5.2.1. - Verify: Check your
package.jsonandpackage-lock.jsonfiles to confirm the version is^5.2.1. - Audit Input: As a general security practice, rigorously validate and sanitize all user-supplied input that is passed to file system or network APIs, even when using a trusted library. Assume all input is malicious until proven otherwise.
If an immediate update is not possible, audit all code paths where user-controlled data is passed to any basic-ftp method that accepts a path, and implement strict validation to reject strings containing CRLF (\r\n) sequences.
Security Insight
This vulnerability highlights the persistent risk of injection attacks when data and control channels are not properly separated. It is reminiscent of classic web vulnerabilities like HTTP header injection or SQL injection, now manifesting in a protocol-specific client library. The flaw’s presence in a helper function named protectWhitespace() suggests a security gap where a partial mitigation was mistaken for a complete one, a common pitfall in secure coding. For the latest on such vulnerabilities, follow security news.
Further Reading
Never miss a critical vulnerability
Get real-time security alerts delivered to your preferred platform.
Related Advisories
Unsanitized input in an OS command in the virtual desktop session name handling in AWS Research and Engineering Studio (RES) version 2025.03 through 2025.12.01 might allow a remote authenticated actor...
A flaw has been found in Linksys MR9600 2.0.6.206937. Affected is the function smartConnectConfigure of the file SmartConnect.lua. Executing a manipulation of the argument configApSsid/configApPassphr...
Roxy-WI is a web interface for managing Haproxy, Nginx, Apache and Keepalived servers. Prior to version 8.2.6.3, a command injection vulnerability exists in the `/config/compare/<service>/<server_ip>/...
A security flaw has been discovered in yued-fe LuLu UI up to 3.0.0. This issue affects the function child_process.exec of the file run.js. The manipulation results in os command injection. The attack ...