drupal-cryptographic-failures

Security rules for Drupal that check how passwords, keys, tokens, and other sensitive data are protected. Cryptography is the use of techniques such as hashing and encryption to protect information.

In plain words
What is it for?
Use them when reviewing Drupal code and configuration for password handling, hashes, credentials, encryption, and protected settings.
Why use it?
They help catch weak hashing, hard-coded secrets, plaintext passwords, unencrypted files, and sensitive values stored insecurely in settings.

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-cryptographic-failures
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,423 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.01423
Opus 5 $0.00000 $0.00711
Sonnet 5 $0.00000 $0.00285
Haiku 4.5 $0.00000 $0.00142

Measured 2d ago against content hash d1ee942cd032, 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 · 134 lines

How it starts

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

actions:

  • type: enforce conditions:

    Pattern 1: Use of weak hash algorithms

    • pattern: "(md5|sha1)\([^)]*\)" message: "Weak hash algorithm detected. Use password_hash() for passwords or hash('sha256'/'sha512') for other data."

    Pattern 2: Hardcoded credentials or keys

    • pattern: "(password|key|token|secret|credentials|pwd)\s*=\s*['"][^'"]+['"]" message: "Hardcoded credentials or sensitive keys detected. Use Drupal's State API, key module, or environment variables."

    Pattern 3: Plaintext password storage

    • pattern: "\$user->setPassword\((?!password_hash|\$hash)[^)]+\)" message: "Never store plaintext passwords. Drupal handles password hashing internally."

    Pattern 4: Improper file encryption

    • pattern: "file_(get|put)_contents\([^,]+,\s*[^,]+\)" message: "Consider encrypting sensitive file contents using Drupal's encryption API or PHP's openssl functions."

    Pattern 5: Unprotected sensitive data in settings

    • pattern: "\$settings\['"[^]]+\]\s*=\s*['"][^"']+['"]" message: "Sensitive data in settings.php should be moved to environment variables or settings.local.php."

    Pattern 6: Insecure random number generation

    • pattern: "(rand|mt_rand|array_rand)\(" message: "Insecure random number generation. Use random_bytes() or random_int() for cryptographic purposes."

    Pattern 7: Missing HTTPS enforcement

    • pattern: "'#cache'|'cache'" message: "Ensure HTTPS is enforced for cached pages containing sensitive information."

    Pattern 8: Missing encryption for content with private information

    • pattern: "(->set|->get)\('field_[^'](?:password|ssn|credit|card|secret|key|token|credentials|pwd)[^']'\)" message: "Consider using field encryption for sensitive data fields."

    Pattern 9: Custom session handling without proper security

    • pattern: "session_(start|regenerate_id)" message: "Avoid custom session handling. Use Drupal's session management services."

    Pattern 10: API tokens without expiration or rotation

    • pattern: "\$token\s*=\s*.*?\$[^;]+;(?![^;]*expir|[^;]*valid)" message: "API tokens should include expiration time or rotation mechanism."
  • type: suggest message: | Drupal Cryptographic Security Best Practices:

    1. Secure Data Storage:

      • Use Drupal's Key module for storing encryption keys
      • Store sensitive configuration in environment variables or settings.local.php
      • Use Drupal's State API for non-configuration sensitive data
      • Never store plaintext sensitive information in the database
    2. Encryption and Hashing:

      • Use Drupal's password hashing system, which uses password_hash() internally
      • For non-password data hashing, use SHA-256 or SHA-512
      • Use the Encrypt module or PHP's openssl_encrypt() with proper algorithms (AES-256-GCM)
      • Always use proper salting techniques
    3. Communication Security:

      • Enforce HTTPS site-wide using settings.php configuration
      • Use secure cookies (secure, HttpOnly, SameSite)
      • Implement proper Content-Security-Policy headers
      • Use TLS 1.2+ for all connections
    4. API Security:

      • Use OAuth or JWT with proper signature verification
      • Implement token expiration and rotation
      • Use HMAC for API request signatures when appropriate
      • Never expose internal encryption keys through APIs

Read the full file on GitHub · 134 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 · 134 lines · 1,423 tokens per session scan A d1ee942cd032

Subscribe to this mod's changes

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