T08 · Insecure Dependencies
- Location
scripts/publish.py:29- Finding
Automatic Global Installation of an Unpinned npm Dependency
- Content
View full analysis
bool: """检查 wenyan-cli 是否安装,未安装则自动安装""" if shutil.which("wenyan") is None: print(f"{RED}wenyan-cli 未安装!{NC}") print(f"{YELLOW}正在安装 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 ``` The same unpinned command is also recommended in `SKILL.md`, lines 50-51, and `references/troubleshooting.md`, lines 33-42. ### Technical Analysis When the `wenyan` executable is unavailable, ordinary Skill execution automatically runs: ```bash npm install -g @wenyan-md/cli ``` No exact package version, lockfile, package integrity hash, or trusted artifact digest is specified. Consequently, the code installed depends on the package registry's current state rather than the version that was reviewed with this project. npm packages may execute lifecycle scripts during installation. A compromised package release, maintainer account, transitive dependency, or registry response could therefore cause arbitrary code to execute during installation. The global `-g` option also modifies the invoking user's global Node.js environment outside the project directory. The npm child process inherits the parent process environment by default. This may expose WeChat credentials and other unrelated environment variables to malicious package lifecycle scripts. ### Attack Path 1. An attacker compromises `@wenyan-md/cli`, one of its dependencies, i ...[truncated 1154 chars]- Remediation
View remediation
