drupal-injection

A set of Drupal security checks for injection flaws, such as unsafe database queries and unescaped output. Drupal is a system for building and managing websites, and injection flaws can let unwanted input alter queries or page content.

In plain words
What is it for?
Use it to inspect Drupal PHP and module files for unsafe SQL queries, database calls without parameters, and output that is not properly escaped.
Why use it?
It helps identify code patterns that can expose a Drupal site to SQL injection or cross-site scripting attacks before they reach users.

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-injection
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,482 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.01482
Opus 5 $0.00000 $0.00741
Sonnet 5 $0.00000 $0.00296
Haiku 4.5 $0.00000 $0.00148

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

Security

Grade A, and why

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

Copies of this mod

1 near-identical copy found in the catalogue:

.cursor/rules/drupal-injection.mdc · 97 lines

How it starts

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

Drupal Injection Security Standards (OWASP A03:2021)

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

Rule Details

  • Name: drupal_injection

  • Description: Detect and prevent injection vulnerabilities in Drupal as defined in OWASP Top 10:2021-A03

Filters

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

Enforcement Checks

  • Conditions:
    • pattern db_query\\(['\"][^'\"]*\\$[^'\"]*['\"] – Direct variables in SQL queries are vulnerable to SQL injection. Use parameterized queries with placeholders.
      • Pattern 1: Raw SQL queries without placeholders
    • pattern ->query\\(['\"][^'\"]*\\$[^'\"]*['\"] – Use parameterized queries with placeholders to prevent SQL injection: ->query($sql, [$param1, $param2]).
      • Pattern 2: Modern DB API without placeholders
    • pattern <?=|<?php\\s+echo\\s+(?!(t|\\\\t|\\$this->t))[^;]*; – Direct output may lead to XSS. Use t(), escaped variables with Html::escape(), or Twig templates.
      • Pattern 3: Unescaped output
    • pattern [\"']#markup[\"']\\s*=>\\s*(?!t\\(|\\\\t\\(|Xss::filterAdmin|Html::escape)\\$ – Never use unfiltered variables in #markup. Use t(), Xss::filterAdmin(), or Html::escape().
      • Pattern 4: Unfiltered user input in render arrays
    • pattern ->addJsSettings\\(\\[(?![^\\]]*(Xss::filter|Json::encode))\\$ – Filter variables before adding to JavaScript settings using Xss::filter() or properly encode with Json::encode().
      • Pattern 5: Unescaped variables in JavaScript settings
    • pattern `exec\(|shell_exec\(|system\(|passthru\(|proc_open\(|popen\(|`` – Command execution functions can lead to command injection. Use Symfony\Component\Process\Process if necessary.
      • Pattern 6: Direct command execution
    • pattern ->redirect\\(\\s*\\$(?!(this->|allowed_destinations|config)) – Unvalidated redirects can lead to open redirect vulnerabilities. Whitelist allowed destinations.
      • Pattern 7: Unvalidated redirect
    • pattern ->condition\\([^,]*,\\s*\\$(?!(this->|config|entity|storage))[^,]*, – Use proper input validation before using variables in database conditions to prevent SQL injection.
      • Pattern 8: Raw user input in conditions
    • pattern (?<!buildForm|getFormId)\\s*function\\s+[a-zA-Z0-9_]+Form\\s*\\([^{]*\\{[^}]*return\\s+\\$form;(?![^}]*FormBuilderInterface|[^}]*::TOKEN|[^}]*#token) – Form submissions must include CSRF protection with $form['#token'].
      • Pattern 9: Missing CSRF protection in forms
    • pattern file_get_contents\\(\\s*\\$(?!(this->|allowed_paths|config)) – Validate file paths before operations to prevent path traversal attacks.
      • Pattern 10: Unvalidated file operations

Read the full file on GitHub · 97 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 · 97 lines · 1,482 tokens per session scan A 2366d3a9a2a4

Subscribe to this mod's changes

drupal-injection 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,482 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.