Summary
Network-AI's backup pruning logic previously trusted a path field from on-disk backup manifests and passed it directly to a recursive delete operation.
If an attacker can create or modify _manifest.json files within the backups directory, they can cause env backup prune to recursively delete arbitrary files and directories accessible to the Network-AI process.
Affected context
This vulnerability appears in Network-AI deployments where backup metadata is stored on disk under data/<env>/.backups/<name>/_manifest.json, and those manifests are later consumed by EnvironmentManager.listBackups() and EnvironmentManager.pruneBackups().
It is relevant in environments where backups may be accessible to other processes, plugins, or users that can write or modify manifest files.
The risk increases when Network-AI runs with broad filesystem permissions, especially on shared or multi-tenant systems.
Exploit preconditions
- Attack surface: Backup manifest files located under
data/<env>/.backups/<name>/_manifest.json - Required access: Ability to create, replace, or modify
_manifest.jsonfor one or more backups (local user, compromised plugin, or misconfigured permissions) - Trigger point: Execution of
network-ai env backup prune --env <env> --keep <n>or any code path that callsEnvironmentManager.pruneBackups() - Why exploitation is possible: The
pathfield from the manifest is treated as trusted and passed directly intormSync(entry.path, { recursive: true, force: true })without validation or containment checks, enabling deletion outside the intended backup directory.
Why this happens
The core issue is blind trust in file system metadata sourced from on-disk JSON manifests.
EnvironmentManager.listBackups() reads _manifest.json and treats the manifest's path as authoritative, passing it unchanged to EnvironmentManager.pruneBackups(), which invokes rmSync() with recursive and force options.
This behavior exemplifies CWE-22: Improper Limitation of a Path to a Restricted Directory, combined with CWE-73: External Control of File Name or Path, because an attacker can control the path string in the manifest and cause operations intended for a restricted backup directory to target arbitrary locations on the filesystem.
Potential impact
- Recursive deletion of arbitrary directories accessible to the Network-AI process user
- Loss of application data, configuration, or logs stored outside the backup directory
- Destruction of other services' data on shared hosts, depending on filesystem layout and permissions
- Potential denial-of-service by deleting critical runtime files or directories
General mitigation guidance
Effective mitigation focuses on constraining file operations to trusted directories and deriving paths from validated identifiers rather than untrusted metadata.
Pattern-based defenses include:
- Recomputing filesystem paths from canonical, validated IDs (such as
backupId) rather than trusting serializedpathfields. - Enforcing strict containment checks (e.g., verifying that target paths are direct descendants of the expected backups root and rejecting any that escape via absolute paths or
..segments). - Applying normalization to paths before use and comparing against a known-safe base directory to detect traversal attempts.
- Running the Network-AI service under an account with least privilege, limiting its ability to delete or modify directories outside its own data hierarchy.
- Avoiding
forceand broadrecursivedeletion of paths derived from external or user-controlled inputs unless guardrails and validation are in place.
How teams detect issues like this
Organizations can detect similar path-based vulnerabilities by:
- Using static analysis rules to flag uses of file APIs like
rmSync,fs.rm, orfs.unlinkwhere the path originates from configuration files, manifests, or other external inputs without validation. - Employing code review checklists that highlight any use of user-controlled paths in recursive delete or move operations, and verifying containment logic around base directories.
- Implementing application-level assertions or logging that record deletion targets, then monitoring for anomalies such as deletions outside the backups directory.
- Incorporating automated security testing tools that exercise backup and restore flows with crafted manifests to validate that access is confined to expected directories.

