AgentsConfigHelper / rules
Cursor rule2 starsChanged 3 months agoMITView on GitHub
API & Web services security (REST/GraphQL/SOAP), schema validation, authn/z, SSRF
We split this codeguard-0-api-web-services.mdc into the rules it gives an agent
5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Use standard flows (OAuth2/OIDC) for clients.
- Distinctive: line 30
Use parameterized queries/ORM bind parameters.
- Distinctive: line 37
Do not accept raw URLs. Validate domains/IPs using libraries.
- Distinctive: line 49
Do not expose over the Internet.
- Distinctive: line 72
Test all HTTP methods per endpoint.
≈ “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: API & Web services security (REST/GraphQL/SOAP), schema validation, authn/z, SSRF globs: **/*.c,**/*.go,**/*.h,**/*.java,**/*.js,**/*.jsx,**/*.mjs,**/*.php,**/*.py,**/*.pyi,**/*.pyx,**/*.rb,**/*.ts,**/*.tsx,**/*.wsdl,**/*.xml,**/*.xsd,**/*.xslt,**/*.yaml,**/*.yml version: 1.0.1 --- rule_id: codeguard-0-api-web-services ## API & Web Services Security Secure REST, GraphQL, and SOAP/WS services end‑to‑end: transport, authn/z, schema validation, SSRF controls, DoS limits, and microservice‑safe patterns. ### Transport and TLS - HTTPS only; consider mTLS for high‑value/internal services. Validate certs (CN/SAN, revocation) and prevent mixed content. ### Authentication and Tokens - Use standard flows (OAuth2/OIDC) for clients; avoid custom schemes. For services, use mTLS or signed service tokens. - JWTs: pin algorithms; validate iss/aud/exp/nbf; short lifetimes; rotation; denylist on logout/revoke. Prefer opaque tokens when revocation is required and central store is available. - API keys: scope narrowly; rate limit; monitor usage; do not use alone for sensitive operations. ### Authorization - Enforce per‑endpoint, per‑resource checks server‑side; deny by default. - For microservices, authorize at gateway (coarse) and service (fine) layers; propagate signed internal identity, not external tokens. ### Input and Content Handling - Validate inputs via contracts: OpenAPI/JSON Schema, GraphQL SDL, XSD. Reject unknown fields and oversize payloads; set limits. - Content types: enforce explicit Content‑Type/Accept; reject unsupported combinations. Harden XML parsers against XXE/expansion. ### SQL/Injection Safety in Resolvers and Handlers - Use parameterized queries/ORM bind parameters; never concatenate user input into queries or commands. ### GraphQL‑Specific Controls - Limit query depth and overall complexity; enforce pagination; timeouts on execution; disable introspection and IDEs in production. - Implement field/object‑level authorization to prevent IDOR/BOLA; validate batching and rate limit per object type. ### SSRF Prevention for Outbound Calls - Do not accept raw URLs. Validate domains/IPs using libraries; restrict to HTTP/HTTPS only (block file://, gopher://, ftp://, etc.). - Case 1 (fixed partners): strict allow‑lists; disable redirects; network egress allow‑lists. - Case 2 (arbitrary): block private/link‑local/localhost ranges; resolve and verify all IPs are public; require signed tokens from the target where feasible. ### SOAP/WS and XML Safety - Validate SOAP payloads with XSD; limit message sizes; enable XML signatures/encryption where required. - Configure parsers against XXE, entity expansion, and recursive payloads; scan attachments. ### Rate Limiting and DoS - Apply per‑IP/user/client limits, circuit breakers, and timeouts. Use server‑side batching and caching to reduce load. ### Management Endpoints - Do not expose over the Internet. Require strong auth (MFA), network restrictions, and separate ports/hosts. ### Testing and Assessment - Maintain formal API definitions; drive contract tests and fuzzing from specs. - Assess endpoints for authn/z bypass, SSRF, injection, and information leakage; log token validation failures. ### Microservices Practices - Policy‑as‑code with embedded decision points; sidecar or library PDPs. - Service identity via mTLS or signed tokens; never reuse external tokens internally. - Centralized structured logging with correlation IDs; sanitize sensitive data. ### Implementation Checklist - HTTPS/mTLS configured; certs managed; no mixed content. - Contract validation at the edge and service; unknown fields rejected; size/time limits enforced. - Strong authn/z per endpoint; GraphQL limits applied; introspection disabled in prod. - SSRF protections at app and network layers; redirects disabled; allow‑lists where possible. - Rate limiting, circuit breakers, and resilient patterns in place. - Management endpoints isolated and strongly authenticated. - Logs structured and privacy‑safe with correlation IDs. ### Test Plan - Contract tests for schema adherence; fuzzing with schema‑aware tools. - Pen tests for SSRF, IDOR/BOLA, and authz bypass; performance tests for DoS limits. - Test all HTTP methods per endpoint; discover parameters in URL paths, headers, and structured data beyond obvious query strings. - Automated checks for token validation and revocation behavior.
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 repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/codeguard-0-additional-cryptography.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
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

