Automatically scan code for security vulnerabilities when user asks if code is secure or shows potentially unsafe code. Performs focused security checks on specific code, functions, or patterns. Invoke when user asks "is this secure?", "security issue?", mentions XSS, SQL injection, or shows security-sensitive code.
Automatically scans code for security vulnerabilities like SQL injection, XSS, and CSRF when you ask "is this secure?" or show security-sensitive code. Provides specific vulnerability locations, risk levels, and platform-specific fixes for Drupal and WordPress.
/plugin marketplace add kanopi/cms-cultivator/plugin install cms-cultivator@claude-toolboxThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Automatically scan code for security vulnerabilities.
Activate this skill when the user:
Vulnerable Pattern:
// ❌ DANGEROUS
$query = "SELECT * FROM users WHERE id = " . $_GET['id'];
db_query($query);
Secure Pattern:
// ✅ SECURE
$query = db_select('users', 'u')
->condition('id', $id, '=')
->execute();
// Or with placeholders
$query = "SELECT * FROM users WHERE id = :id";
db_query($query, [':id' => $id]);
Vulnerable Pattern:
// ❌ DANGEROUS
echo "<div>" . $_POST['name'] . "</div>";
Secure Pattern:
// ✅ SECURE (Drupal)
echo "<div>" . Html::escape($_POST['name']) . "</div>";
// ✅ SECURE (WordPress)
echo "<div>" . esc_html( $_POST['name'] ) . "</div>";
Vulnerable Pattern:
// ❌ DANGEROUS - No CSRF protection
if ($_POST['action'] === 'delete') {
delete_user($_POST['user_id']);
}
Secure Pattern:
// ✅ SECURE (Drupal) - CSRF token validation
if ($_POST['form_token'] && \Drupal::csrfToken()->validate($_POST['form_token'])) {
delete_user($_POST['user_id']);
}
// ✅ SECURE (WordPress) - Nonce validation
if (wp_verify_nonce($_POST['_wpnonce'], 'delete_user')) {
delete_user($_POST['user_id']);
}
Check for:
Vulnerable Pattern:
// ❌ DANGEROUS - No validation
move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_FILES['file']['name']);
Secure Pattern:
// ✅ SECURE
$allowed_types = ['jpg', 'png', 'pdf'];
$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
if (in_array(strtolower($extension), $allowed_types)) {
$safe_name = preg_replace('/[^a-zA-Z0-9_-]/', '', basename($_FILES['file']['name']));
move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $safe_name);
}
## Security Scan Results
### 🔴 Critical Issues (Fix Immediately)
**1. SQL Injection Vulnerability**
- **Location**: `src/Controller/UserController.php:45`
- **Risk**: Critical - Allows database manipulation
- **Code**:
```php
$query = "SELECT * FROM users WHERE id = " . $_GET['id'];
$query = $connection->select('users', 'u')
->condition('id', $id, '=')
->execute();
2. Missing CSRF Protection
src/Form/DeleteForm.php:673. Weak Password Policy
## OWASP Top 10 Quick Check
1. **Injection** - SQL, command, LDAP injection
2. **Broken Authentication** - Weak passwords, session management
3. **Sensitive Data Exposure** - Unencrypted data, weak crypto
4. **XML External Entities (XXE)** - XML parsing vulnerabilities
5. **Broken Access Control** - Missing permission checks
6. **Security Misconfiguration** - Default configs, verbose errors
7. **XSS** - Unescaped user input
8. **Insecure Deserialization** - Unsafe object deserialization
9. **Known Vulnerabilities** - Outdated dependencies
10. **Insufficient Logging** - No audit trail
## Platform-Specific Security
### Drupal Security
**Use**:
- `\Drupal\Component\Utility\Html::escape()` for output
- `\Drupal::database()->select()` for queries
- `\Drupal::csrfToken()->validate()` for forms
- `$this->currentUser()->hasPermission()` for access checks
### WordPress Security
**Use**:
- `esc_html()`, `esc_attr()`, `esc_url()` for output
- `$wpdb->prepare()` for queries
- `wp_verify_nonce()` for forms
- `current_user_can()` for permissions
## Integration with /audit-security Command
- **This Skill**: Focused code-level security checks
- "Is this query secure?"
- "Check this form for vulnerabilities"
- Single function/file analysis
- **`/audit-security` Command**: Comprehensive security audit
- Full OWASP Top 10 scan
- Dependency vulnerability check
- File permission analysis
- Secrets detection
## Common Vulnerabilities
### Input Validation
```php
// ❌ No validation
$age = $_POST['age'];
// ✅ Validated
$age = filter_var($_POST['age'], FILTER_VALIDATE_INT, [
'options' => ['min_range' => 1, 'max_range' => 120]
]);
// ❌ Unescaped
echo $user_input;
// ✅ Escaped (context-appropriate)
echo Html::escape($user_input); // HTML context
echo Html::escape($user_input, ENT_QUOTES); // Attribute context
echo json_encode($user_input); // JSON context
// ❌ No permission check
function deleteUser($uid) {
User::load($uid)->delete();
}
// ✅ Permission checked
function deleteUser($uid) {
if (!\Drupal::currentUser()->hasPermission('delete users')) {
throw new AccessDeniedHttpException();
}
User::load($uid)->delete();
}
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.