AI-agents-for-cybersecurity / rules
Cursor rule256 starsChanged 20 days agoBSD-3-ClauseView on GitHub
MCP (Model Context Protocol) Security based on CoSAI MCP Security guidelines
We split this codeguard-0-mcp-security.mdc into the rules it gives an agent
16 rules. About 0 are common, 15 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈15
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
NEVER deploy MCP servers or clients without implementing proper security controls.
- Distinctive: line 14
Use SPIFFE/SPIRE for cryptographic workload identities
- Distinctive: line 21
Use parameterized queries for database operations
- Distinctive: line 24
Treat ALL inputs, tool schemas, metadata, prompts, and resource content as untrusted input
- Distinctive: line 26
Use strict JSON schemas to maintain boundaries between instructions and data
- Distinctive: line 37
Use TLS for ALL data in transit
- Distinctive: line 59
Create single-purpose tools with explicit boundaries.
- Distinctive: line 60
Do not rely on the LLM for validation or authorization decisions
- Distinctive: line 61
Use two-stage commit for high-impact actions: draft/preview first, explicit commit with confirmation second
- Distinctive: line 66
Use elicitation on MCP server side to request user confirmation of risky actions
- Distinctive: line 68
Do NOT rely solely on human approval (users can become fatigued)
- Distinctive: line 73
Use OpenTelemetry for end-to-end linkability of actions
- Very specific: line 82
Use stdio transport to avoid DNS rebinding risks
- Distinctive: line 83
Use sandboxing to limit privilege escalation attacks
- Distinctive: line 88
Use secure credential storage (OS keychains, secret managers)
- Distinctive: line 95
Prefer MCP servers hosted directly by service provider
≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
--- description: MCP (Model Context Protocol) Security based on CoSAI MCP Security guidelines globs: **/*.go,**/*.java,**/*.js,**/*.jsx,**/*.mjs,**/*.py,**/*.pyi,**/*.pyx,**/*.rs,**/*.ts,**/*.tsx version: 1.5.0 --- rule_id: codeguard-0-mcp-security # MCP (Model Context Protocol) Security Guidelines NEVER deploy MCP servers or clients without implementing proper security controls. ### Workload Identity and Authentication - Use SPIFFE/SPIRE for cryptographic workload identities - SPIFFE (Secure Production Identity Framework For Everyone) provides a standard for service identity - SPIRE (SPIFFE Runtime Environment) issues and rotates short-lived cryptographic identities (SVIDs) ### Input and Data Sanitization - Validate ALL inputs using allowlists at every trust boundary - Sanitize file paths through canonicalization - Use parameterized queries for database operations - Apply context-aware output encoding (SQL, shell, HTML) - Sanitize tool outputs: return only minimum fields, redact all PII and sensitive data - Treat ALL inputs, tool schemas, metadata, prompts, and resource content as untrusted input - Deploy prompt injection detection systems - Use strict JSON schemas to maintain boundaries between instructions and data ### Sandboxing and Isolation - Design MCP servers to execute with least privilege - MCP servers interacting with host environment (files, commands, network) MUST implement sandboxing controls - LLM-generated code MUST NOT run with full user privileges - Implement additional sandboxing layers: gVisor, Kata Containers, SELinux sandboxes ### Cryptographic Verification of Resources - Provide cryptographic signatures and SBOMs for all server code - Implement signature verification in your MCP client before loading servers - Use TLS for ALL data in transit - Implement remote attestation capabilities to verify servers are running expected code ### Transport Layer Security #### stdio Transport (Local Servers) - STRONGLY RECOMMENDED for local MCP to eliminate DNS rebinding risks - Direct pipe-based stream communication - Implement sandbox to prevent privilege escalation #### HTTP Streaming Transport (Remote Servers) Required security controls to implement: - Payload Limits (prevent large payload and recursive payload DoS) - Rate limiting for tool calls and transport requests - Client-Server Authentication/Authorization - Mutual TLS Authentication - TLS Encryption - CORS Protection - CSRF Protection - Integrity Checks (prevent replay, spoofing, poisoned responses) ### Secure Tool and UX Design - Create single-purpose tools with explicit boundaries; avoid "do anything" tools - Do not rely on the LLM for validation or authorization decisions - Use two-stage commit for high-impact actions: draft/preview first, explicit commit with confirmation second - Provide rollback/undo paths (draft IDs, snapshots, reversible actions) and time-bound commits when possible ### Human-in-the-Loop - Implement confirmation prompts for risky operations in your MCP server - Use elicitation on MCP server side to request user confirmation of risky actions - Security-relevant messages MUST clearly indicate implications - Do NOT rely solely on human approval (users can become fatigued) ### Logging and Observability - Implement logging in your MCP servers and clients - Log: tools that were used, parameters, originating prompt - Use OpenTelemetry for end-to-end linkability of actions - Maintain immutable records of actions and authorizations --- ## Deployment Pattern Security ### All-Local (stdio or http) - Security depends entirely on host system posture - Use `stdio` transport to avoid DNS rebinding risks - Use sandboxing to limit privilege escalation attacks - Appropriate for development and personal use ### Single-Tenant Remote (http) - Authentication between client and server is REQUIRED - Use secure credential storage (OS keychains, secret managers) - Communication MUST be authenticated and encrypted - Enterprise clients should enforce authenticated server discovery with explicit allowlists ### Multi-Tenant Remote (http) - Require robust tenant isolation, identity, and access control - Implement strong multi-tenancy controls (per-tenant encryption, role-based access control) - Prefer MCP servers hosted directly by service provider - Provide remote attestation when possible
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 3,978 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository25 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .cursor/rules/codeguard-0-additional-cryptography.mdcCursor rule
- .cursor/rules/codeguard-0-api-web-services.mdcCursor rule
- .cursor/rules/codeguard-0-authentication-mfa.mdcCursor rule
- .cursor/rules/codeguard-0-authorization-access-control.mdcCursor rule
- .cursor/rules/codeguard-0-client-side-web-security.mdcCursor rule
- .cursor/rules/codeguard-0-cloud-orchestration-kubernetes.mdcCursor rule
- .cursor/rules/codeguard-0-data-storage.mdcCursor rule
- .cursor/rules/codeguard-0-devops-ci-cd-containers.mdcCursor rule
- .cursor/rules/codeguard-0-file-handling-and-uploads.mdcCursor rule
- .cursor/rules/codeguard-0-framework-and-languages.mdcCursor rule
- .cursor/rules/codeguard-0-iac-security.mdcCursor rule
- .cursor/rules/codeguard-0-input-validation-injection.mdcCursor rule
- .cursor/rules/codeguard-0-logging.mdcCursor rule
- .cursor/rules/codeguard-0-mobile-apps.mdcCursor rule
- .cursor/rules/codeguard-0-privacy-data-protection.mdcCursor rule
- .cursor/rules/codeguard-0-safe-c-functions.mdcCursor rule
- .cursor/rules/codeguard-0-session-management-and-cookies.mdcCursor rule
- .cursor/rules/codeguard-0-supply-chain-security.mdcCursor rule
- .cursor/rules/codeguard-0-xml-and-serialization.mdcCursor rule
- .cursor/rules/codeguard-1-crypto-algorithms.mdcCursor rule
- .cursor/rules/codeguard-1-digital-certificates.mdcCursor rule
- .cursor/rules/codeguard-1-hardcoded-credentials.mdcCursor rule
- codeguardSkill
- codeguardSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

