drupal-insecure-design

A Drupal code rule that checks custom modules, themes, and profiles for insecure design choices listed in the OWASP Top 10, a common security-risk guide.

In plain words
What is it for?
Use it when reviewing custom Drupal PHP and configuration code for permission design, hard-coded rules, and input-sanitization practices.
Why use it?
It helps catch overly broad permissions, fixed business rules, and unsafe sanitization patterns that can make a Drupal site easier to misuse or harder to change safely.

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/drupal-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 1,495 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.01495
Opus 5 $0.00000 $0.00747
Sonnet 5 $0.00000 $0.00299
Haiku 4.5 $0.00000 $0.00150

Measured yesterday against content hash 173c39cf13aa, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

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

.cursor/rules/drupal-insecure-design.mdc · 103 lines

How it starts

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

Drupal Insecure Design Security Standards (OWASP A04:2021)

This rule enforces security best practices to prevent insecure design vulnerabilities in Drupal applications, as defined in OWASP Top 10:2021-A04.

Rule Details

  • Name: drupal_insecure_design

  • Description: Detect and prevent insecure design patterns in Drupal as defined in OWASP Top 10:2021-A04

Filters

  • file extension pattern: \\.(php|inc|module|install|theme|info\\.yml)$
  • file path pattern: (modules|themes|profiles)/custom

Enforcement Checks

  • Conditions:
    • pattern \\$permissions\\[['\"][^'\"]+['\"]\\]\\s*=\\s*array\\((?![^)]*(administer|manage|edit|delete)[^)]*(content|configuration|users)).*?\\); – Permissions should follow Drupal naming patterns (verb + object) and be specific. Avoid overly broad permissions.
      • Pattern 1: Insecure permission design
    • pattern if\\s*\\([^\\)]*===?\\s*['\"][a-zA-Z0-9_]+['\"]\\s*\\) – Consider moving business logic rules to configuration to allow for proper adjustment without code changes.
      • Pattern 2: Hard-coded business logic values
    • pattern preg_replace|str_replace|strip_tags – Avoid ad hoc sanitization. Use Drupal's built-in sanitization tools: t(), Xss::filter(), etc.
      • Pattern 3: Ad hoc input sanitization
    • pattern class\\s+[a-zA-Z0-9_]+Controller.+\\{[^}]*->query\\( – Follow separation of concerns. Move database logic to services or repositories, not in controllers.
      • Pattern 4: Database logic in controllers
    • pattern function\\s+[a-zA-Z0-9_]+_entity_access\\([^)]*\\)\\s*\\{[^}]*return\\s+AccessResult::allowed\\(\\); – Avoid unconditional access grants. Implement proper conditional checks based on roles, permissions, or entity ownership.
      • Pattern 5: Weak entity access policy
    • pattern session_start|session_set_cookie_params – Avoid custom session management. Use Drupal's session handling system and services.
      • Pattern 6: Custom session management
    • pattern (?:\\\\Drupal::[a-zA-Z_]+\\(\\).*){3,} – Excessive static service calls indicate poor dependency injection. Use proper service injection.
      • Pattern 7: Excessive global state dependency
    • pattern password_verify\\(|password_hash\\( – Avoid custom authentication. Use Drupal's built-in authentication system and services.
      • Pattern 8: Custom user authentication
    • pattern function\\s+[a-zA-Z0-9_]+_schema\\(\\)[^{]*\\{[^}]*return\\s+\\$schema;(?![^}]*validate_utf8|[^}]*'not null') – Database schemas should enforce data integrity with proper constraints (NOT NULL, length, etc.).
      • Pattern 9: Missing schema definitions
    • pattern \\$config\\[['\"](mdc:?!secure_|security_|private_)[^'\"]+['\"]\\]\\s*=\\s*(?:FALSE|0|'0'|\"0\"); – Security-related configuration should default to secure settings (opt-in for potentially insecure features).
      • Pattern 10: Insecure defaults

Read the full file on GitHub · 103 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 · 103 lines · 1,495 tokens per session scan A 173c39cf13aa

Subscribe to this mod's changes

drupal-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 1,495 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.