GHSA-V64J-MC7X-C7X7
network-ai FileJobStore job ID path traversal allows arbitrary .json file read and delete
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-V64J-MC7X-C7X7 divulgada · CVSS 8.8 (GitHub) | |
| 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 |
Summary
`FileJobStore` in the `network-ai` package constructs job record file paths by joining a developer-configured directory with a caller-supplied `id` value and a `.json` suffix, without validating that `id` stays inside the configured directory. A caller that controls the `id` argument to `FileJobStore.get()` or `FileJobStore.delete()`, including through the `JobQueue.getJob()` wrapper, can use relative traversal sequences such as `../../some-config` to read or delete JSON files anywhere the process has filesystem permissions, escaping the intended job directory. The capability is a confidentiality, integrity, and availability breach limited to paths that resolve to a `.json` suffix.
Root Cause
The `FileJobStore.get(id)` and `FileJobStore.delete(id)` methods build the on-disk path with `join(this.dir, id + '.json')` and immediately read from or unlink that path. Node.js `path.join()` normalizes embedded `..` segments, so an `id` containing relative traversal resolves to a location outside `this.dir`. Neither method, nor the `JobQueue.getJob()` and `JobQueue.cancel()` wrappers that forward an external `jobId` to the store, performs any normalization-and-containment check, path-separator rejection, or allowlist before touching the filesystem. Although `JobQueue.enqueue()` generates safe hexadecimal identifiers, the lookup and delete paths accept arbitrary strings independently, so safe creation does not constrain them. The security invariant that a job file must reside under `this.dir` is never enforced.
lib/job-queue.ts:175-183 FileJobStore.get(): const filePath = join(this.dir, `${id}.json`); const raw = await readFile(filePath, 'utf-8')
lib/job-queue.ts:185-191 FileJobStore.delete(): await unlink(join(this.dir, `${id}.json`))
lib/job-queue.ts:329 JobQueue.getJob(): return this.store.get(jobId) // no sanitization
lib/job-queue.ts:315-316 JobQueue.cancel(): const job = await this.store.get(jobId) // no sanitizationImpact
An attacker who can influence the `id` passed to `get()`/`getJob()` or `delete()` gains two primitives, both bounded to the process's own filesystem authority and to paths resolving to a `.json` extension. Through `get()` the attacker reads arbitrary `.json` files and receives their parsed contents, disclosing configuration, credentials, or job data stored in JSON, including the active-grant store, whose persisted tokens validated successfully when replayed. Through `delete()` the attacker removes arbitrary `.json` files; errors are silently swallowed, so deletion of configuration or data files can degrade or disrupt service availability, and queued job records are destroyed irrecoverably. Deletion also weakens authorization where a deployment keeps security state in JSON, because the trust-level configuration is read only if the file exists and the loader falls back to the package defaults when it is absent: removing a configuration that had placed an agent below the denial threshold caused `AuthGuardian` to issue that agent a grant, and removing the active-grant store invalidated the tokens held by legitimate agents. No remote code execution path was demonstrated. In a deployment that exposes job management over a network interface, the `jobId` typically originates from an untrusted request, so the lookup and delete paths accept attacker-controlled strings.
Proof of Concept
The following script reproduces the traversal using only temporary directories. It demonstrates the read primitive escaping the configured job directory.
TMP=$(mktemp -d)
TMPBASE="$TMP" node -r ts-node/register/transpile-only - <<'TS'
const { FileJobStore } = require('./lib/job-queue');
const fs = require('fs');
const path = require('path');
const base = process.env.TMPBASE;
const jobs = path.join(base, 'jobs');
const secretDir = path.join(base, 'outside');
fs.mkdirSync(jobs, { recursive: true });
fs.mkdirSync(secretDir, { recursive: true });
fs.writeFileSync(path.join(secretDir, 'secret.json'), '{"leaked":true}');
const store = new FileJobStore(jobs);
(async () => {
const traversal = path.relative(jobs, path.join(secretDir, 'secret'));
const record = await store.get(traversal);
console.log(JSON.stringify({ id: traversal, record }, null, 2));
fs.rmSync(base, { recursive: true, force: true });
})();
TS{
"id": "../outside/secret",
"record": { "leaked": true }
}Attack Chain
- Exposure: `FileJobStore` and `JobQueue` are exported from the package public surface (`index.ts:1144`) and ship in the npm artifact (`dist/lib/job-queue.js`, included via the `files` entry in `package.json:136`). A consuming application instantiates the store and exposes job lookup or cancellation.
- Control: The attacker controls the `id`/`jobId` argument. The appended `.json` suffix does not neutralize preceding `..` segments. Safe hexadecimal IDs from `enqueue()` (`lib/job-queue.ts:296`) do not constrain the lookup or delete paths.
- Path: The value forwards unsanitized through `JobQueue.getJob()` (`lib/job-queue.ts:329`) or `JobQueue.cancel()` (`lib/job-queue.ts:316`) into `FileJobStore.get()`, or directly into `FileJobStore.delete()`, where `join(this.dir, id + '.json')` normalizes the traversal to a location outside `this.dir`.
- Guard: No normalization-and-containment check, separator rejection, or allowlist exists on the store methods or the queue wrappers.
- Primitive: The resolved path reaches `readFile()` at `lib/job-queue.ts:178` or `unlink()` at `:187`.
- Result: Arbitrary `.json` file read (contents returned) or arbitrary `.json` file deletion, within process filesystem permissions.
Bypass Evidence
No relevant guard or prior fix protects this code path. The published advisory for this package addressed the same class of relative path traversal in `EnvironmentManager.restore()` by adding an identifier regex and a resolved-directory containment assertion in `lib/env-manager.ts`; that remediation is scoped exclusively to `restore()` and does not touch `lib/job-queue.ts`. An exhaustive search of `lib/job-queue.ts` for `resolve`, `dirname`, `startsWith`, `sanitiz`, `validat`, `check`, `regex`, and `.test(` returned no matches on the lookup or delete path. The strongest counter-argument, that identifiers are always internally generated, holds only for the creation path via `enqueue()`; the `get()`, `getJob()`, `cancel()`, and `delete()` entry points accept arbitrary strings, as the `IJobStore` interface (`lib/job-queue.ts:134-149`) declares. Note that `delete()` is reached as a public method on the exported class rather than via `cancel()`, which calls only `get()` and `save()`.
Affected Versions
- Ecosystem: `npm`
- Package: `network-ai`
- Confirmed affected range: `>= 5.13.4, <= 5.15.4`
- Latest release checked: `5.15.4` (npm registry
https://www.npmjs.com/package/network-ai) - Fix status: not fixed
The `lib/job-queue.ts` module first appears in release `5.13.4`; it is absent from `5.13.3` and earlier. The vulnerable code is present and unchanged through the latest published release `5.15.4` (git tag `v5.15.4`). No fix for this code path has been released.
Suggested Fix
Enforce that the resolved job path remains inside the configured directory before any filesystem operation in `get()`, `delete()`, and `save()`, and in the `JobQueue` wrappers that forward an external identifier. Validate `id` against a strict identifier allowlist (for example `/^[\w-]+$/`) that rejects path separators and `..`, and additionally assert that `dirname(resolve(join(this.dir, id + '.json'))) === resolve(this.dir)` so that encoded or platform-specific separator variants cannot escape. Mirror the containment approach already used for `EnvironmentManager.restore()`.
---
Reported by zx.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmnetwork-ai |
Corregida | 5.15.5 | 0 d | 6.0.1 no afectada |
5.15.5Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/Jovancoding/Network-AI/security/advisories/GHSA-v64j-mc7x-c7x7Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
