T08 · Insecure Dependencies
Error
- Location
- scripts/guarded_flow.py:90
- Finding
- Installation and update operations execute untrusted package code before security approval<![CDATA[ ## Vulnerability Details **File Location**: `scripts/guarded_flow.py:90-124` **Vulnerability Type**: Unsafe package installation and update ordering **Risk Level**: High ### Vulnerable Code ```python def command_npx_add(args: argparse.Namespace) -> int: policy = load_policy(args.policy) roots = default_scan_roots(policy) before = snapshot_roots(roots) command = [args.npx_bin, "skills", "add", args.package] if args.global_install: command.append("-g") if args.yes: command.append("-y") if args.extra_args: command.extend(args.extra_args) exit_code = run_command(command, WORKSPACE) if exit_code != 0: return exit_code after = snapshot_roots(roots) changed = detect_changed_dirs(before, after) for skill_dir in changed: ensure_safe(skill_dir, policy, "install") return 0 def command_npx_update(args: argparse.Namespace) -> int: policy = load_policy(args.policy) roots = default_scan_roots(policy) before = snapshot_roots(roots) command = [args.npx_bin, "skills", "update"] if args.extra_args: command.extend(args.extra_args) exit_code = run_command(command, WORKSPACE) if exit_code != 0: return exit_code after = snapshot_roots(roots) changed = detect_changed_dirs(before, after) if not changed: changed = [path for root in roots for path in root.iterdir() if path.is_dir()] for skill_dir in changed: ensure_safe(skill_dir, policy, "update") return 0 ``` ### Technical Analysis Both guarded package workflows invoke the real package manager before calling `ensure_safe()`. Consequently, the scan is a post-installation or post-update check rather than a security gate. Package managers and their wrappers can execute lifecycle hooks, installer scripts, or other package-controlled behavior during installation and update. Such code may run before the package files appear in the monitored skill directorie ...[truncated 1776 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Acquire packages without executing lifecycle scripts, and unpack them into a newly created staging directory. 2. Perform static and AI auditing against the staged package before any installation command or package-controlled script executes. 3. Promote only approved files from staging into the destination using an atomic replacement operation. 4. If package-manager execution is unavoidable, run it in a sandbox with: - No inherited credentials or unnecessary environment variables. - Network access disabled or restricted to explicitly required registries. - A read-only host filesystem except for an isolated staging directory. - A dedicated unprivileged user and strict resource limits. 5. Disable lifecycle hooks during acquisition, using the package manager's equivalent of `--ignore-scripts`, and separately audit any scripts before explicitly permitting them. 6. Verify package integrity through immutable version pinning, cryptographic hashes, or signed provenance. 7. On failed audits, delete the isolated staging directory rather than attempting to remediate an already active installation. ]]>
