{"id":"CVE-2026-27699","aliases":["CVE-2026-27699","GHSA-5rq4-664w-9x2c"],"related":[],"kind":"vulnerability","state":"published","title":"Basic FTP has Path Traversal Vulnerability in its downloadToDir() method","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"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```","format":"markdown","source":"ghsa"},{"lang":"es","text":"La librería cliente FTP `basic-ftp` para Node.js contiene una vulnerabilidad de salto de ruta (CWE-22) en versiones anteriores a la 5.2.0 en el método `downloadToDir()`. Un servidor FTP malicioso puede enviar listados de directorio con nombres de archivo que contienen secuencias de salto de ruta (`../`) que provocan que los archivos se escriban fuera del directorio de descarga previsto. La versión 5.2.0 corrige el problema.","source":"nvd"}],"published":"2026-02-25T14:58:56.815Z","modified":"2026-09-10T03:50:34.155Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H","score":9.1,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H","score":9.1,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H","score":9.1,"rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"version":"< 5.2.0","status":"affected"}],"vendor":"patrickjuchli","product":"basic-ftp","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"5.2.0"}],"ecosystem":"npm","package":"basic-ftp","purl":"pkg:npm/basic-ftp","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"5.2.0"}],"vendor":"patrickjuchli","product":"basic-ftp","cpe":"cpe:2.3:a:patrickjuchli:basic-ftp:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/patrickjuchli/basic-ftp/security/advisories/GHSA-5rq4-664w-9x2c","tags":["exploit","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/patrickjuchli/basic-ftp/commit/2a2a0e6514357b9eda07c2f8afbd3f04727a7cd9","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/patrickjuchli/basic-ftp/releases/tag/v5.2.0","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-27699","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/patrickjuchli/basic-ftp","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"total","date":"2026-02-27T17:04:25.002Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-27699","url":"https://www.cve.org/CVERecord?id=CVE-2026-27699","licence":"CVE Terms of Use","modified":"2026-02-27T17:04:33.751Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-5rq4-664w-9x2c","url":"https://github.com/advisories/GHSA-5rq4-664w-9x2c","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:34.155Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-27699","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-27699","licence":"Public domain","modified":"2026-06-17T10:27:32.287Z"}],"updatedAt":"2026-11-25T22:59:14.842Z","epss":{"score":0.00925,"percentile":0.61478,"date":"2026-12-01T12:00:22.000Z"}}