CVE-2026-27699: Basic FTP has Path Traversal Vulnerability in its downloadToDir() method

Published Feb 25, 2026
·
Updated

The basic-ftp FTP client library for Node.js contains a path traversal vulnerability (CWE-22) in versions prior to 5.2.0 in the downloadToDir() method. A malicious FTP server can send directory listings with filenames containing path traversal sequences (../) that cause files to be written outside the intended download directory. Version 5.2.0 patches the issue.

Other sources

The basic-ftp library contains a path traversal vulnerability in the downloadToDir() method. A malicious FTP server can send directory listings with filenames containing path traversal sequences (../) that cause files to be written outside the intended download directory.

Source-to-Sink Flow

1. SOURCE: FTP server sends LIST response └─> "-rw-r--r-- 1 user group 1024 Jan 20 12:00 ../../../etc/passwd"

2. PARSER: parseListUnix.ts:100 extracts filename └─> file.name = "../../../etc/passwd"

3. VALIDATION: parseListUnix.ts:101 checks └─> if (name === "." || name === "..") ❌ (only filters exact matches) └─> "../../../etc/passwd" !== "." && !== ".." ✅ PASSES

4. SINK: Client.ts:707 uses filename directly └─> const localPath = join(localDirPath, file.name) └─> join("/safe/download", "../../../etc/passwd") └─> Result: "/safe/download/../../../etc/passwd" → resolves to "/etc/passwd"

5. FILE WRITE: Client.ts:512 opens file └─> fsOpen(localPath, "w") → writes to /etc/passwd (outside intended directory)

Vulnerable Code

File: src/Client.ts:707

typescript protected async downloadFromWorkingDir(localDirPath: string): Promise<void> { await ensureLocalDirectory(localDirPath) for (const file of await this.list()) { const localPath = join(localDirPath, file.name) // ⚠️ VULNERABLE // file.name comes from untrusted FTP server, no sanitization await this.downloadTo(localPath, file.name) } }

Root Cause: - Parser validation (parseListUnix.ts:101) only filters exact . or .. entries - No sanitization of ../ sequences in filenames - path.join() doesn't prevent traversal, fs.open() resolves paths

Impact

A malicious FTP server can: - Write files to arbitrary locations on the client filesystem - Overwrite critical system files (if user has write access) - Potentially achieve remote code execution

Affected Versions

- Tested: v5.1.0 - Likely: All versions (code pattern exists since initial implementation)

Mitigation

Workaround: Do not use downloadToDir() with untrusted FTP servers.

Fix: Sanitize filenames before use:

typescript import { basename } from 'path'

// In downloadFromWorkingDir: const sanitizedName = basename(file.name) // Strip path components const localPath = join(localDirPath, sanitizedName)

GitHub

Affected Software

4 affected componentsFixes available
npm/basic-ftp<5.2.0
npm/basic-ftp<5.2.0
5.2.0
patrickjuchli Basic-ftp Node.js<5.2.0
IBM Concert Software<=1.0.0-2.3.1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/basic-ftp to a version that resolves this vulnerability.

    Fixed in 5.2.0
  2. Upgrade

    Upgrade basic-ftp to a version that resolves this vulnerability.

    Fixed in 5.2.0
  3. Configuration

    Do not use downloadToDir() (or downloadToDir() via downloadTo/local downloads) with untrusted FTP servers; filenames from the FTP LIST response can include traversal sequences.

    basic-ftp Client.ts downloadToDir() usage downloadToDir() with untrusted FTP servers = avoid
  4. Configuration

    Before calling downloadTo/open for writes, sanitize the FTP-provided filename: set sanitizedName = basename(file.name) (strip path components) and use join(localDirPath, sanitizedName) instead of join(localDirPath, file.name).

    Client.ts (_downloadFromWorkingDir) localPath construction from file.name = sanitize using basename(file.name)

Event History

Feb 25, 2026
CVE Published
via MITRE·02:58 PM
Data Sourced
via MITRE·02:58 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·03:20 PM
RemedyDescriptionSeverityWeaknessAffected Software
Advisory Published
via GitHub·10:34 PM
Data Sourced
via GitHub·10:34 PM
DescriptionSeverityWeaknessAffected Software
Aug 27, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Frequently Asked Questions

1

What is the severity of CVE-2026-27699?

CVE-2026-27699 is classified as a high severity vulnerability due to its potential for exploitation by a malicious FTP server.

2

How do I fix CVE-2026-27699?

To fix CVE-2026-27699, upgrade the `basic-ftp` library to version 5.2.0 or later.

3

What impact does CVE-2026-27699 have on applications using the basic-ftp library?

CVE-2026-27699 allows attackers to exploit path traversal sequences, potentially leading to unauthorized file downloads.

4

Which versions of basic-ftp are affected by CVE-2026-27699?

CVE-2026-27699 affects all versions of the basic-ftp library prior to 5.2.0.

5

Is the CVE-2026-27699 vulnerability related to Node.js applications?

Yes, CVE-2026-27699 specifically impacts Node.js applications that utilize the basic-ftp library.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203