cursorrules / rules
Cursor rule88 starsChanged 13 months agoMITView on GitHub
Detect and prevent cryptographic failures in Drupal as defined in OWASP Top 10:2021-A02
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-authentication-failures.mdcCursor rule
- .cursor/rules/drupal-broken-access-control.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-cryptographic-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 Key module for storing encryption keys
- Distinctive: line 50
Use Drupal's State API for non-configuration sensitive data
- Distinctive: line 51
Never store plaintext sensitive information in the database
- Distinctive: line 54
Use Drupal's password hashing system, which uses password_hash() internally
- Distinctive: line 56
Use the Encrypt module or PHP's openssl_encrypt() with proper algorithms (AES-256-GCM)
- Distinctive: line 57
Always use proper salting techniques
- Distinctive: line 61
Use secure cookies (secure, HttpOnly, SameSite)
- Distinctive: line 63
Use TLS 1.2+ for all connections
- Distinctive: line 66
Use OAuth or JWT with proper signature verification
- Distinctive: line 68
Use HMAC for API request signatures when appropriate
- Distinctive: line 69
Never expose internal encryption keys through APIs
- Distinctive: line 80
Check 1: Proper password handling
- Distinctive: line 82
Check 2: Proper random generation
- Distinctive: line 86
Check 4: Proper encryption usage
≈ “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 cryptographic failures in Drupal as defined in OWASP Top 10:2021-A02
globs: *.php, *.install, *.module, *.inc, *.theme
alwaysApply: false
---
# 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
## Suggestions
- Guidance:
**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
5. **Configuration Best Practices:**
- Regularly rotate encryption keys and credentials
- Implement secure key storage using key management services
- Monitor and log cryptographic operations
- Maintain an inventory of cryptographic algorithms in use
## Validation Checks
- Conditions:
- pattern `UserInterface::PASSWORD_|password_hash\\(` – Using Drupal's password system correctly.
- Check 1: Proper password handling
- pattern `random_bytes|random_int|\\\\Drupal::service\\('random'\\)` – Using secure random generation methods.
- Check 2: Proper random generation
- pattern `getenv\\('|\\$_ENV\\['|\\$_SERVER\\['|settings\\.local\\.php` – Using environment variables or local settings correctly.
- Check 3: Secure settings
- pattern `openssl_encrypt\\(|\\\\Drupal::service\\('encryption'\\)` – Using proper encryption methods.
- Check 4: Proper encryption usage
## Metadata
- Priority: high
- Version: 1.1
- Tags: security, drupal, cryptography, encryption, owasp, language:php, framework:drupal, category:security, subcategory:cryptography, standard:owasp-top10, risk:a02-cryptographic-failures
## References
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/
- https://www.drupal.org/docs/security-in-drupal
- https://www.drupal.org/project/key
- https://www.drupal.org/project/encrypt
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.

