javascript-insecure-design

A set of JavaScript security checks based on OWASP A04, the category for unsafe application design.

In plain words
What is it for?
It is for reviewing routes, APIs, and controllers for possible design weaknesses including IDOR, where a user accesses another object's data by changing an identifier.
Why use it?
It helps reveal patterns such as missing rate limits, weak access checks, and unvalidated user input that can expose an application to abuse.

Cursor rule for Cursor

Install

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.

agentmods
npx agentmods add rules/ivangrynenko/cursorrules/javascript-insecure-design
Clone the repo
git clone --depth 1 https://github.com/ivangrynenko/cursorrules

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 4,533 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What 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.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.04533
Opus 5 $0.00000 $0.02266
Sonnet 5 $0.00000 $0.00907
Haiku 4.5 $0.00000 $0.00453

Measured 2d ago against content hash c9992e65cd40, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

javascript-insecure-design 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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

.cursor/rules/javascript-insecure-design.mdc · 492 lines

How it starts

The opening of the file, as written. The whole thing — 492 lines — stays where its author put it; the contents beside it link to each section on GitHub.

JavaScript Insecure Design (OWASP A04:2021)

actions:

  • type: enforce conditions:

    Pattern 1: Lack of Rate Limiting

    • pattern: "app\.(?:get|post|put|delete|patch)\([^)]?\)\s(?!.*(?:rateLimiter|limiter|throttle|rateLimit))" location: "(?:routes|api|controllers)" message: "Potential lack of rate limiting in API endpoint. Consider implementing rate limiting to prevent abuse."

    Pattern 2: Insecure Direct Object Reference (IDOR)

    • pattern: "(?:findById|getById|findOne)\([^)]?(?:req\.|request\.|params\.|query\.|body\.|user\.|input\.|form\.)[^)]?\)\s*(?!.*(?:authorization|permission|access|canAccess|isAuthorized|checkPermission))" location: "(?:routes|api|controllers)" message: "Potential Insecure Direct Object Reference (IDOR) vulnerability. Implement proper authorization checks before accessing objects by ID."

    Pattern 3: Lack of Input Validation

    • pattern: "(?:req\.|request\.|params\.|query\.|body\.|user\.|input\.|form\.)[a-zA-Z0-9_]+\s*(?!.*(?:validate|sanitize|check|schema|joi|yup|zod|validator|isValid))" location: "(?:routes|api|controllers)" message: "Potential lack of input validation. Implement proper validation for all user inputs."

    Pattern 4: Hardcoded Business Logic

    • pattern: "if\s*\([^)]?(?:role\s===\s*['"]admin['"]|isAdmin\s*===\strue|user\.role\s===\s*['"]admin['"])\s*\)" message: "Hardcoded business logic for authorization. Consider using a more flexible role-based access control system."

    Pattern 5: Lack of Proper Error Handling

    • pattern: "catch\s*\([^)]?\)\s\{[^}]?(?:console\.(?:log|error))[^}]?\}" negative_pattern: "(?:res\.status|next\(err|next\(error|errorHandler)" message: "Improper error handling. Avoid only logging errors without proper handling or user feedback."

    Pattern 6: Insecure Authentication Design

    • pattern: "(?:password|token|secret|key)\s*===\s*(?:req\.|request\.|params\.|query\.|body\.|user\.|input\.|form\.)" message: "Insecure authentication design. Avoid direct string comparison for passwords or tokens."

    Pattern 7: Lack of Proper Logging

    • pattern: "app\.(?:get|post|put|delete|patch)\([^)]?\)\s(?!.*(?:log|logger|winston|bunyan|morgan|audit))" location: "(?:routes|api|controllers)" message: "Lack of proper logging in API endpoint. Implement logging for security-relevant events."

    Pattern 8: Insecure Defaults

    • pattern: "new\s+(?:Session|Cookie|JWT)\([^)]?\{[^}]?(?:secure\s*:\sfalse|httpOnly\s:\sfalse|sameSite\s:\s*['"]none['"])" message: "Insecure default configuration. Avoid setting secure:false, httpOnly:false, or sameSite:'none' for cookies or sessions."

    Pattern 9: Lack of Proper Access Control

    • pattern: "router\.(?:get|post|put|delete|patch)\([^)]?\)\s(?!.*(?:authenticate|authorize|requireAuth|isAuthenticated|checkAuth|verifyToken|passport\.authenticate))" location: "(?:routes|api|controllers)" message: "Potential lack of access control in route definition. Implement proper authentication and authorization middleware."

    Pattern 10: Insecure File Operations

    • pattern: "(?:fs\.(?:readFile|writeFile|appendFile|readdir|stat|access|open|unlink)|require)\([^)]?(?:(?:\+|\$\{|\`)[^)]?(?:__dirname|__filename|process\.cwd\(\)|path\.(?:resolve|join)))" negative_pattern: "path\.normalize|path\.resolve|path\.join" message: "Insecure file operations. Use path.normalize() and validate file paths to prevent directory traversal attacks."

    Pattern 11: Lack of Proper Secrets Management

    • pattern: "(?:apiKey|secret|password|token|credentials)\s*=\s*(?:process\.env\.[A-Z_]+|config\.[a-zA-Z0-9_]+|['"][^'"]+['"])" negative_pattern: "(?:vault|secretsManager|keyVault|secretClient)" message: "Insecure secrets management. Consider using a dedicated secrets management solution instead of environment variables or configuration files."

Read the full file on GitHub · 492 lines

Changes

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.

  1. 2d ago First seen · 492 lines · 4,533 tokens per session scan A c9992e65cd40

Subscribe to this mod's changes

javascript-insecure-design is a cursor rule published in the GitHub repository ivangrynenko/cursorrules (87 stars, last pushed 10mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 4,533 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-30.