abderrahimghazali/drupal-boost/drupal-security
Claude Code and agent skill by abderrahimghazali/drupal-boost
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Drupal security best practices, vulnerability prevention, permissions and access control, input sanitization, and the Access Policy API. Use when reviewing security, setting up permissions, or hardening a Drupal site.
Install
npx vskill@latest install abderrahimghazali/drupal-boost/drupal-securitySKILL.md
The same SKILL.md was published earlier as abderrahimghazali/drupal-boost/drupal-security.
Drupal Security Best Practices
XSS Prevention
Twig (auto-escaping ON by default)
{{ variable }}— safe, auto-escaped{{ variable|raw }}— DANGEROUS, bypasses escaping. Only use for pre-sanitized markup{% set markup %}...{% endset %}— auto-escaped when rendered{{ variable|striptags }}— strips HTML tags
PHP
- Use
$this->t()ornew TranslatableMarkup()for user-facing strings - Use
Xss::filter()for user HTML that needs limited tags - Use
Html::escape()for plain text output - Use
#plain_textrender element for untrusted text - NEVER use
Markup::create()with user input - NEVER use
#markupwith unsanitized content
SQL Injection Prevention
Access Control
Route Permissions
Entity Access
- Always call
->accessCheck(TRUE)on entity queries - Implement
EntityAccessControlHandlerfor custom entities - Use
AccessResult::allowed(),::forbidden(),::neutral()with proper cacheability
Permission Definitions
CSRF Protection
- Drupal forms have built-in CSRF tokens — never disable them
- For custom AJAX endpoints, require
X-CSRF-Tokenheader - Get token from
/session/tokenendpoint - REST/JSON:API requests with cookie auth must include CSRF token
File Upload Security
- Validate file extensions with
file_validate_extensions() - Set file size limits with
file_validate_size() - Use
private://for sensitive files (notpublic://) - Never allow
.php,.phtml,.pharextensions
Input Handling
- Never access
$_GET,$_POST,$_REQUESTdirectly - Use the Request object:
$request->query->get('param') - Validate and sanitize all input at the boundary
- Use Form API validation for user-submitted forms
Common Anti-Patterns to Flag
\Drupal::request()->get()without validation$_GET,$_POST,$_SERVERdirect access|rawin Twig templatesdb_query()with string interpolationMarkup::create($user_input)- Missing
accessCheck(TRUE)on entity queries _access: 'TRUE'on sensitive routes- Debug functions in production code (var_dump, dpm, kint, dd)
- Hardcoded credentials or API keys
Security Review Checklist
- All user input sanitized before output
- All database queries use placeholders
- All routes have proper access requirements
- All entity queries include
accessCheck(TRUE) - All file uploads validated (type, size, extension)
- No debug functions in production code
- No hardcoded secrets in code
- CSRF tokens on all state-changing operations
- Sensitive files use
private://scheme - Error messages don't expose internals
Read reference files for details:
reference/vulnerability-checklist.mdfor complete vulnerability patternsreference/access-control-patterns.mdfor access control implementation
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/drupal-security/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/abderrahimghazali/drupal-boost/drupal-security)