javascript-insecure-design

A set of rules for detecting common insecure design patterns in JavaScript and TypeScript applications, based on the OWASP security standard. It applies to source files such as .js, .jsx, .ts, and .tsx.

In plain words
What is it for?
Reviewing API routes, controllers, and related JavaScript or TypeScript code for missing rate limits, insecure object access, and missing input validation.
Why use it?
It flags code that may allow abuse, unauthorized access to records, or unsafe input handling. Catching these patterns during development can prevent avoidable security weaknesses.

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/abderrahimghazali/cursor-rules/javascript-insecure-design
Clone the repo
git clone --depth 1 https://github.com/abderrahimghazali/cursor-rules

Made for: Cursor.

Per session 4,533 This file is loaded in full into every session.
When invoked 4,533 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod 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.04533 $0.04533
Opus 5 $0.02266 $0.02266
Sonnet 5 $0.00907 $0.00907
Haiku 4.5 $0.00453 $0.00453

Measured yesterday 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 yesterday.

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

This is a copy

100% identical to javascript-insecure-design — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

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


description: Detect and prevent insecure design patterns in JavaScript applications as defined in OWASP Top 10:2021-A04 globs: /.js, **/.jsx, /.ts, **/.tsx, !/node_modules/, !/dist/, !/build/, !/coverage/

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

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. yesterday 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 abderrahimghazali/cursor-rules (2 stars, last pushed 1y ago), licensed MIT. It adds 4,533 tokens to every session, about $0.0227 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to javascript-insecure-design, differing in 0 lines, and is treated as a copy.