CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



GHSA-6V7Q-WJVX-W8WG

GHSA-6V7Q-WJVX-W8WG: Arbitrary FTP Command Execution via CRLF Injection in basic-ftp

Amit Schendel
Amit Schendel
Senior Security Researcher

Apr 11, 2026·6 min read·50 visits

Executive Summary (TL;DR)

CRLF injection in basic-ftp < 5.2.2 permits arbitrary FTP command execution when handling unvalidated credentials and directory names.

The basic-ftp npm package prior to version 5.2.2 contains a CRLF injection vulnerability due to incomplete input validation. This flaw allows an attacker who controls credentials or directory inputs to execute arbitrary FTP commands on the target server.

Vulnerability Overview

The basic-ftp library is a widely used FTP client for Node.js, providing asynchronous functions to interact with FTP servers. Prior to version 5.2.2, the package exhibited incomplete sanitization of user-supplied inputs, resulting in an Improper Neutralization of CRLF Sequences vulnerability (CWE-93). This flaw allows an attacker to inject control characters into the network stream.

The attack surface includes several input vectors, specifically the connection credentials (username and password) and directory path arguments supplied to commands like MKD (Make Directory). The library attempted to mitigate injection attacks using a localized helper function, but failed to apply this validation uniformly across all protocol interactions.

Successful exploitation results in arbitrary FTP command execution. By injecting Carriage Return (\r) and Line Feed (\n) sequences into these vulnerable inputs, an attacker can manipulate the FTP protocol stream. This forces the server to process the injected payload as subsequent, distinct commands, overriding the intended behavior of the client application.

Root Cause Analysis

The root cause of this vulnerability stems from a decentralized and incomplete validation strategy for network-bound data. Security controls were implemented at the perimeter of the application logic rather than at the network socket sink. Specifically, basic-ftp relied on a helper method named protectWhitespace(path) to identify and reject control characters.

This perimeter-based defense failed to cover critical command execution paths. The USER and PASS commands, which authenticate the client to the server, bypassed the protectWhitespace check entirely. If the application allowed user-controlled input for these fields, an attacker could embed newline characters to terminate the PASS sequence and inject arbitrary operations.

Furthermore, the validation logic exhibited inconsistencies regarding directory management. In workflows utilizing the ensureDir functionality, the library issued the MKD command to the server before applying validation in the subsequent cd (Change Directory) call. This execution order created a vulnerability window where malicious directory names were transmitted to the server without sanitization.

By failing to validate all outbound data at the point of socket transmission, the library permitted downstream components to transmit protocol control characters. The FTP protocol utilizes CRLF as the standard command delimiter, meaning any injected newlines are inherently interpreted as command boundaries by the receiving server.

Code Analysis and Patch Review

Prior to version 5.2.2, the protectWhitespace method in src/Client.ts contained the primary defense against CRLF injection. This method was invoked inconsistently across the codebase, leaving several command invocation routes unprotected.

async protectWhitespace(path: string): Promise<string> {
    // Reject CRLF injection attempts
    if (/[\r\n\0]/.test(path)) {
        throw new Error("Invalid path: Contains control characters");
    }
    if (!path.startsWith(" ")) {
        return path
    }
}

The maintainer addressed this architectural flaw in commit 20327d35126e57e5fdbaae79a4b65222fbadc53c by shifting the validation logic from the high-level client methods to a centralized choke point. The localized check in protectWhitespace was removed, preventing future omissions when adding new client functions.

// In src/FtpContext.ts
send(command: string) {
    // Reject control character injection attempts.
    if (/[\r\n\0]/.test(command)) {
        throw new Error(`Invalid command: Contains control characters. (${command})`);
    }
    const containsPassword = command.startsWith("PASS")
    const message = containsPassword ? "> PASS ###" : `> ${command}`
    this.log(message)
    // ... network write logic ...
}

The patch in src/FtpContext.ts intercepts all outgoing FTP commands at the send method. By applying the regular expression /[\r\n\0]/ to the raw command string immediately prior to transmission, the library guarantees that no carriage returns, line feeds, or null bytes can reach the socket interface. This centralized sink validation completely mitigates the CRLF injection vulnerability regardless of the entry point.

Exploitation Methodology

Exploitation requires the attacker to control variables passed to the vulnerable basic-ftp methods. Common vectors include applications that dynamically connect to FTP servers based on user-supplied credentials, or applications that create directories named after user input.

An attacker crafts a payload by terminating the intended value with a CRLF sequence, followed by an arbitrary FTP command. For example, if an attacker provides mypassword\r\nDELE /critical/file as the password field, the library appends its own termination sequence and writes the data to the socket.

The FTP server receives the network transmission and processes the byte stream sequentially. It interprets PASS mypassword as the first command and attempts authentication. Immediately following, it encounters the DELE /critical/file command and executes it within the context of the authenticated session.

This technique allows the execution of arbitrary FTP protocol actions. The attacker does not gain arbitrary operating system command execution directly via this vector, but rather achieves control over the FTP interaction stream. The success of the injected commands depends on the authorization state at the moment the server evaluates the payload.

Impact Assessment

The direct impact of this vulnerability is the unauthorized execution of FTP commands. If the injected command executes successfully, an attacker can manipulate files, alter permissions, or retrieve data from the target FTP server. This compromises the integrity and confidentiality of the data stored on the system.

The severity of the impact is contingent on the privileges of the authenticated FTP user. If the injection occurs during the PASS command authentication phase, the subsequent commands execute with the permissions of that user. Actions such as DELE (delete file), RMD (remove directory), or RETR (retrieve file) can be utilized to destroy data or exfiltrate sensitive information.

If the injection occurs pre-authentication (e.g., within the USER command), the impact is limited to commands the server permits for unauthenticated clients. However, many FTP servers allow specific informational commands or anonymous interactions before a successful login, which could still be abused for reconnaissance.

The blast radius is primarily confined to the FTP server and its accessible file system. The application running the basic-ftp library acts as a confused deputy, unwittingly relaying the malicious payloads to the backend infrastructure.

Remediation and Mitigation

The definitive remediation for this vulnerability is updating the basic-ftp dependency to version 5.2.2 or later. This release introduces the centralized validation logic at the send method, ensuring all network transmissions are free of control characters. Development teams must audit their package.json and lockfiles to enforce this minimum version requirement.

For environments unable to deploy the patched library version immediately, application-level input validation serves as an effective mitigating control. Developers must implement strict sanitization on all user-controlled data passed to basic-ftp methods, specifically stripping or rejecting carriage returns (\r), line feeds (\n), and null bytes (\0) from credentials and file paths.

Defenders should monitor FTP server logs for indicators of exploitation. Network security monitoring tools can be configured to detect anomalous FTP streams containing multiple rapid commands or the presence of literal newline characters within the parameters of commands like USER, PASS, and MKD. Unusual intervals between authentication commands and destructive commands often indicate automated injection attempts.

Official Patches

patrickjuchliRelease v5.2.2 basic-ftp

Fix Analysis (1)

Technical Appendix

CVSS Score
8.1/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H

Affected Systems

basic-ftp < 5.2.2

Affected Versions Detail

Product
Affected Versions
Fixed Version
basic-ftp
npm
< 5.2.25.2.2
AttributeDetail
CWE IDCWE-93
Attack VectorNetwork
CVSS Score8.1
ImpactArbitrary FTP Command Execution
Exploit StatusPoC
KEV StatusNot Listed

MITRE ATT&CK Mapping

T1059Command and Scripting Interpreter
Execution
CWE-93
Improper Neutralization of CRLF Sequences

Improper Neutralization of CRLF Sequences ('CRLF Injection')

Vulnerability Timeline

Fix commit pushed and version 5.2.2 released to npm
2026-04-09
GitHub Advisory GHSA-6V7Q-WJVX-W8WG published
2026-04-09

References & Sources

  • [1]GitHub Advisory GHSA-6V7Q-WJVX-W8WG
  • [2]Fix Commit 20327d35126e57e5fdbaae79a4b65222fbadc53c
  • [3]Release 5.2.2

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•about 7 hours ago•GHSA-4PH6-MJV7-3FQ6
6.5

GHSA-4PH6-MJV7-3FQ6: Improper Handling of Untrusted DNS-over-HTTPS Response Data in netfoil

netfoil, an allowlist-based DNS proxy, failed to sanitize ALPN fields parsed from untrusted DNS-over-HTTPS (DoH) HTTPS Resource Records. This allowed attackers to inject ANSI escape sequences into log files or trigger Denial of Service (DoS) via uncontrolled memory allocations.

Alon Barad
Alon Barad
5 views•6 min read
•about 8 hours ago•GHSA-3GJW-F78C-VVPW
7.5

GHSA-3GJW-F78C-VVPW: Denial of Service via Unhandled Out-of-Bounds Indexing Panic in tokio-postgres

An issue was discovered in the tokio-postgres library for Rust prior to version 0.7.18. A trust assumption mismatch between the PostgreSQL protocol messages sent by a server and how they are parsed and indexed by the client-side library allows a rogue or compromised database server to trigger a Denial of Service (DoS) crash via an unhandled out-of-bounds slice indexing panic.

Alon Barad
Alon Barad
6 views•6 min read
•about 22 hours ago•CVE-2026-14669
8.8

CVE-2026-14669: PostgreSQL to_char() Timezone Abbreviation Heap-Based Buffer Overflow

CVE-2026-14669 is a critical heap-based buffer overflow vulnerability in PostgreSQL's date/time formatting function to_char(timestamptz). The flaw arises from unsafe copying of user-controlled timezone abbreviations into a fixed-size internal buffer. An authenticated database user can trigger this issue by setting a long POSIX timezone abbreviation containing custom formatting, allowing them to overwrite adjacent heap structures and hijack execution control to achieve remote code execution (RCE) with the privileges of the 'postgres' operating system user.

Alon Barad
Alon Barad
14 views•6 min read
•3 days ago•CVE-2026-63462
7.5

CVE-2026-63462: Unauthenticated Stack Overflow Denial of Service in Unleash Server

An unauthenticated remote denial of service vulnerability exists in the Unleash feature management platform. By submitting a crafted JSON payload containing deeply nested structures to an OpenAPI-validated endpoint, an attacker can trigger uncontrolled recursion within the error formatting module. This leads to a call-stack exhaustion (RangeError: Maximum call stack size exceeded) inside the Node.js runtime, causing the service to crash immediately without recovery.

Alon Barad
Alon Barad
11 views•6 min read
•3 days ago•CVE-2026-63004
5.5

CVE-2026-63004: Server-Side Request Forgery in Unleash Addon and Integration Subsystem

CVE-2026-63004 is a server-side request forgery (SSRF) vulnerability in the Unleash feature management platform. Authenticated administrators with CREATE_ADDON or UPDATE_ADDON privileges can exploit this vulnerability to initiate requests to loopback addresses, private networks, and cloud metadata endpoints, potentially leading to information disclosure and credential extraction.

Amit Schendel
Amit Schendel
10 views•8 min read
•3 days ago•CVE-2026-63466
4.1

CVE-2026-63466: Process-Wide Security Degradation via Global Module Mutation in Unleash

Prior to version 8.0.3, Unleash's Markdown event formatter directly mutated the global template-escaping function of the shared mustache Node.js module, resulting in a process-wide security degradation where HTML/Markdown escaping was permanently disabled for the application lifetime.

Alon Barad
Alon Barad
3 views•6 min read