cursorrules / rules
Cursor rule88 starsChanged 13 months agoMITView on GitHub
Detect and prevent insecure design patterns in Drupal as defined in OWASP Top 10:2021-A04
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-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-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-insecure-design.mdc into the rules it gives an agent
15 rules. About 0 are common, 15 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈15
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
Follow the principle of least privilege for all user roles and permissions
- Distinctive: line 50
Use Drupal's entity/field API for structured data instead of custom tables
- Distinctive: line 52
Follow Drupal coding standards to leverage community security expertise
- Distinctive: line 56
Avoid creating omnipotent permissions that grant excessive access
- Distinctive: line 57
Use context-aware access systems like Entity Access or Node Grants
- Distinctive: line 58
Consider record-based and field-based access for better control
- Distinctive: line 59
Document permission architecture and security implications
- Distinctive: line 63
Use hooks judiciously and document security implications
- Distinctive: line 71
Use appropriate field types for sensitive data
- Distinctive: line 73
Consider encryption for sensitive stored data
- Distinctive: line 78
Avoid exposing sensitive data in error messages
- Distinctive: line 85
Check 1: Proper dependency injection
- Distinctive: line 87
Check 2: Configuration schema usage
- Distinctive: line 89
Check 3: Proper permission definition
- Distinctive: line 91
Check 4: Entity access handlers
≈ “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 insecure design patterns in Drupal as defined in OWASP Top 10:2021-A04
globs: *.php, *.install, *.module, *.inc, *.theme, *.yml, *.info
alwaysApply: false
---
# Drupal Insecure Design Security Standards (OWASP A04:2021)
This rule enforces security best practices to prevent insecure design vulnerabilities in Drupal applications, as defined in OWASP Top 10:2021-A04.
## Rule Details
- **Name:** drupal_insecure_design
- **Description:** Detect and prevent insecure design patterns in Drupal as defined in OWASP Top 10:2021-A04
## Filters
- file extension pattern: `\\.(php|inc|module|install|theme|info\\.yml)$`
- file path pattern: `(modules|themes|profiles)/custom`
## Enforcement Checks
- Conditions:
- pattern `\\$permissions\\[['\"][^'\"]+['\"]\\]\\s*=\\s*array\\((?![^)]*(administer|manage|edit|delete)[^)]*(content|configuration|users)).*?\\);` – Permissions should follow Drupal naming patterns (verb + object) and be specific. Avoid overly broad permissions.
- Pattern 1: Insecure permission design
- pattern `if\\s*\\([^\\)]*===?\\s*['\"][a-zA-Z0-9_]+['\"]\\s*\\)` – Consider moving business logic rules to configuration to allow for proper adjustment without code changes.
- Pattern 2: Hard-coded business logic values
- pattern `preg_replace|str_replace|strip_tags` – Avoid ad hoc sanitization. Use Drupal's built-in sanitization tools: t(), Xss::filter(), etc.
- Pattern 3: Ad hoc input sanitization
- pattern `class\\s+[a-zA-Z0-9_]+Controller.+\\{[^}]*->query\\(` – Follow separation of concerns. Move database logic to services or repositories, not in controllers.
- Pattern 4: Database logic in controllers
- pattern `function\\s+[a-zA-Z0-9_]+_entity_access\\([^)]*\\)\\s*\\{[^}]*return\\s+AccessResult::allowed\\(\\);` – Avoid unconditional access grants. Implement proper conditional checks based on roles, permissions, or entity ownership.
- Pattern 5: Weak entity access policy
- pattern `session_start|session_set_cookie_params` – Avoid custom session management. Use Drupal's session handling system and services.
- Pattern 6: Custom session management
- pattern `(?:\\\\Drupal::[a-zA-Z_]+\\(\\).*){3,}` – Excessive static service calls indicate poor dependency injection. Use proper service injection.
- Pattern 7: Excessive global state dependency
- pattern `password_verify\\(|password_hash\\(` – Avoid custom authentication. Use Drupal's built-in authentication system and services.
- Pattern 8: Custom user authentication
- pattern `function\\s+[a-zA-Z0-9_]+_schema\\(\\)[^{]*\\{[^}]*return\\s+\\$schema;(?![^}]*validate_utf8|[^}]*'not null')` – Database schemas should enforce data integrity with proper constraints (NOT NULL, length, etc.).
- Pattern 9: Missing schema definitions
- pattern `\\$config\\[['\"](mdc:?!secure_|security_|private_)[^'\"]+['\"]\\]\\s*=\\s*(?:FALSE|0|'0'|\"0\");` – Security-related configuration should default to secure settings (opt-in for potentially insecure features).
- Pattern 10: Insecure defaults
## Suggestions
- Guidance:
**Drupal Secure Design Best Practices:**
1. **Secure Architecture Principles:**
- Follow the principle of least privilege for all user roles and permissions
- Implement defense in depth with multiple security layers
- Use Drupal's entity/field API for structured data instead of custom tables
- Employ service-oriented architecture with proper dependency injection
- Follow Drupal coding standards to leverage community security expertise
2. **Permission System Design:**
- Design granular permissions following the verb+object pattern
- Avoid creating omnipotent permissions that grant excessive access
- Use context-aware access systems like Entity Access or Node Grants
- Consider record-based and field-based access for better control
- Document permission architecture and security implications
3. **Module Architecture:**
- Separate concerns into appropriate services
- Use hooks judiciously and document security implications
- Implement proper validation and sanitization layers
- Design APIs with security in mind from the start
- Provide secure default configurations
4. **Data Modeling Security:**
- Implement appropriate validation constraints on entity fields
- Design schema definitions with integrity constraints
- Use appropriate field types for sensitive data
- Implement field-level access control when needed
- Consider encryption for sensitive stored data
5. **Error Handling and Logging:**
- Design contextual error messages (detailed for admins, general for users)
- Implement appropriate logging for security events
- Avoid exposing sensitive data in error messages
- Design fault-tolerant systems that fail securely
- Include appropriate transaction management
## Validation Checks
- Conditions:
- pattern `protected\\s+\\$[a-zA-Z0-9_]+;[^}]*public\\s+function\\s+__construct\\([^\\)]*\\)` – Using proper dependency injection pattern.
- Check 1: Proper dependency injection
- pattern `config\\/schema\\/[a-zA-Z0-9_]+\\.schema\\.yml` – Providing configuration schema for validation.
- Check 2: Configuration schema usage
- pattern `\\$permissions\\[['\"][a-z\\s]+[a-z0-9\\s]+['\"]\\]\\s*=\\s*\\[` – Following permission naming conventions.
- Check 3: Proper permission definition
- pattern `@EntityAccessControl\\(|class\\s+[a-zA-Z0-9_]+AccessControlHandler\\s+extends\\s+` – Using dedicated access control handlers for entities.
- Check 4: Entity access handlers
## Metadata
- Priority: high
- Version: 1.1
- Tags: security, drupal, design, architecture, owasp, language:php, framework:drupal, category:security, subcategory:design, standard:owasp-top10, risk:a04-insecure-design
## References
- https://owasp.org/Top10/A04_2021-Insecure_Design/
- https://www.drupal.org/docs/develop/security-in-drupal
- https://www.drupal.org/docs/8/api/entity-api/access-control-for-entities
- https://www.drupal.org/docs/8/api/configuration-api/configuration-schemametadata
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.

