T08 · Insecure Dependencies
- Location
- scripts/weibo-utils.ts:117
- Finding
- Unpinned Runtime Package Is Automatically Downloaded and Executed<![CDATA[ ## Vulnerability Details **File Location**: `scripts/weibo-utils.ts:117-120`; additionally declared in `SKILL.md:22-27` **Vulnerability Type**: Supply-chain exposure through unpinned package execution **Risk Level**: High ### Complete Vulnerable Code Snippet ```ts function runBunScript(scriptPath: string, args: string[]): boolean { const result = spawnSync('npx', ['-y', 'bun', scriptPath, ...args], { stdio: 'inherit' }); return result.status === 0; } ``` The corresponding execution instruction is: ```text **Agent Execution Instructions**: 1. Determine this SKILL.md file's directory path as `{baseDir}` 2. Script path = `{baseDir}/scripts/<script-name>.ts` 3. Replace all `{baseDir}` in this document with the actual path 4. Resolve `${BUN_X}` runtime: if `bun` installed → `bun`; if `npx` available → `npx -y bun`; else suggest installing bun ``` ### Technical Analysis The helper invokes `npx -y bun` without specifying an exact package version or enforcing a lockfile and integrity hash. The `-y` option suppresses confirmation, allowing `npx` to resolve, download, and execute the package automatically. Consequently, the effective executable is not completely fixed to the code that was audited. Its behavior can change according to the configured package registry, package ownership, package version resolution, local npm configuration, or a future compromised package release. This path is used by the clipboard helpers during ordinary article composition, so the exposure is not limited to an optional development command. ### Attack Path 1. A user asks the Skill to compose a Weibo article containing HTML or images. 2. The article workflow calls `copyHtmlToClipboard`, `copyImageToClipboard`, or `pasteFromClipboard`. 3. These functions call `runBunScript`. 4. `runBunScript` executes `npx -y bun` without an exact version or integrity requirement. 5. If package resolution or the configured registry has been compromised, `npx` downloads and executes atta ...[truncated 790 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require a previously installed, trusted Bun executable and fail safely if it is unavailable. 2. Remove the automatic `npx -y` fallback from runtime workflows. 3. If package-based installation is unavoidable, pin an exact reviewed version rather than resolving the latest compatible release. 4. Commit and enforce a lockfile containing package integrity metadata. 5. Use a trusted registry explicitly and validate downloaded package integrity. 6. Resolve the executable to an expected absolute path before execution. 7. Document runtime installation as a separate, user-approved prerequisite instead of downloading executable code while handling article content. 8. Consider implementing clipboard operations directly in the primary process so that routine article composition does not invoke a package manager. ]]>
