| name | security-review |
| description | PHP security review and vulnerability scanning guide. Use for code review, security audits, and fixing vulnerabilities in PHP applications. |
| allowed-tools | Read, Grep, Glob, Bash |
PHP Security Review Skill
This skill guides security review and vulnerability scanning for PHP applications.
Quick Scanning
Composer Audit
composer audit
composer audit --format=json
Static Analysis
./vendor/bin/phpstan analyse
Security Checklist
1. Input Validation
2. Output Encoding
3. Access Control
4. Authentication & Sessions
5. Secrets Management
6. Dependencies
Dangerous Patterns
SQL Injection
$query = "SELECT * FROM users WHERE name = '" . $name . "'";
$stmt = $pdo->prepare("SELECT * FROM users WHERE name = :name");
$stmt->execute(['name' => $name]);
XSS (Cross-Site Scripting)
echo $user_input;
echo htmlspecialchars($user_input, ENT_QUOTES, 'UTF-8');
Command Injection
exec("ls " . $user_input);
exec("ls " . escapeshellarg($user_input));
Path Traversal
file_get_contents($user_path);
$real_path = realpath($user_path);
if ($real_path && str_starts_with($real_path, $allowed_directory)) {
file_get_contents($real_path);
}
Insecure Deserialization
$data = unserialize($user_input);
$data = json_decode($user_input, true);
$data = unserialize($input, ['allowed_classes' => [SafeClass::class]]);
Code Review Process
- Identify entry points: Forms, APIs, URL parameters, file uploads
- Trace data flow: Input -> Processing -> Output
- Check sanitization: At both input and output points
- Verify access control: Authentication and authorization
- Review dependencies: Third-party code vulnerabilities
- Test edge cases: Empty, null, special characters, boundary values
Reporting
When reporting issues, include:
- Severity: Critical/High/Medium/Low
- Location: File path and line number
- Description: What the vulnerability is
- Impact: What could happen if exploited
- Remediation: How to fix it
Resources