T08 · Insecure Dependencies
- Location
python/agent-sdk/patterns.md:162- Finding
Unpinned MCP packages are downloaded and executed through npx
- Content
View full analysis
- Remediation
View remediation
"] } ``` ```python "postgres": { "command": "npx", "args": ["--no-install", "@modelcontextprotocol/server-postgres@"], "env": {"DATABASE_URL": restricted_database_url} } ``` 2. Install MCP dependencies separately through a lockfile-controlled package manifest. Review the resolved dependency tree before execution. 3. Use `npx --no-install` after installation so agent startup cannot silently fetch new code. 4. Commit and enforce lockfiles, and use npm integrity metadata or an internal artifact registry to ensure reviewed artifacts are executed. 5. Remove `@latest`, unversioned package identifiers, and `-y` from copy-ready security-sensitive examples. 6. Run external MCP servers in an isolated container or sandbox with: - A read-only filesystem where possible. - A narrowly scoped working directory. - Restricted outbound network access. - No unrelated environment variables. - Resource and process limits. 7. Create a dedicated, least-privileged database account for the PostgreSQL MCP server. Prefer read-only access restricted to necessary schemas and tables. 8. Avoid forwarding the application's primary `DATABASE_URL`. Supply a dedicated credential through an isolated secret mechanism and rotate it if package compromise is suspected. 9. Document that MCP servers are locally executed third-party programs and require the same dependency review as any other executable component. ]]>
