Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/hamzaamjad/cursor-rules/433-backend-securitygit clone --depth 1 https://github.com/hamzaamjad/cursor-rulesWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.01104 |
| Opus 5 | $0.00000 | $0.00552 |
| Sonnet 5 | $0.00000 | $0.00221 |
| Haiku 4.5 | $0.00000 | $0.00110 |
Grade A, and why
433-backend-security scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 65 lines — stays where its author put it; the contents beside it link to each section on GitHub.
backend-security.mdc
- Purpose: To enforce fundamental security best practices for backend and API development, aligning with OWASP recommendations.
- Requirements:
- Input Validation: All external/untrusted data (request bodies, params, headers) MUST be validated and sanitized using a schema validation library (e.g.,
zod,pydantic,express-validator). Validate type, format, length, and range. - Authentication & Authorization:
- Use secure, framework-recommended session management (e.g., HTTPS-only, SameSite cookies).
- Implement proper authorization checks for all sensitive endpoints/operations.
- Rotate secrets (API keys, JWT secrets) periodically (default: quarterly, document exceptions). Store secrets securely (env vars loaded from vault/KMS in prod/stage,
.envfor local dev ONLY), never commit to VCS.
- SQL & Data Access:
- Use parameterized queries or ORM methods that prevent SQL injection by default.
- Direct use of raw SQL execution functions (e.g., ORM
.raw()) requires explicit justification and review for injection vulnerabilities.
- Error Handling:
- Return generic error messages/codes (e.g., HTTP 4xx/5xx) to clients.
- NEVER expose stack traces, sensitive configuration details, or PII in error responses. Log detailed errors internally.
- Logging:
- Include correlation IDs (
requestId,traceId) in logs. Include authenticateduserIdwhere applicable. - Scrub or mask sensitive data (passwords, PII, secrets) before logging payloads.
- Include correlation IDs (
- Rate Limiting: Implement rate limiting on public endpoints, especially authentication routes (e.g., per IP, per API key), with exponential backoff on failures.
- Dependency Management: Regularly scan dependencies for vulnerabilities (e.g., weekly
npm audit --prod/pip-audit). Patch Critical/High severity vulnerabilities promptly (define SLA, e.g., within 7 days). - Secrets Management: Use appropriate mechanisms for environment (e.g., Vault, AWS Secrets Manager, GCP Secret Manager for prod/stage;
.envfile loaded viadotenvfor local development ONLY). - (Placeholder) Incorporate specific checks from
@security-checklist.mdonce available.
- Input Validation: All external/untrusted data (request bodies, params, headers) MUST be validated and sanitized using a schema validation library (e.g.,
- Validation:
- Check (Static Analysis/Linting): Configure linters (e.g., ESLint security plugins, Bandit for Python) to detect common vulnerabilities like lack of input validation, use of raw SQL, insecure cookie settings.
- Check (Code Review): Explicitly review areas using raw SQL, handling sensitive data, authentication/authorization logic. Verify secret management practices. Verify presence of schema validation on input boundaries. Check error responses for information leakage.
- Check (Testing): Security tests should attempt to bypass validation, trigger errors, exploit potential injection points. Dependency scan results must be checked in CI.
- Check: Is
@security-checklist.mdintegrated or its content addressed? (Needs Clarification)
- Examples:
- Input Validation (Pydantic):
from pydantic import BaseModel, Field, EmailStr class UserSignup(BaseModel): email: EmailStr password: str = Field(min_length=8) full_name: str = Field(max_length=100) - Error Handling (Generic):
// Bad: Leaks details // app.use((err, req, res, next) => { res.status(500).send(err.stack); }); // Good: Logs detail, returns generic error app.use((err, req, res, next) => { console.error(`[${req.id}] Error processing request: ${err.message}`, err.stack); res.status(500).json({ error: 'Internal Server Error' }); });
- Input Validation (Pydantic):
- Changes: Updated to include recent security vulnerabilities and mitigation strategies for backend systems, including enhanced logging practices and dependency management.
- Readiness: Needs Clarification (regarding content/location of
@security-checklist.md). Assuming it contains more specific checks, it needs to be obtained and integrated. - Source References:
.cursor/rules/backend-security.mdc; OWASP Top 10;pydanticdocs;zoddocs.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 65 lines · 0 tokens per session scan A 6b626acb63ca
433-backend-security is a cursor rule published in the GitHub repository hamzaamjad/cursor-rules (2 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,104 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other cursor rules, from other repositories
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
cli-error-handling
CLI command error handling patterns.
prefer-direct-imports-over-module-mocks
Prefer extracting a testable core over vi.mock / vi.resetModules when unit tests need to reach production logic entangled with config, env, or singletons.
control-plane-descriptors
Control plane descriptor and instance implementation patterns.
family-instance-domain-actions
Family instance domain action implementation patterns.