T08 · Insecure Dependencies
Error
- Location
- scripts/setup.mjs:11
- Finding
- Security-Critical Wallet and Trading Operations Are Delegated to an Unreviewed Third-Party Package<![CDATA[ ## Vulnerability Details **File Location**: `scripts/setup.mjs:11-22`; related launch paths in `scripts/start-watcher.mjs:9-23`, `scripts/start-mcp.mjs:9-26`, and dependency declaration in `scripts/package-lock.json:701-718` **Vulnerability Type**: Third-party supply-chain trust and dynamic execution **Risk Level**: High ### Vulnerable Code ```javascript let entry; try { const pkgJson = require.resolve('@hypelens/hypelens-agent-guard/package.json'); entry = join(dirname(pkgJson), 'bin', 'agent-guard.js'); } catch { entry = join(scriptsDir, '..', '..', 'bin', 'agent-guard.js'); } if (!existsSync(entry)) { console.error('Missing @hypelens/hypelens-agent-guard. Run: npm install'); process.exit(1); } process.argv = [process.argv[0], entry, 'setup', '--scripts-dir', scriptsDir, ...process.argv.slice(2)]; await import(pathToFileURL(entry).href); ``` The watcher launcher similarly executes an entry point selected from the dependency's package metadata: ```javascript try { const pkgJson = require.resolve('@hypelens/hypelens-agent-guard/package.json'); const pkg = require(pkgJson); const binRel = (pkg.bin && pkg.bin['agent-guard-watcher']) || 'bin/agent-guard-watcher.js'; const entry = join(dirname(pkgJson), binRel); await import(pathToFileURL(entry).href); } catch (e) { try { const localEntry = join( dirname(fileURLToPath(import.meta.url)), '..', '..', 'bin', 'agent-guard-watcher.js', ); await import(pathToFileURL(localEntry).href); } catch { console.error('Missing dependency. Run: npm install (in this scripts/ folder)'); console.error(String(e && e.message ? e.message : e)); process.exit(1); } } ``` The dependency is locked as follows: ```json "node_modules/@hypelens/hypelens-agent-guard": { "version": "0.1.17", "resolved": "https://registry.npmjs.org/@hypelens/hypelens-agent-guard/-/hypelens-agent-guard-0.1.17.tgz", "integrity": "sha512-oDPjyJHHatIM69eiGCthlxtkKewFB8J ...[truncated 2854 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Include the security-critical dependency source in the review scope or vendor a reviewed copy of the relevant executable implementation. 2. Publish and verify reproducible build information for the npm artifact. 3. Retain exact dependency versions and integrity hashes, and use `npm ci` rather than an unconstrained installation workflow. 4. Document all network endpoints, files, environment variables, and wallet operations used by the dependency. 5. Run the watcher in a dedicated low-privilege account or container with a read-only filesystem where possible. 6. Restrict outbound network access to explicitly required Polymarket endpoints. 7. Scope the signer to a dedicated wallet with limited funds and permissions. 8. Require explicit operator confirmation before enabling live transaction execution. 9. Validate resolved executable paths against an allowlist instead of trusting mutable `package.json` `bin` metadata at runtime. ]]>
