T08 · Insecure Dependencies
- Location
- scripts/playwright_utils.py:19
- Finding
- Unscoped npx Fallback May Execute an Unintended Registry Package## Vulnerability Details **File Location**: `scripts/playwright_utils.py`, lines 19–24 **Vulnerability Type**: Dependency confusion caused by an incorrect package fallback **Risk Level**: High ### Vulnerable Code ```python def build_pw_command() -> list[str]: pw = resolve_command("playwright-cli") if pw: return [pw] npx = resolve_command("npx") if npx: return [npx, "playwright-cli"] raise RuntimeError( "playwright-cli is not installed. Install with: npm install -g @playwright/cli@latest" ) ``` The installation instructions identify the intended dependency as the scoped package `@playwright/cli`. However, when the `playwright-cli` executable is unavailable, the fallback invokes: ```text npx playwright-cli ``` This resolves the unscoped registry package named `playwright-cli`, not necessarily the documented `@playwright/cli` package. ### Technical Analysis The returned command is passed to `run_pw()`, where it is executed through `subprocess.run()` with the current Agent or user privileges. Although `shell=False` prevents shell metacharacter injection, it does not address package identity: `npx` may retrieve and execute code associated with the unintended unscoped package. The issue is reachable when all of the following conditions hold: 1. The Skill runs `extract_sac_deploy_info.py`. 2. No local `playwright-cli` executable is found. 3. `npx` is available. 4. The fallback command resolves the unscoped `playwright-cli` package from the configured npm registry. This is classified as an insecure dependency flaw rather than malicious behavior because the reviewed project contains no evidence that the authors control the resolved package or intentionally seek to execute a malicious payload. ### Attack Path 1. A user invokes the Skill’s solution-information extraction workflow. 2. `extract_sac_deploy_info.py` calls `build_pw_command()`. 3. The expected `playwright-cli` executable is absent, while `npx` is pres ...[truncated 1094 chars]
- Remediation
- ## Remediation Suggestions 1. Remove the automatic `npx` fallback and fail closed when the expected executable is unavailable. 2. If fallback execution is necessary, explicitly select the intended scoped package and pin its version, for example: ```python return [ npx, "--yes", "--package=@playwright/cli@<reviewed-version>", "playwright-cli", ] ``` 3. Keep the package version consistent with the installation guide and avoid `@latest` in automated execution paths. 4. Verify the resolved executable or package identity before execution. 5. Use a lockfile or controlled installation process where practical. 6. Run the extraction helper in a restricted environment that does not expose Huawei Cloud credentials unless they are required. 7. Document the exact trusted package name and version so installation and fallback behavior cannot diverge.
