CVE-2026-27699: Basic ftp Path Traversal Vulnerability

CRITICAL
Advisory Identifier: GHSA-5rq4-664w-9x2c
CVSS 9.1
CWE-22
Published
Advisory Summary

CVE-2026-27699 is a CRITICAL (CVSS 9.1) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Basic ftp libraries in the npm ecosystem. The issue involves basic ftp has path traversal vulnerability in its downloadtodir() method. Remediation is available by upgrading affected packages to version 5.2.0.

CVE-2026-27699 at a Glance

CVE Identifier CVE-2026-27699
GHSA Identifier GHSA-5rq4-664w-9x2c
Severity CRITICAL
CVSS v3.1 Base Score 9.1
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Basic ftp
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-27699

To remediate this vulnerability, upgrade all affected Basic ftp dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

basic-ftp fixed: 5.2.0
npm install basic-ftp@5.2.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls basic-ftp

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-27699, inspect your project dependencies using npm:

npm ls basic-ftp

Analyze the terminal output to locate any version of Basic ftp in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.2.0), your application is affected.

Note: The npm ls basic-ftp command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Basic ftp, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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) ```

CVE-2026-27699 Affected Basic ftp Versions

1 component(s)
Fixed Versions:
5.2.0
Product / Package Ecosystem Affected Versions Fixed Version
basic-ftp
npm
< 5.2.0
5.2.0

References

Frequently Asked Questions

What is CVE-2026-27699?
CVE-2026-27699 is a security vulnerability in Basic ftp involving Basic FTP has Path Traversal Vulnerability in its downloadToDir() method under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Basic ftp versions are affected?
Affected versions include releases prior to 5.2.0 across affected packages: basic-ftp.
What version fixes CVE-2026-27699?
Upgrading to 5.2.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is basic-ftp affected?
Yes, basic-ftp is affected in releases prior to 5.2.0. Upgrade your dependency to 5.2.0 or later.
What is the CVSS score of CVE-2026-27699?
CVE-2026-27699 has a CVSS v3.1 base score of 9.1 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H.
What CWE is associated with CVE-2026-27699?
CVE-2026-27699 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check npm dependencies for CVE-2026-27699?
Run the dependency tree command: 'npm ls basic-ftp'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-5rq4-664w-9x2c",
  "modified" : "2026-02-25T22:34:26Z",
  "published" : "2026-02-25T22:34:26Z",
  "aliases" : [ "CVE-2026-27699" ],
  "summary" : "Basic FTP has Path Traversal Vulnerability in its downloadToDir() method",
  "details" : "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.\n\n\n## Source-to-Sink Flow\n\n```\n1. SOURCE: FTP server sends LIST response\n└─> \"-rw-r--r-- 1 user group 1024 Jan 20 12:00 ../../../etc/passwd\"\n\n2. PARSER: parseListUnix.ts:100 extracts filename\n└─> file.name = \"../../../etc/passwd\"\n\n3. VALIDATION: parseListUnix.ts:101 checks\n└─> if (name === \".\" || name === \"..\") ❌ (only filters exact matches)\n└─> \"../../../etc/passwd\" !== \".\" && !== \"..\" ✅ PASSES\n\n4. SINK: Client.ts:707 uses filename directly\n└─> const localPath = join(localDirPath, file.name)\n└─> join(\"/safe/download\", \"../../../etc/passwd\")\n└─> Result: \"/safe/download/../../../etc/passwd\" → resolves to \"/etc/passwd\"\n\n5. FILE WRITE: Client.ts:512 opens file\n└─> fsOpen(localPath, \"w\") → writes to /etc/passwd (outside intended directory)\n```\n\n## Vulnerable Code\n\n**File**: `src/Client.ts:707`\n\n```typescript\nprotected async _downloadFromWorkingDir(localDirPath: string): Promise<void> {\nawait ensureLocalDirectory(localDirPath)\nfor (const file of await this.list()) {\nconst localPath = join(localDirPath, file.name) // ⚠️ VULNERABLE\n// file.name comes from untrusted FTP server, no sanitization\nawait this.downloadTo(localPath, file.name)\n}\n}\n```\n\n**Root Cause**:\n- Parser validation (`parseListUnix.ts:101`) only filters exact `.` or `..` entries\n- No sanitization of `../` sequences in filenames\n- `path.join()` doesn't prevent traversal, `fs.open()` resolves paths\n\n\n# Impact\n\nA malicious FTP server can:\n- Write files to arbitrary locations on the client filesystem\n- Overwrite critical system files (if user has write access)\n- Potentially achieve remote code execution\n\n## Affected Versions\n\n- **Tested**: v5.1.0\n- **Likely**: All versions (code pattern exists since initial implementation)\n\n## Mitigation\n\n**Workaround**: Do not use `downloadToDir()` with untrusted FTP servers.\n\n**Fix**: Sanitize filenames before use:\n\n```typescript\nimport { basename } from 'path'\n\n// In _downloadFromWorkingDir:\nconst sanitizedName = basename(file.name) // Strip path components\nconst localPath = join(localDirPath, sanitizedName)\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "basic-ftp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.2.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/patrickjuchli/basic-ftp/security/advisories/GHSA-5rq4-664w-9x2c"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-27699"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/patrickjuchli/basic-ftp/commit/2a2a0e6514357b9eda07c2f8afbd3f04727a7cd9"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/patrickjuchli/basic-ftp"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/patrickjuchli/basic-ftp/releases/tag/v5.2.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-02-25T22:34:26Z",
    "nvd_published_at" : "2026-02-25T15:20:53Z"
  }
}