drupal-insecure-design

Security rules for Drupal, a content-management system used to build websites. They check for design choices that can make an application unsafe, based on the OWASP Top 10 security risks.

In plain words
What is it for?
Use them when reviewing Drupal modules and custom code for permission design, configurable business logic, input sanitization, and separation between page handling and database access.
Why use it?
They help catch overly broad permissions, fixed business rules, inconsistent input cleaning, and database work placed in the wrong part of the code before these choices cause security or maintenance problems.

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

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,620 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.01620
Opus 5 $0.00000 $0.00810
Sonnet 5 $0.00000 $0.00324
Haiku 4.5 $0.00000 $0.00162

Measured 2d ago against content hash 937396f557c8, 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 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.

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

How it starts

The opening of the file, as written. The whole thing — 139 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.

actions:

  • type: enforce conditions:

    Pattern 1: Insecure permission design

    • pattern: "\$permissions\[['"][^'"]+['"]\]\s*=\sarray\((?![^)](administer|manage|edit|delete)[^)](content|configuration|users)).?\);" message: "Permissions should follow Drupal naming patterns (verb + object) and be specific. Avoid overly broad permissions."

    Pattern 2: Hard-coded business logic values

    • pattern: "if\s*\([^\)]===?\s['"][a-zA-Z0-9_]+['"]\s*\)" message: "Consider moving business logic rules to configuration to allow for proper adjustment without code changes."

    Pattern 3: Ad hoc input sanitization

    • pattern: "preg_replace|str_replace|strip_tags" message: "Avoid ad hoc sanitization. Use Drupal's built-in sanitization tools: t(), Xss::filter(), etc."

    Pattern 4: Database logic in controllers

    • pattern: "class\s+[a-zA-Z0-9_]+Controller.+\{[^}]*->query\(" message: "Follow separation of concerns. Move database logic to services or repositories, not in controllers."

    Pattern 5: Weak entity access policy

    • pattern: "function\s+[a-zA-Z0-9_]+_entity_access\([^)]\)\s\{[^}]*return\s+AccessResult::allowed\(\);" message: "Avoid unconditional access grants. Implement proper conditional checks based on roles, permissions, or entity ownership."

    Pattern 6: Custom session management

    • pattern: "session_start|session_set_cookie_params" message: "Avoid custom session management. Use Drupal's session handling system and services."

    Pattern 7: Excessive global state dependency

    • pattern: "(?:\\Drupal::[a-zA-Z_]+\(\).*){3,}" message: "Excessive static service calls indicate poor dependency injection. Use proper service injection."

    Pattern 8: Custom user authentication

    • pattern: "password_verify\(|password_hash\(" message: "Avoid custom authentication. Use Drupal's built-in authentication system and services."

    Pattern 9: Missing schema definitions

    • pattern: "function\s+[a-zA-Z0-9_]+_schema\(\)[^{]*\{[^}]*return\s+\$schema;(?![^}]validate_utf8|[^}]'not null')" message: "Database schemas should enforce data integrity with proper constraints (NOT NULL, length, etc.)."

    Pattern 10: Insecure defaults

    • pattern: "\$config\['"[^'"]+['"]\]\s*=\s*(?:FALSE|0|'0'|"0");" message: "Security-related configuration should default to secure settings (opt-in for potentially insecure features)."
  • type: suggest message: | Drupal Secure Design Best Practices:

    1. Secure Architecture Principles:

      • Follow the principle of least privilege for all user roles and permissions
      • Implement defense in depth with multiple security layers
      • Use Drupal's entity/field API for structured data instead of custom tables
      • Employ service-oriented architecture with proper dependency injection
      • Follow Drupal coding standards to leverage community security expertise
    2. Permission System Design:

      • Design granular permissions following the verb+object pattern
      • Avoid creating omnipotent permissions that grant excessive access
      • Use context-aware access systems like Entity Access or Node Grants
      • Consider record-based and field-based access for better control
      • Document permission architecture and security implications

Read the full file on GitHub · 139 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 · 139 lines · 1,620 tokens per session scan A 937396f557c8

Subscribe to this mod's changes

drupal-insecure-design is a cursor rule published in the GitHub repository abderrahimghazali/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,620 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.