drupal-cryptographic-failures

A Drupal code-checking rule for protecting passwords, keys, tokens, and other sensitive data through appropriate cryptography.

In plain words
What is it for?
Use it to review Drupal core, module, theme, profile, install, and configuration files for cryptographic mistakes.
Why use it?
It helps catch weak hashing, hardcoded secrets, plaintext passwords, and unsafe handling of protected files or values.

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-cryptographic-failures
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,302 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.01302
Opus 5 $0.00000 $0.00651
Sonnet 5 $0.00000 $0.00260
Haiku 4.5 $0.00000 $0.00130

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

Security

Grade A, and why

drupal-cryptographic-failures 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-cryptographic-failures.mdc · 98 lines

How it starts

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

Drupal Cryptographic Failures Security Standards (OWASP A02:2021)

This rule enforces security best practices to prevent cryptographic failures in Drupal applications, as defined in OWASP Top 10:2021-A02.

Rule Details

  • Name: drupal_cryptographic_failures

  • Description: Detect and prevent cryptographic failures in Drupal as defined in OWASP Top 10:2021-A02

Filters

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

Enforcement Checks

  • Conditions:
    • pattern (md5|sha1)\\([^)]*\\) – Weak hash algorithm detected. Use password_hash() for passwords or hash('sha256'/'sha512') for other data.
      • Pattern 1: Use of weak hash algorithms
    • pattern (password|key|token|secret|credentials|pwd)\\s*=\\s*['\"][^'\"]+['\"] – Hardcoded credentials or sensitive keys detected. Use Drupal's State API, key module, or environment variables.
      • Pattern 2: Hardcoded credentials or keys
    • pattern \\$user->setPassword\\((?!password_hash|\\$hash)[^)]+\\) – Never store plaintext passwords. Drupal handles password hashing internally.
      • Pattern 3: Plaintext password storage
    • pattern file_(get|put)_contents\\([^,]+,\\s*[^,]+\\) – Consider encrypting sensitive file contents using Drupal's encryption API or PHP's openssl functions.
      • Pattern 4: Improper file encryption
    • pattern \\$settings\\[['\"](mdc:?!hash_salt|update_free_access)[^]]+\\]\\s*=\\s*['\"][^\"']+['\"] – Sensitive data in settings.php should be moved to environment variables or settings.local.php.
      • Pattern 5: Unprotected sensitive data in settings
    • pattern (rand|mt_rand|array_rand)\\( – Insecure random number generation. Use random_bytes() or random_int() for cryptographic purposes.
      • Pattern 6: Insecure random number generation
    • pattern '#cache'|'cache' – Ensure HTTPS is enforced for cached pages containing sensitive information.
      • Pattern 7: Missing HTTPS enforcement
    • pattern (->set|->get)\\('field_[^']*(?:password|ssn|credit|card|secret|key|token|credentials|pwd)[^']*'\\) – Consider using field encryption for sensitive data fields.
      • Pattern 8: Missing encryption for content with private information
    • pattern session_(start|regenerate_id) – Avoid custom session handling. Use Drupal's session management services.
      • Pattern 9: Custom session handling without proper security
    • pattern \\$token\\s*=\\s*.*?\\$[^;]+;(?![^;]*expir|[^;]*valid) – API tokens should include expiration time or rotation mechanism.
      • Pattern 10: API tokens without expiration or rotation

Read the full file on GitHub · 98 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 · 98 lines · 1,302 tokens per session scan A f90d34ef08ff

Subscribe to this mod's changes

drupal-cryptographic-failures 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,302 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.