GHSA-2w5v-vj22-jp27: 
JavaScript Análise e mitigação de vulnerabilidades

Summary

downloadToDir() sanitizes file/directory names returned by the FTP server using basename(file.name) !== file.name. However, path.basename("..") === "..", so the check evaluates to false for the literal name .., allowing the traversal protection to be bypassed. A malicious FTP server can list a directory entry named .., causing the client to descend outside the intended local destination directory.

Root Cause

src/Client.ts:737 — sanitization check does not handle ..:

const hasInvalidName = !file.name || basename(file.name) !== file.name
// BYPASS: basename("..") === ".." → hasInvalidName = false → not skipped

src/Client.ts:743 — path constructed with unsanitized name:

const localPath = join(localDirPath, file.name)
// join("/home/user/downloads", "..") → "/home/user" (outside target dir)

src/Client.ts:745-746 — recursive download outside target:

await this.cd(file.name)                      // cd("..") on the server
await this._downloadFromWorkingDir(localPath) // downloads to /home/user instead

Proof of Concept (analytic confirmation)

const { basename, join } = require("path");
// The check that is supposed to block traversal:
const fileName = "..";
const hasInvalidName = !fileName || basename(fileName) !== fileName;
console.log("hasInvalidName:", hasInvalidName);
// Output: hasInvalidName: false  ← BYPASSED
const localPath = join("/home/user/downloads", fileName);
console.log("resolved path:", localPath);
// Output: resolved path: /home/user  ← ESCAPED target directory

A malicious FTP server returning [{ name: "..", isDirectory: true }] from its LIST response triggers this code path, causing _downloadFromWorkingDir to be called with the parent directory path, writing server files outside the intended download location.

Impact

A client connecting to a malicious FTP server (e.g., via a user-supplied URL, a Man-in-the-Middle attack on unencrypted FTP, or a compromised server) and calling downloadToDir() may have files written outside the intended local directory, potentially overwriting system files or placing malicious files in sensitive locations.

Affected Versions

v6.2.4 (latest) and earlier versions with downloadToDir().

Suggested Fix

Add an explicit check for . and .. in the name guard:

const hasInvalidName =
  !file.name ||
  file.name === "." ||
  file.name === ".." ||                     // add this line
  basename(file.name) !== file.name;

Or use a path containment check:

const resolvedLocal = resolve(localDirPath, file.name);
if (!resolvedLocal.startsWith(resolve(localDirPath) + sep)) {
  this.ftp.log(`Unsafe filename skipped: ${JSON.stringify(file.name)}`);
  continue;
}

Origem: NVD

Relacionado JavaScript Vulnerabilidades:

CVE ID

Gravidade

Pontuação

Tecnologias

Nome do componente

Exploit CISA KEV

Tem correção

Data de publicação

CVE-2026-120415MEDIUM5.9
  • JavaScript logoJavaScript
  • undici
NãoSimNov 05, 2026
CVE-2026-116630MEDIUM5.9
  • JavaScript logoJavaScript
  • undici
NãoSimNov 05, 2026
GHSA-9rmh-cqxg-g7fmLOWN/A
  • JavaScript logoJavaScript
  • tina4-nodejs
NãoSimNov 05, 2026
GHSA-685j-v6qp-54w7LOWN/A
  • JavaScript logoJavaScript
  • @tina4/core
NãoSimNov 05, 2026
GHSA-q2gc-fpw5-3v3cMEDIUMN/A
  • JavaScript logoJavaScript
  • tina4-python
NãoSimNov 05, 2026

Avaliação Gratuita de Vulnerabilidades

Avalie a sua postura de segurança na nuvem

Avalie suas práticas de segurança em nuvem em 9 domínios de segurança para avaliar seu nível de risco e identificar lacunas em suas defesas.

Avaliação de solicitação

Recursos adicionais da Wiz

Marque uma demonstração personalizada

Pronto para ver a Wiz em ação?

"A melhor experiência do usuário que eu já vi, fornece visibilidade total para cargas de trabalho na nuvem."
David EstlickCISO
"A Wiz fornece um único painel de vidro para ver o que está acontecendo em nossos ambientes de nuvem."
Adam FletcherDiretor de Segurança
"Sabemos que se a Wiz identifica algo como crítico, na verdade é."
Greg PoniatowskiChefe de Gerenciamento de Ameaças e Vulnerabilidades