T08 · Insecure Dependencies
Warning
- Location
- scripts/setup.mjs:11
- Finding
- Unverified Third-Party Execution and Mutable Out-of-Package Fallback<![CDATA[ ## Vulnerability Details **File Locations**: - `scripts/package.json:6-8` - `scripts/setup.mjs:11-23` - `scripts/start-mcp.mjs:9-30` - `scripts/start-watcher.mjs:9-27` - `SKILL.md:34-44` - `BOT.md:2-3,6` - `ELIZA-COMPANION.md:6-10` - `NAUTILUS-SIDECAR.md:6-18,56-66` **Vulnerability Type**: Execution of unverified dependency code and an external local fallback **Risk Level**: Medium ### Vulnerable Code `scripts/package.json:6-8` declares the executable third-party dependency without an accompanying lockfile in the audited project: ```json "dependencies": { "@hypelens/hypelens-agent-guard": "0.1.18" } ``` `scripts/setup.mjs:11-23` dynamically imports the dependency and falls back to JavaScript outside the project package: ```js 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); ``` `scripts/start-mcp.mjs:9-30` imports an executable selected by package metadata and falls back after any caught dependency error: ```js try { const pkgJson = require.resolve('@hypelens/hypelens-agent-guard/package.json'); const pkg = require(pkgJson); const binRel = (pkg.bin && (pkg.bin['agent-guard-mcp'] || pkg.bin['agent-guard'])) || 'bin/agent-guard-mcp.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-mcp.js', ); await import(pathToFileURL(localEntry).href); } catch { console.error('Missing dep ...[truncated 4872 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Establish dependency integrity** - Commit a generated lockfile containing resolved package URLs and npm integrity hashes. - Require reproducible installation with `npm ci`. - Verify the expected package integrity in CI before publication and deployment. - Maintain an audited software bill of materials for the executable dependency and its transitive dependencies. 2. **Avoid direct `npx` execution for wallet-sensitive operations** - Install reviewed dependencies from a lockfile before runtime. - Execute the verified local installation rather than allowing installation and execution to occur in one command. - Consider vendoring the security-critical launcher implementation so that the reviewed artifact contains the effective code. 3. **Remove or secure the external fallback** - Remove the `../../bin` fallback paths if they are not strictly required. - If a fallback is necessary, resolve it from a canonical trusted installation root. - Use `realpath` and verify that the resolved executable remains inside an approved directory. - Verify a cryptographic digest or signature before importing fallback code. - Refuse execution when ownership or filesystem permissions permit modification by untrusted users. 4. **Narrow error handling** - Separate dependency resolution from dependency execution. - Fall back only for a specifically identified module-not-found condition. - Do not switch executable sources after syntax errors, initialization failures, or exceptions thrown by imported dependency code. 5. **Constrain package metadata paths** - Validate that the selected `pkg.bin` target resolves inside the verified package directory. - Reject absolute paths and paths that escape the package directory. 6. **Reduce credential exposure** - Run the watcher under a dedicated operating-system account with minimal filesystem access. - Use a narrowly scoped trading key or wallet permiss ...[truncated 373 chars]
