cursorrules / rules
Cursor rule88 starsChanged 13 months agoMITView on GitHub
Detect and prevent identification and authentication failures in Drupal as defined in OWASP Top 10:2021-A07
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository70 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/accessibility-standards.mdcCursor rule
- .cursor/rules/api-standards.mdcCursor rule
- .cursor/rules/behat-ai-guide.mdcCursor rule
- .cursor/rules/behat-steps.mdcCursor rule
- .cursor/rules/build-optimization.mdcCursor rule
- .cursor/rules/code-generation-standards.mdcCursor rule
- .cursor/rules/confluence-editing-standards.mdcCursor rule
- .cursor/rules/cursor-rules.mdcCursor rule
- .cursor/rules/debugging-standards.mdcCursor rule
- .cursor/rules/docker-compose-standards.mdcCursor rule
- .cursor/rules/drupal-broken-access-control.mdcCursor rule
- .cursor/rules/drupal-cryptographic-failures.mdcCursor rule
- .cursor/rules/drupal-database-standards.mdcCursor rule
- .cursor/rules/drupal-file-permissions.mdcCursor rule
- .cursor/rules/drupal-injection.mdcCursor rule
- .cursor/rules/drupal-insecure-design.mdcCursor rule
- .cursor/rules/drupal-integrity-failures.mdcCursor rule
- .cursor/rules/drupal-logging-failures.mdcCursor rule
- .cursor/rules/drupal-security-misconfiguration.mdcCursor rule
- .cursor/rules/drupal-ssrf.mdcCursor rule
- .cursor/rules/drupal-vulnerable-components.mdcCursor rule
- .cursor/rules/generic_bash_style.mdcCursor rule
- .cursor/rules/git-commit-standards.mdcCursor rule
- .cursor/rules/github-actions-standards.mdcCursor rule
- .cursor/rules/improve-cursorrules-efficiency.mdcCursor rule
- .cursor/rules/javascript-broken-access-control.mdcCursor rule
- .cursor/rules/javascript-cryptographic-failures.mdcCursor rule
- .cursor/rules/javascript-identification-authentication-failures.mdcCursor rule
- .cursor/rules/javascript-injection.mdcCursor rule
- .cursor/rules/javascript-insecure-design.mdcCursor rule
- .cursor/rules/javascript-performance.mdcCursor rule
- .cursor/rules/javascript-security-logging-monitoring-failures.mdcCursor rule
- .cursor/rules/javascript-security-misconfiguration.mdcCursor rule
- .cursor/rules/javascript-server-side-request-forgery.mdcCursor rule
- .cursor/rules/javascript-software-data-integrity-failures.mdcCursor rule
- .cursor/rules/javascript-standards.mdcCursor rule
- .cursor/rules/javascript-vulnerable-outdated-components.mdcCursor rule
- .cursor/rules/lagoon-docker-compose-standards.mdcCursor rule
- .cursor/rules/lagoon-yml-standards.mdcCursor rule
- .cursor/rules/multi-agent-coordination.mdcCursor rule
- .cursor/rules/new-pull-request.mdcCursor rule
- .cursor/rules/node-dependencies.mdcCursor rule
- .cursor/rules/php-drupal-best-practices.mdcCursor rule
- .cursor/rules/php-drupal-development-standards.mdcCursor rule
- .cursor/rules/php-memory-optimisation.mdcCursor rule
- .cursor/rules/project-definition-template.mdcCursor rule
- .cursor/rules/pull-request-changelist-instructions.mdcCursor rule
- .cursor/rules/python-authentication-failures.mdcCursor rule
- .cursor/rules/python-broken-access-control.mdcCursor rule
- .cursor/rules/python-cryptographic-failures.mdcCursor rule
- .cursor/rules/python-injection.mdcCursor rule
- .cursor/rules/python-insecure-design.mdcCursor rule
- .cursor/rules/python-integrity-failures.mdcCursor rule
- .cursor/rules/python-logging-monitoring-failures.mdcCursor rule
- .cursor/rules/python-security-misconfiguration.mdcCursor rule
- .cursor/rules/python-ssrf.mdcCursor rule
- .cursor/rules/python-vulnerable-outdated-components.mdcCursor rule
- .cursor/rules/react-patterns.mdcCursor rule
- The first 60 shown.
The file
Show its rules and text
We split this drupal-authentication-failures.mdc into the rules it gives an agent
14 rules. About 0 are common, 14 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 48
Use Drupal's Password Policy module for enforcing strong passwords
- Distinctive: line 52
Check passwords against known breached password databases
- Distinctive: line 55
Use Drupal's core authentication mechanisms rather than custom solutions
- Distinctive: line 57
Consider multi-factor authentication (TFA module) for privileged accounts
- Distinctive: line 59
Use HTTPS for all authentication traffic
- Distinctive: line 62
Use Drupal's session management system rather than PHP's session functions
- Distinctive: line 65
Consider using the Session Limit module to restrict concurrent sessions
- Distinctive: line 70
Use email verification for new account registration
- Distinctive: line 79
Consider CAPTCHA or reCAPTCHA for login forms
- Distinctive: line 80
Use OAuth or SAML for single sign-on where appropriate
- Distinctive: line 85
Check 1: Proper password handling
- Distinctive: line 87
Check 2: CSRF token implementation
- Distinctive: line 89
Check 3: Proper session management
- Distinctive: line 91
Check 4: User flood control
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Detect and prevent identification and authentication failures in Drupal as defined in OWASP Top 10:2021-A07
globs: *.php, *.inc, *.module, *.install, *.info.yml, *.theme
alwaysApply: false
---
# 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.
## Rule Details
- **Name:** drupal_authentication_failures
- **Description:** Detect and prevent identification and authentication failures in Drupal as defined in OWASP Top 10:2021-A07
## Filters
- file extension pattern: `\\.(php|inc|module|install|theme|yml)$`
- file path pattern: `.*`
## Enforcement Checks
- Conditions:
- pattern `UserPasswordConstraint|PasswordPolicy|user\\.settings\\.yml` – Ensure strong password policies are configured to require complexity, length, and prevent common passwords.
- Pattern 1: Weak or missing password policies
- pattern `(authenticate|login|auth).*function[^}]*return\\s+(TRUE|true|1)\\s*;` – Custom authentication functions should implement proper validation and not return TRUE without checks.
- Pattern 2: Custom authentication without proper validation
- pattern `==\\s*\\$password|===\\s*\\$password|strcmp\\(|password_verify\\([^,]+,[^,]+\\$plainTextPassword` – Avoid direct password comparison. Use Drupal's built-in password verification services.
- Pattern 3: Improper password comparison
- pattern `(username|user|pass|password|pwd)\\s*=\\s*['\"][^'\"]+['\"]` – Hardcoded credentials detected. Store credentials securely outside of code.
- Pattern 4: Credentials in code
- pattern `drupal_get_token\\(|form_token|\\$form\\[['\"]#token['\"]\\]\\s*=|drupal_valid_token\\(` – Ensure proper CSRF protection is implemented for all authenticated actions.
- Pattern 5: Missing or weak CSRF protection
- pattern `setcookie\\(|session_regenerate_id\\(false\\)|session_regenerate_id\\([^\\)]*` – Use Drupal's session management. If custom code is required, ensure secure session handling practices.
- Pattern 6: Insecure session management
- pattern `user\\.flood\\.yml|flood_control|UserFloodControl|user_failed_login_` – Ensure proper account lockout and flood control mechanisms are configured to prevent brute force attacks.
- Pattern 7: Missing account lockout protection
- pattern `user_pass_reset|password_reset|reset.*token` – Verify password reset functionality uses secure tokens with proper expiration and validation.
- Pattern 8: Insecure password reset implementation
- pattern `tfa|two_factor|multi_factor|2fa` – Consider implementing multi-factor authentication for sensitive operations or user roles.
- Pattern 9: Lack of multi-factor authentication
- pattern `\\$user->name\\s*=\\s*['\"]admin['\"]|\\$name\\s*=\\s*['\"]admin['\"]|->values\\(['\"](mdc:name|mail)['\"]\\)\\s*->\\s*set\\(['\"][^\\'\"]+['\"]\\)` – Avoid creating default administrator accounts or test users in production code.
- Pattern 10: Default or test accounts
## Suggestions
- Guidance:
**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
3. **Session Management:**
- Use Drupal's session management system rather than PHP's session functions
- Configure secure session cookie settings in settings.php
- Implement proper session regeneration on privilege changes
- Consider using the Session Limit module to restrict concurrent sessions
- Properly destroy sessions on logout
4. **Account Management:**
- Implement proper account provisioning and deprovisioning processes
- Use email verification for new account registration
- Implement secure password reset mechanisms with limited-time tokens
- Apply the principle of least privilege for user roles
- Regularly audit user accounts and permissions
5. **Authentication Hardening:**
- Monitor for authentication failures and suspicious patterns
- Implement IP-based and username-based flood control
- Log authentication events for security monitoring
- Consider CAPTCHA or reCAPTCHA for login forms
- Use OAuth or SAML for single sign-on where appropriate
## Validation Checks
- Conditions:
- pattern `password_verify\\(|UserPassword|\\\\Drupal::service\\(['\"]password['\"]\\)` – Using Drupal's password services correctly.
- Check 1: Proper password handling
- pattern `\\$form\\[['\"]#token['\"]\\]\\s*=\\s*['\"][^'\"]+['\"]` – Form includes CSRF protection token.
- Check 2: CSRF token implementation
- pattern `\\$request->getSession\\(\\)|\\\\Drupal::service\\(['\"]session['\"]\\)` – Using Drupal's session management services.
- Check 3: Proper session management
- pattern `user\\.flood\\.yml|flood|user_login_final_validate` – Implementing user flood protection.
- Check 4: User flood control
## Metadata
- Priority: high
- Version: 1.1
- Tags: security, drupal, authentication, identification, owasp, language:php, framework:drupal, category:security, subcategory:authentication, standard:owasp-top10, risk:a07-authentication-failures
## References
- https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/
- https://www.drupal.org/docs/security-in-drupal/drupal-security-best-practices
- https://www.drupal.org/project/tfa
- https://www.drupal.org/project/password_policy
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

