T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/check-axios-risk.sh:70
- Finding
- Automatic Destructive Dependency Remediation Without User Confirmation<![CDATA[ ## Vulnerability Details **File Location**: `scripts/check-axios-risk.sh`, lines 70–80 **Vulnerability Type**: Destructive and nondeterministic dependency remediation **Risk Level**: High ### Vulnerable Code ```bash # 修复步骤1:卸载恶意包 echo -e "${YELLOW}→ 卸载恶意 axios & plain-crypto-js...${NC}" npm uninstall axios plain-crypto-js 2>/dev/null || true # 修复步骤2:清理缓存 + 重装官方稳定版 echo -e "${YELLOW}→ 安装官方安全版本 axios(最新稳定版)...${NC}" npm install axios@latest --save # 修复步骤3:清理 node_modules + 重新安装(彻底清除残留) echo -e "${YELLOW}→ 清理依赖并重新安装...${NC}" rm -rf node_modules package-lock.json yarn.lock pnpm-lock.yaml 2>/dev/null || true npm install 2>/dev/null || true ``` ### Technical Analysis Detection of any configured indicator immediately initiates destructive project modification without displaying a proposed plan or requesting confirmation. The script uninstalls dependencies, installs a mutable `latest` package version, deletes all supported lockfiles, removes the installed dependency tree, and resolves the project's dependencies again. Deleting lockfiles removes the integrity and version constraints that provide reproducible installations. The subsequent `npm install` can therefore resolve versions different from those previously reviewed or tested. In addition, npm installation can execute lifecycle scripts from resolved packages with the privileges of the user running this Skill. The use of `axios@latest` is nondeterministic. It does not identify a specific reviewed version and can introduce breaking changes or supply-chain risk if the registry package changes after the Skill itself was audited. These actions are also performed when the detected indicator is only one of the absolute system files, even if no malicious npm dependency was found. ### Attack Path 1. The user runs `bash ./scripts/check-axios-risk.sh`. 2. One configured indicator is detected, such as a matching dependency version or one of the hard-coded system file paths. 3. The script automatically unin ...[truncated 877 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Make the default behavior report-only and require an explicit remediation flag, such as `--remediate`. 2. Present all planned file and dependency changes and require interactive confirmation before destructive operations. 3. Do not delete lockfiles automatically. Preserve the lockfile and use the package manager already associated with the project. 4. Pin remediation to an exact, independently reviewed package version instead of using `axios@latest`. 5. Use lock-preserving installation mechanisms such as `npm ci` where appropriate. 6. Consider disabling dependency lifecycle scripts during initial recovery, for example through `--ignore-scripts`, followed by a reviewed rebuild procedure. 7. Back up the manifest and lockfile before making changes and restore them if remediation fails. 8. Separate dependency remediation from host-level incident response so that a system-file indicator does not automatically rewrite project dependencies. ]]>
