drupal-authentication-failures

A Drupal security rule for preventing identification and authentication failures identified by the OWASP Top 10, a widely used list of major web-application risks. It checks password handling, custom authentication and credential storage patterns.

In plain words
What is it for?
Use it to review Drupal code and configuration for authentication weaknesses, including password policies, custom login functions and hardcoded passwords.
Why use it?
It flags weak password rules, unsafe password comparisons, incomplete login checks and credentials written directly in code before they become security 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-authentication-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,527 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 86% copy Near-identical to another mod 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.01527
Opus 5 $0.00000 $0.00763
Sonnet 5 $0.00000 $0.00305
Haiku 4.5 $0.00000 $0.00153

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

Security

Grade A, and why

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

This is a copy

86% identical to drupal-authentication-failures — 216 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.cursor/rules/drupal-authentication-failures.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 Identification and Authentication Failures Standards (OWASP A07:2021)

This rule enforces security best practices to prevent identification and authentication failures in Drupal applications, as defined in OWASP Top 10:2021-A07.

actions:

  • type: enforce conditions:

    Pattern 1: Weak or missing password policies

    • pattern: "UserPasswordConstraint|PasswordPolicy|user\.settings\.yml" message: "Ensure strong password policies are configured to require complexity, length, and prevent common passwords."

    Pattern 2: Custom authentication without proper validation

    • pattern: "(authenticate|login|auth).*function[^}]return\s+(TRUE|true|1)\s;" message: "Custom authentication functions should implement proper validation and not return TRUE without checks."

    Pattern 3: Improper password comparison

    • pattern: "==\s*\$password|===\s*\$password|strcmp\(|password_verify\([^,]+,[^,]+\$plainTextPassword" message: "Avoid direct password comparison. Use Drupal's built-in password verification services."

    Pattern 4: Credentials in code

    • pattern: "(username|user|pass|password|pwd)\s*=\s*['"][^'"]+['"]" message: "Hardcoded credentials detected. Store credentials securely outside of code."

    Pattern 5: Missing or weak CSRF protection

    • pattern: "drupal_get_token\(|form_token|\$form\[['"]#token['"]\]\s*=|drupal_valid_token\(" message: "Ensure proper CSRF protection is implemented for all authenticated actions."

    Pattern 6: Insecure session management

    • pattern: "setcookie\(|session_regenerate_id\(false\)|session_regenerate_id\([^\)]*" message: "Use Drupal's session management. If custom code is required, ensure secure session handling practices."

    Pattern 7: Missing account lockout protection

    • pattern: "user\.flood\.yml|flood_control|UserFloodControl|user_failed_login_" message: "Ensure proper account lockout and flood control mechanisms are configured to prevent brute force attacks."

    Pattern 8: Insecure password reset implementation

    • pattern: "user_pass_reset|password_reset|reset.*token" message: "Verify password reset functionality uses secure tokens with proper expiration and validation."

    Pattern 9: Lack of multi-factor authentication

    • pattern: "tfa|two_factor|multi_factor|2fa" message: "Consider implementing multi-factor authentication for sensitive operations or user roles."

    Pattern 10: Default or test accounts

    • pattern: "\$user->name\s*=\s*['"]admin['"]|\$name\s*=\s*['"]admin['"]|->values\('"['"]\)\s*->\s*set\(['"][^\'"]+['"]\)" message: "Avoid creating default administrator accounts or test users in production code."
  • type: suggest message: | Drupal Authentication Security Best Practices:

    1. Password Policies:

      • Use Drupal's Password Policy module for enforcing strong passwords
      • Configure minimum password length (12+ characters recommended)
      • Require complexity (uppercase, lowercase, numbers, special characters)
      • Implement password rotation for sensitive roles
      • Check passwords against known breached password databases
    2. Authentication Infrastructure:

      • Use Drupal's core authentication mechanisms rather than custom solutions
      • Implement proper account lockout after failed login attempts
      • Consider multi-factor authentication (TFA module) for privileged accounts
      • Implement session timeout for inactivity
      • Use HTTPS for all authentication traffic

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. yesterday First seen · 139 lines · 1,527 tokens per session scan A a5ef60a87ee0

Subscribe to this mod's changes

drupal-authentication-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,527 tokens. A static security scan graded it A with 0 findings. It is 86% identical to drupal-authentication-failures, differing in 216 lines, and is treated as a copy.