GHSA-6x2m-p4xp-wg22: Network-AI EnvironmentManager.backup() Follows Symlinked Directories And Vulnerability

MODERATE
CVSS 5.5
CWE-59 CWE-22
Published
Advisory Summary

GHSA-6x2m-p4xp-wg22 is a MODERATE (CVSS 5.5) environmentmanager.backup() follows symlinked directories and vulnerability (CWE-59: Improper Link Resolution Before File Access ('Link Following')) affecting Network-AI libraries in the npm ecosystem. The issue involves environmentmanager.backup() follows symlinked directories and copies files outside the environment root into backups. Remediation is available by upgrading affected packages to version 5.12.2.

GHSA-6x2m-p4xp-wg22 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-6x2m-p4xp-wg22
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-59: Improper Link Resolution Before File Access ('Link Following')
Affected Product Network-AI
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix GHSA-6x2m-p4xp-wg22

To remediate this vulnerability, upgrade all affected Network-AI dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

network-ai fixed: 5.12.2
npm install network-ai@5.12.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls network-ai

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-6x2m-p4xp-wg22, inspect your project dependencies using npm:

npm ls network-ai

Analyze the terminal output to locate any version of Network-AI in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.12.2), your application is affected.

Note: The npm ls network-ai command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-59: Improper Link Resolution Before File Access ('Link Following'), where the product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource. In Network-AI, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary `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. Confirmed in Network-AI 5.12.1. ### Details `backup()` collects file paths and copies them into the backup directory: ```ts const files = this._collectBackupFiles(envDir); for (const rel of files) { const src = join(envDir, rel); const dst = join(backupPath, rel); mkdirSync(join(backupPath, rel.includes('/') ? rel.substring(0, rel.lastIndexOf('/')) : '.'), { recursive: true }); try { copyFileSync(src, dst); } catch { /* skip unreadable */ } } ``` `_collectBackupFiles()` follows symlinked directories because it calls `statSync()`, not `lstatSync()`: ```ts const info = statSync(full); if (info.isDirectory()) { walk(full, rel); } else { results.push(rel); } ``` Default CLI reachability exists through `network-ai env backup create --env <env>`. `backup()` also runs automatically before promotion and restore operations. Affected source evidence: - `lib/env-manager.ts:435-460` — backup copy logic. - `lib/env-manager.ts:596-617` — symlink-following `_collectBackupFiles()`. - `bin/cli.ts:413-420` — default CLI exposes backup creation. - `lib/env-manager.ts:294-297` and `483-484` — backup also runs before promote/restore. ### PoC This 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: ```bash TMP=$(mktemp -d) TMPBASE="$TMP" node -r ts-node/register/transpile-only - <<'TS' const { EnvironmentManager } = require('./lib/env-manager'); const fs = require('fs'); const path = require('path'); const base = process.env.TMPBASE; const data = path.join(base, 'data'); const outside = path.join(base, 'outside'); fs.mkdirSync(outside, { recursive: true }); fs.writeFileSync(path.join(outside, 'secret.txt'), 'secret-through-symlink'); const mgr = new EnvironmentManager(data, { chain: ['dev', 'st'], gates: { dev: 'auto', st: 'auto' }, }); mgr.init('dev'); fs.symlinkSync(outside, path.join(data, 'dev', 'linked-outside'), 'dir'); const result = mgr.backup('dev'); const copied = path.join(result.path, 'linked-outside', 'secret.txt'); console.log(JSON.stringify({ copied: fs.existsSync(copied), content: fs.readFileSync(copied, 'utf8'), }, null, 2)); fs.rmSync(base, { recursive: true, force: true }); TS ``` Observed result: `copied` is `true` and `content` is `secret-through-symlink`. ### Impact An 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. --- ### Resolution (maintainer) **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. `_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. All 3,269 tests pass against the patched build. Thanks to @sondt99 for the responsible disclosure.

GHSA-6x2m-p4xp-wg22 Affected Network-AI Versions

1 component(s)
Fixed Versions:
5.12.2
Product / Package Ecosystem Affected Versions Fixed Version
network-ai
npm
< 5.12.2
5.12.2

References

Frequently Asked Questions

What is GHSA-6x2m-p4xp-wg22?
GHSA-6x2m-p4xp-wg22 is a security vulnerability in Network-AI involving EnvironmentManager.backup() follows symlinked directories and copies files outside the environment root into backups under CWE-59: Improper Link Resolution Before File Access ('Link Following').
Which Network-AI versions are affected?
Affected versions include releases prior to 5.12.2 across affected packages: network-ai.
What version fixes GHSA-6x2m-p4xp-wg22?
Upgrading to 5.12.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is network-ai affected?
Yes, network-ai is affected in releases prior to 5.12.2. Upgrade your dependency to 5.12.2 or later.
What is the CVSS score of GHSA-6x2m-p4xp-wg22?
GHSA-6x2m-p4xp-wg22 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with GHSA-6x2m-p4xp-wg22?
GHSA-6x2m-p4xp-wg22 is classified under CWE-59: Improper Link Resolution Before File Access ('Link Following') (The product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.).
How can I check npm dependencies for GHSA-6x2m-p4xp-wg22?
Run the dependency tree command: 'npm ls network-ai'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-6x2m-p4xp-wg22",
  "modified" : "2026-06-19T21:42:36Z",
  "published" : "2026-06-19T21:42:36Z",
  "aliases" : [ ],
  "summary" : "Network-AI: EnvironmentManager.backup() follows symlinked directories and copies files outside the environment root into backups",
  "details" : "### 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "network-ai"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.12.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.12.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Jovancoding/Network-AI/security/advisories/GHSA-6x2m-p4xp-wg22"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Jovancoding/Network-AI/commit/a59c13a1f0ce0e8a0779a90343eef92fac5ab4c3"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Jovancoding/Network-AI"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Jovancoding/Network-AI/releases/tag/v5.12.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22", "CWE-59" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-19T21:42:36Z",
    "nvd_published_at" : null
  }
}