Update dependency basic-ftp to v5.3.0 [SECURITY]#319
Open
renovate[bot] wants to merge 1 commit intodevelopfrom
Open
Update dependency basic-ftp to v5.3.0 [SECURITY]#319renovate[bot] wants to merge 1 commit intodevelopfrom
renovate[bot] wants to merge 1 commit intodevelopfrom
Conversation
80ab5a1 to
cdab592
Compare
cdab592 to
7622709
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
5.2.0→5.3.0basic-ftp has FTP Command Injection via CRLF
CVE-2026-39983 / GHSA-chqc-8p9q-pq6q
More information
Details
Summary
basic-ftpversion5.2.0allows FTP command injection via CRLF sequences (\r\n) in file path parameters passed to high-level path APIs such ascd(),remove(),rename(),uploadFrom(),downloadTo(),list(), andremoveDir(). The library'sprotectWhitespace()helper only handles leading spaces and returns other paths unchanged, whileFtpContext.send()writes the resulting command string directly to the control socket with\r\nappended. This lets attacker-controlled path strings split one intended FTP command into multiple commands.Affected product
Vulnerability details
CWE-93- Improper Neutralization of CRLF Sequences ('CRLF Injection')8.6(High)CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:Ldist/Client.js, all path-handling methods viaprotectWhitespace()andsend()The vulnerability exists because of two interacting code patterns:
1. Inadequate path sanitization in
protectWhitespace()(line 677):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):The
send()method appends\r\nto the command and writes directly to the TCP socket. If the command string already contains\r\nsequences (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:
DELE /critical-fileto delete files on the FTP serverMKDorRMDcommands to create/remove directoriesRETRcommands to trigger downloads of unintended filesSITE EXEC, inject system commandsUSER/PASScommands to re-authenticate as a different userQUITto terminate the FTP session unexpectedlyThe 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:
Mock FTP server (ftp-server-mock.js):
Exploit (poc.js):
Running the PoC:
Expected output on mock server:
This command trace was reproduced against the published
basic-ftp@5.2.0package on Linux with a local mock FTP server. The injected
DELEcommands arereceived 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:
Recommended fix for basic-ftp: The
protectWhitespace()function (or a new validation layer) should reject or strip\rand\ncharacters from all path inputs:References
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:LReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
basic-ftp: Incomplete CRLF Injection Protection Allows Arbitrary FTP Command Execution via Credentials and MKD Commands
GHSA-6v7q-wjvx-w8wg
More information
Details
Summary
basic-ftp's CRLF injection protection (added in commit 2ecc8e2 for GHSA-chqc-8p9q-pq6q) is incomplete. Two code paths bypass the
protectWhitespace()control character check: (1) thelogin()method directly concatenates user-supplied credentials into USER/PASS FTP commands without any validation, and (2) the_openDir()method sends an MKD command beforecd()invokesprotectWhitespace(), creating a TOCTOU bypass. Both vectors allow an attacker who controls input to inject arbitrary FTP commands into the control connection.Details
Vector 1: Credential Injection (login)
The
login()method constructs FTP commands by direct string concatenation with no CRLF validation:FtpContext.send()writes directly to the TCP socket:The
protectWhitespace()method (line 762) rejects\r,\n, and\0characters — but it is only called for path-based operations. Credentials never pass through it.The public
access()method (line 268) passesoptions.userandoptions.passworddirectly tologin()with no sanitization.Vector 2: MKD TOCTOU Bypass (_openDir)
The
_openDir()method sends an MKD command before the CRLF check incd():This is called from
ensureDir()(line 729) which splits a user-supplied remote path by/and passes each fragment to_openDir(), and from_uploadToWorkingDir()(line 679) which passes local directory names read from the filesystem.PoC
Vector 1: Credential Injection
Vector 2: MKD TOCTOU Bypass
Impact
An attacker who controls credentials or remote paths passed to basic-ftp can inject arbitrary FTP commands into the control connection. This enables:
DELEcommands to remove files on the FTP serverRNFR/RNTOto rename files,MKD/RMDto create/remove directoriesSITEcommands (e.g.,SITE CHMOD) to change permissionsUSER/PASSto re-authenticate as a different userThe credential injection vector (Vector 1) is particularly dangerous because it occurs before authentication, meaning the injected commands execute with whatever default permissions the server grants during the login handshake.
Applications that accept user-supplied FTP credentials (e.g., web-based file managers, backup tools, deployment systems) are directly vulnerable.
Recommended Fix
Add CRLF validation to both code paths:
1. Validate credentials in
login():2. Validate dirName in
_openDir()before sending MKD:Alternatively, centralize CRLF validation in
FtpContext.send()so that all FTP commands are protected regardless of the calling code path.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:LReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
basic-ftp vulnerable to denial of service via unbounded memory consumption in Client.list()
CVE-2026-41324 / GHSA-rp42-5vxx-qpwr
More information
Details
Summary
basic-ftp@5.2.2is vulnerable to denial of service through unbounded memory growth while processing directory listings from a remote FTP server. A malicious or compromised server can send an extremely large or never-ending listing response toClient.list(), causing the client process to consume memory until it becomes unstable or crashes.Details
The issue is in the package's default directory listing flow.
Client.list()reachesdist/Client.js, where the full listing response is downloaded into aStringWriterbefore parsing:File:
dist/Client.js:516-527The vulnerable sink is
StringWriter, which grows an in-memoryBufferwith no limit:File:
dist/StringWriter.js:5-20The critical operation is:
There is no maximum size check, no truncation, and no streaming parser. Because the remote FTP server controls the listing response, it can force the client to keep allocating memory until the process is terminated.
How it happens:
client.list().basic-ftpbuffers the full response inStringWriter.Buffer.concat(...)calls.PoC
The following PoC exercises the vulnerable buffering primitive directly:
Observed output:
This demonstrates sustained memory growth in the same code path used to buffer directory listing data.
Supporting files saved alongside this report:
poc.jspoc_output.txtImpact
This is a denial-of-service vulnerability affecting applications that use
basic-ftpto list directories from remote FTP servers.Client.list()basic-ftp@5.2.2against untrusted FTP endpointsRecommended remediation:
Example defensive check:
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
basic-ftp has FTP Command Injection via CRLF
CVE-2026-39983 / GHSA-chqc-8p9q-pq6q
More information
Details
Summary
basic-ftpversion5.2.0allows FTP command injection via CRLF sequences (\r\n) in file path parameters passed to high-level path APIs such ascd(),remove(),rename(),uploadFrom(),downloadTo(),list(), andremoveDir(). The library'sprotectWhitespace()helper only handles leading spaces and returns other paths unchanged, whileFtpContext.send()writes the resulting command string directly to the control socket with\r\nappended. This lets attacker-controlled path strings split one intended FTP command into multiple commands.Affected product
Vulnerability details
CWE-93- Improper Neutralization of CRLF Sequences ('CRLF Injection')8.6(High)CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:Ldist/Client.js, all path-handling methods viaprotectWhitespace()andsend()The vulnerability exists because of two interacting code patterns:
1. Inadequate path sanitization in
protectWhitespace()(line 677):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):The
send()method appends\r\nto the command and writes directly to the TCP socket. If the command string already contains\r\nsequences (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:
DELE /critical-fileto delete files on the FTP serverMKDorRMDcommands to create/remove directoriesRETRcommands to trigger downloads of unintended filesSITE EXEC, inject system commandsUSER/PASScommands to re-authenticate as a different userQUITto terminate the FTP session unexpectedlyThe 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:
Mock FTP server (ftp-server-mock.js):
Exploit (poc.js):
Running the PoC:
Expected output on mock server:
This command trace was reproduced against the published
basic-ftp@5.2.0package on Linux with a local mock FTP server. The injected
DELEcommands arereceived 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:
Recommended fix for basic-ftp: The
protectWhitespace()function (or a new validation layer) should reject or strip\rand\ncharacters from all path inputs:References
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:LReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
basic-ftp: Incomplete CRLF Injection Protection Allows Arbitrary FTP Command Execution via Credentials and MKD Commands
GHSA-6v7q-wjvx-w8wg
More information
Details
Summary
basic-ftp's CRLF injection protection (added in commit 2ecc8e2 for GHSA-chqc-8p9q-pq6q) is incomplete. Two code paths bypass the
protectWhitespace()control character check: (1) thelogin()method directly concatenates user-supplied credentials into USER/PASS FTP commands without any validation, and (2) the_openDir()method sends an MKD command beforecd()invokesprotectWhitespace(), creating a TOCTOU bypass. Both vectors allow an attacker who controls input to inject arbitrary FTP commands into the control connection.Details
Vector 1: Credential Injection (login)
The
login()method constructs FTP commands by direct string concatenation with no CRLF validation:FtpContext.send()writes directly to the TCP socket:The
protectWhitespace()method (line 762) rejects\r,\n, and\0characters — but it is only called for path-based operations. Credentials never pass through it.The public
access()method (line 268) passesoptions.userandoptions.passworddirectly tologin()with no sanitization.Vector 2: MKD TOCTOU Bypass (_openDir)
The
_openDir()method sends an MKD command before the CRLF check incd():This is called from
ensureDir()(line 729) which splits a user-supplied remote path by/and passes each fragment to_openDir(), and from_uploadToWorkingDir()(line 679) which passes local directory names read from the filesystem.PoC
Vector 1: Credential Injection
Vector 2: MKD TOCTOU Bypass
Impact
An attacker who controls credentials or remote paths passed to basic-ftp can inject arbitrary FTP commands into the control connection. This enables:
DELEcommands to remove files on the FTP serverRNFR/RNTOto rename files,MKD/RMDto create/remove directoriesSITEcommands (e.g.,SITE CHMOD) to change permissionsUSER/PASSto re-authenticate as a different userThe credential injection vector (Vector 1) is particularly dangerous because it occurs before authentication, meaning the injected commands execute with whatever default permissions the server grants during the login handshake.
Applications that accept user-supplied FTP credentials (e.g., web-based file managers, backup tools, deployment systems) are directly vulnerable.
Recommended Fix
Add CRLF validation to both code paths:
1. Validate credentials in
login():2. Validate dirName in
_openDir()before sending MKD:Alternatively, centralize CRLF validation in
FtpContext.send()so that all FTP commands are protected regardless of the calling code path.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:LReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
basic-ftp vulnerable to denial of service via unbounded memory consumption in Client.list()
GHSA-rp42-5vxx-qpwr
More information
Details
Summary
basic-ftp@5.2.2is vulnerable to denial of service through unbounded memory growth while processing directory listings from a remote FTP server. A malicious or compromised server can send an extremely large or never-ending listing response toClient.list(), causing the client process to consume memory until it becomes unstable or crashes.Details
The issue is in the package's default directory listing flow.
Client.list()reachesdist/Client.js, where the full listing response is downloaded into aStringWriterbefore parsing:File:
dist/Client.js:516-527The vulnerable sink is
StringWriter, which grows an in-memoryBufferwith no limit:File:
dist/StringWriter.js:5-20The critical operation is:
There is no maximum size check, no truncation, and no streaming parser. Because the remote FTP server controls the listing response, it can force the client to keep allocating memory until the process is terminated.
How it happens:
client.list().basic-ftpbuffers the full response inStringWriter.Buffer.concat(...)calls.PoC
The following PoC exercises the vulnerable buffering primitive directly:
Observed output:
This demonstrates sustained memory growth in the same code path used to buffer directory listing data.
Supporting files saved alongside this report:
poc.jspoc_output.txtImpact
This is a denial-of-service vulnerability affecting applications that use
basic-ftpto list directories from remote FTP servers.Client.list()basic-ftp@5.2.2against untrusted FTP endpointsRecommended remediation:
Example defensive check:
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:HReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
Release Notes
patrickjuchli/basic-ftp (basic-ftp)
v5.3.0Compare Source
v5.2.2Compare Source
v5.2.1Compare Source
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.