llamaCVEVulnerability Intelligence
/
Advisory · GitHub · npm · network-ai

GHSA-5MM5-4MH4-6GM6

InputSanitizer.sanitizePath sibling-directory escape via non-separator-anchored prefix check

Parche disponible
Descargar PNG JSON
CVSS
—
high
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche el mismo día de la divulgación
Exposición34 dDesde la divulgación, 17 oct 2026, 1:17 p. m.
Detección32 dDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir
Remediar en la ventana regular de mantenimiento
Estimación de Llama con el árbol SSVC de CISA a partir de la severidad declarada por GHSA (alta) y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, no automatizable e impacto técnico parcial. Hay versiones corregidas disponibles.
Hmm… no me convence. Vigílala de cerquita.Si sale un exploit, la subo de categoría. Atento.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 5.15.5
Monitoreo
Detectada +1
17 oct 26
19 nov 26
21 nov 26
17 oct 26
26 oct 26
4 nov 26
12 nov 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-5MM5-4MH4-6GM6 divulgada
Remediación Parche 5.15.5 network-ai · 0 d desde divulgación
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

Summary

`InputSanitizer.sanitizePath()`, a published path validation helper exported from the `network-ai` package as `network-ai/security`, fails to confine a resolved path to its intended base directory. The containment check at `security.ts:387` uses a bare string `startsWith(resolvedBase)` without a trailing path separator, so any path in a sibling directory whose name begins with the base directory's name (for example `/data/project-evil/secret.txt` against base `/data/project`) is accepted as in-scope. A caller that invokes this helper to validate attacker-influenced paths can be tricked into treating out-of-scope paths as safe, enabling file access outside the directory the helper is supposed to enforce.

Root Cause

The security invariant is that a path returned by `sanitizePath()` must resolve to a location inside `basePath`. The method normalizes the input, resolves it to an absolute path, and then tests containment only with `resolvedPath.startsWith(resolvedBase)`. Plain string prefix matching is not path-boundary aware: the base string `/data/project` is a prefix of the unrelated sibling `/data/project-evil`, so the check passes for a path that is not under the base directory. The method never appends a path separator to the base before comparing, and it never re-checks the final resolved path against a separator-anchored boundary. The companion `SandboxPolicy` checks in `lib/agent-runtime.ts` use the correct separator-anchored form (`startsWith(base + sep)`), but that pattern was never applied to this helper; `security.ts` does not even import `sep`.

security.ts:374  static sanitizePath(inputPath, basePath)
security.ts:387  if (!resolvedPath.startsWith(resolvedBase)) { throw ... }   // missing separator anchor
security.ts:20   import { join, normalize, isAbsolute } from 'path'          // 'sep' not imported

Impact

An actor who can supply the `inputPath` argument to a caller of `InputSanitizer.sanitizePath()` can cause the helper to return an out-of-scope path as if it were validated. The attacker controls `inputPath`; `basePath` is set by the consuming application. Exploitation requires the attacker to supply (or guess) a sibling directory name that shares a string prefix with the base directory, a common condition for conventional layouts such as `/data/project` next to `/data/project-evil` or `/data/project2`. Because the helper is the terminal path-validation step, any filesystem operation the caller performs on the returned path (read or directory listing in the demonstrated case) then operates outside the intended base directory, disclosing files the sandbox was meant to withhold. The primitive demonstrated directly is read/list disclosure across the sibling-prefix boundary. Because the helper is a general path validator whose return value carries no record of the intended operation, a caller that validates a write destination with it receives the same out-of-scope path and writes outside the base directory, letting attacker-controlled content be created or overwritten there; the package's own companion sandbox check is applied to read, write, and directory-listing calls alike, so write validation is an expected use of a helper of this kind rather than a hypothetical one.

Proof of Concept

No dependencies beyond Node.js. The script reproduces the exact resolution and
containment logic of security.ts:374-392 and compares it against the fixed,
separator-anchored pattern used in lib/agent-runtime.ts.
const { normalize, isAbsolute, join, sep } = require('path');

function vulnerable(inputPath, basePath) {
  const normalized = normalize(inputPath);
  const absolute = isAbsolute(normalized) ? normalized : join(basePath, normalized);
  const resolvedBase = normalize(basePath);
  const resolvedPath = normalize(absolute);
  if (!resolvedPath.startsWith(resolvedBase)) throw new Error('PATH_TRAVERSAL');
  return resolvedPath;
}

const base = '/data/project';
for (const input of ['/data/project-evil/secret.txt', '../project-evil/secret.txt',
                     '/data/project2/key.pem', '../project2/key.pem']) {
  try { console.log('ACCEPTED', input, '=>', vulnerable(input, base)); }
  catch (e) { console.log('BLOCKED ', input); }
}
ACCEPTED /data/project-evil/secret.txt => /data/project-evil/secret.txt
ACCEPTED ../project-evil/secret.txt => /data/project-evil/secret.txt
ACCEPTED /data/project2/key.pem => /data/project2/key.pem
ACCEPTED ../project2/key.pem => /data/project2/key.pem

All four sibling-prefix paths are returned as validated, each resolving outside the base directory `/data/project`. A classic `../../../etc/passwd` input is still rejected, and legitimate children under the base are accepted, confirming the flaw is specifically the missing separator anchor rather than broken traversal handling generally.

Attack Chain

  1. Exposure: The consuming application imports `InputSanitizer` from the published `network-ai/security` subpath export and calls `InputSanitizer.sanitizePath(inputPath, basePath)` to validate a path before a filesystem operation, with `basePath` set to its intended sandbox root.
  2. Control: The attacker controls `inputPath`. They provide a sibling path whose leading component shares a string prefix with `basePath`, for example `/data/project-evil/secret.txt` (absolute) or `../project-evil/secret.txt` (relative), when the base is `/data/project`.
  3. Path: `normalize()` leaves the sibling path unchanged (no dot segments or redundant separators), and `join()` resolves the relative form to the same absolute sibling path. Control reaches the single containment check unchanged.
  4. Guard: The only guard, `resolvedPath.startsWith(resolvedBase)` at `security.ts:387`, lacks a trailing separator. `'/data/project-evil/secret.txt'.startsWith('/data/project')` is `true`, so the guard passes for an out-of-scope path.
  5. Primitive: The helper returns the out-of-scope path to the caller as a validated, in-scope path.
  6. Result: The caller performs its filesystem operation (file read or directory listing in the demonstrated case) on a location outside the intended base directory, disclosing files the base-directory restriction was meant to protect.

Bypass Evidence

The relevant protection is the containment check at `security.ts:387`. The strongest challenge is whether `normalize()` or the `isAbsolute()`/`join()` handling removes the escape before the check; it does not, because a sibling path such as `/data/project-evil/secret.txt` contains no dot segments or redundant separators to normalize away, and the relative form joins to the identical absolute sibling path. The check then reduces to `'/data/project-evil/secret.txt'.startsWith('/data/project')`, which is `true`. The separator-anchored form used elsewhere in the package (`lib/agent-runtime.ts:456`, `resolved === base || resolved.startsWith(base + sep)`) rejects the same input, demonstrating that the missing anchor is the specific defect. This helper is a distinct code path from the previously reported `SandboxPolicy` checks in `lib/agent-runtime.ts`: the earlier fix added separator anchoring only in that file, and `security.ts` has never been modified across the available repository history and still omits the `sep` import, so this validation path remains unguarded against the sibling-prefix input.

Affected Versions

  • Ecosystem: `npm`
  • Package: `network-ai`
  • Confirmed affected range: `<= 5.15.4`
  • Latest release checked: `5.15.4` (npm registry https://www.npmjs.com/package/network-ai/v/5.15.4)
  • Fix status: not fixed

The vulnerable `startsWith(resolvedBase)` containment check in `security.ts` is present in the latest published release, 5.15.4, and `security.ts` has not been modified across the available repository history. The earlier sibling-prefix fix was applied only to `lib/agent-runtime.ts` and did not change this helper, so no release addresses this code path. The introduction boundary cannot be established from the available checkout, which is why the range is left open at the lower end rather than anchored to a specific introducing version.

Suggested Fix

Enforce a separator-anchored containment boundary in `sanitizePath()`: after resolving both the input and the base to absolute, normalized paths, accept the result only when it equals the base or begins with the base followed by the platform path separator (`resolvedPath === resolvedBase || resolvedPath.startsWith(resolvedBase + sep)`), mirroring the pattern already used in `lib/agent-runtime.ts`. This requires importing `sep` from `path` in `security.ts`. Ensure the comparison is applied after full resolution so both relative inputs (joined to the base) and absolute inputs are checked against the anchored boundary, and add test coverage for the sibling-prefix vectors (both absolute and relative) alongside the existing classic traversal test.

---

Reported by zx.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Versiones

Rangos afectados

Afectada Corregida Última
network-ai≤ 5.15.4
5.15.4
6.0.1
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
npmnetwork-ai
Corregida 5.15.5 0 d 6.0.1 no afectada
Versiones corregidas5.15.5
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/Jovancoding/Network-AI/security/advisories/GHSA-5mm5-4mh4-6gm6

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.