T08 · Insecure Dependencies
- Location
scripts/publish_and_verify.py:22- Finding
Automatic Global Installation of an Unpinned npm Dependency
- Content
View full analysis
bool: if shutil.which("wenyan") is None: print(f"{RED}wenyan-cli 未安装,正在安装...{NC}") try: subprocess.run(["npm", "install", "-g", "@wenyan-md/cli"], check=True, capture_output=False) print(f"{GREEN}wenyan-cli 安装成功!{NC}") except (subprocess.CalledProcessError, FileNotFoundError): print(f"{RED}安装失败!请手动运行: npm install -g @wenyan-md/cli{NC}") return False return True ``` ### Technical Analysis The publishing script automatically installs the latest available version of `@wenyan-md/cli` from the npm registry when the `wenyan` executable is unavailable. The dependency is not pinned to an audited version, and no package integrity value is verified. npm packages can execute lifecycle scripts during installation. Therefore, a compromised package release, maintainer account, transitive dependency, or registry response could cause arbitrary code to run with the permissions of the user executing the Skill. The global `-g` installation also modifies the user's global npm environment rather than limiting the dependency to an isolated project directory. The resulting executable is subsequently invoked with an environment containing `WECHAT_APP_ID` and `WECHAT_APP_SECRET`, increasing the sensitivity of the dependency trust boundary. ### Attack Path 1. An attacker compromises `@wenyan-md/cli`, one of its transitive dependencies, or an authorized package publisher. 2. The attacker publishes a malicious version or adds a malicious installation lifecycle script. 3. A user without an existing `wenyan` executable invokes `publish_and_verify.py`. 4. `check_wenyan()` downloads and globally installs the current package version without confirmation, version pinning, or ...[truncated 730 chars]- Remediation
View remediation
