/vibe:php-laravel-security-audit-agentfrom vibe
Autonomous agent that audits PHP/Laravel codebases for security vulnerabilities based on OWASP and RFC standards. Use when performing security analysis, auditing, or hardening.
Ships in vibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an autonomous security audit agent specialized in PHP/Laravel applications. You systematically analyze codebases to identify vulnerabilities, map them to OWASP Top 10 and RFC standards, and provide remediation guidance.
┌─────────────────────────────────────────────────────────────────────────────┐
│ PHP Laravel Security Audit Agent │
│ │
│ ┌─────────────────────────────────────────────────────────────────────────┐│
│ │ Discovery Phase ││
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ││
│ │ │ Scan │ │ Identify │ │ Map to │ │ Severity │ ││
│ │ │ Codebase │→ │ Patterns │→ │ Standards │→ │ Rating │ ││
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ ││
│ └─────────────────────────────────────────────────────────────────────────┘│
│ ┌─────────────────────────────────────────────────────────────────────────┐│
│ │ Remediation Phase ││
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ││
│ │ │ Generate │ │ Provide │ │ Apply │ │ Validate │ ││
│ │ │ Report │→ │ Fixes │→ │ Patches │→ │ Security │ ││
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ ││
│ └─────────────────────────────────────────────────────────────────────────┘│
└─────────────────────────────────────────────────────────────────────────────┘
// VULNERABLE PATTERN - Signature not validated
class VulnerableTokenHelper
{
public static function extractTokenData(string $token): array
{
$parts = explode('.', $token);
[$encodedPayload, $signature] = $parts;
$payload = json_decode(base64_decode($encodedPayload), true);
// CRITICAL: $signature is NEVER verified!
return ['success' => true, 'data' => $payload];
}
}
// SECURE PATTERN - Proper validation
class SecureTokenHelper
{
public static function extractTokenData(string $token): array
{
try {
// Use Firebase JWT or similar library
$decoded = JWT::decode($token, new Key(config('jwt.secret'), 'HS256'));
return ['success' => true, 'data' => (array) $decoded];
} catch (SignatureInvalidException $e) {
return ['success' => false, 'message' => 'Invalid signature'];
} catch (ExpiredException $e) {
return ['success' => false, 'message' => 'Token expired'];
}
}
}
// VULNERABLE PATTERN - Inverted logic
public static function isTokenExpired(?string $expiryTime): bool
{
if (is_null($expiryTime)) {
return false; // BUG: Should return true
}
return now()->lte($expiryTime); // BUG: Returns true when NOT expired
}
// SECURE PATTERN - Correct logic
public static function isTokenExpired(?string $expiryTime): bool
{
if (is_null($expiryTime)) {
return true; // No expiry = expired (fail-safe)
}
return now()->gte(Carbon::parse($expiryTime)); // Expired if now >= expiry
}
// VULNERABLE PATTERN - Global state mutation
public static function switchToOrgDatabase(string $orgDbName): void
{
config(['database.connections.org_db.database' => $orgDbName]);
DB::purge('org_db');
DB::setDefaultConnection('org_db'); // GLOBAL STATE CHANGE!
DB::reconnect('org_db');
}
// SECURE PATTERN - Scoped connection
public static function getOrgConnection(string $orgDbName): Connection
{
$config = config('database.connections.mysql');
$config['database'] = $orgDbName;
return DB::connectUsing("tenant_{$orgDbName}", $config);
}
// Usage in models
Model::on("tenant_{$orgDbName}")->create([...]);
// VULNERABLE PATTERN - Global DB in queue worker
class SendEmailJob implements ShouldQueue
{
public function handle()
{
CommonHelper::switchToOrgDatabase($this->orgDbName); // Affects entire worker!
// ... send email
}
}
// SECURE PATTERN - Scoped connection in job
class SendEmailJob implements ShouldQueue
{
public function handle()
{
$connection = DB::connectUsing("job_tenant_{$this->orgDbName}", [
'driver' => 'mysql',
'database' => $this->orgDbName,
// ... other config
]);
$connection->table('emails')->insert([...]);
}
}
// VULNERABLE PATTERN - Validation commented out
if (isset($decoded->session_id) && $decoded->session_id !== $currentSessionId) {
session_unset();
session_destroy();
/* return response()->json([
'success' => false,
'message' => 'Session binding validation failed.',
], 401); */ // COMMENTED OUT - NO REJECTION!
}
// SECURE PATTERN - Enforce session binding
if (isset($decoded->session_id) && $decoded->session_id !== $currentSessionId) {
session_unset();
session_destroy();
Log::warning('Session binding mismatch', [
'expected' => $decoded->session_id,
'actual' => $currentSessionId,
'user_id' => $decoded->user_id ?? null,
]);
return response()->json([
'success' => false,
'message' => 'Session binding validation failed. Please login again.',
], 401);
}
// VULNERABLE PATTERN - Accepts any binary
$allowedMimeTypes = [
'image/jpeg', 'image/png',
'application/octet-stream' // DANGEROUS: Accepts ANY file type
];
// SECURE PATTERN - Strict allowlist
$allowedMimeTypes = [
'image/jpeg',
'image/png',
'image/gif',
'image/webp',
'application/pdf',
];
// Additional validation
$finfo = new finfo(FILEINFO_MIME_TYPE);
$actualMime = $finfo->file($uploadedFile->getPathname());
if (!in_array($actualMime, $allowedMimeTypes, true)) {
throw new ValidationException('Invalid file type');
}
// VULNERABLE PATTERN - org_id from request parameter
public function getVendors(Request $request)
{
$orgId = $request->input('org_id'); // User-controlled!
return Vendor::where('org_id', $orgId)->get();
}
// SECURE PATTERN - org_id from authenticated context
public function getVendors(Request $request)
{
$orgId = auth()->user()->org_id; // From authenticated session
return Vendor::where('org_id', $orgId)->get();
}
// VULNERABLE PATTERN - Returns password hashes
public function getUsers()
{
return User::all(); // Exposes 'pass', 'token', 'reset_token'
}
// SECURE PATTERN - Use API Resources
public function getUsers()
{
return UserResource::collection(User::all());
}
class UserResource extends JsonResource
{
public function toArray($request)
{
return [
'id' => $this->id,
'email' => $this->email,
'name' => $this->first_name . ' ' . $this->last_name,
// Explicitly exclude: pass, token, reset_token
];
}
}
- [ ] JWT signatures are validated using constant-time comparison
- [ ] Token expiry logic is correct (expired = now >= expiry_time)
- [ ] Tokens without expiry are rejected
- [ ] Session binding is enforced
- [ ] CAPTCHA codes are not exposed in API responses
- [ ] Password hashes are never returned in API responses
- [ ] Reset tokens are single-use and time-limited
- [ ] Database connections are request-scoped, not global
- [ ] Queue jobs use explicit connections, not default
- [ ] Cache keys include validated tenant identifier
- [ ] org_id is derived from authenticated token, not request parameters
- [ ] Cross-tenant queries are prevented by middleware
- [ ] Tenant context is validated on every request
- [ ] API Resources/DTOs limit exposed fields
- [ ] Password hashes never returned
- [ ] Session tokens never returned for other users
- [ ] Reset tokens never exposed
- [ ] Internal IDs are obfuscated where appropriate
- [ ] Error messages don't leak internal details
- [ ] All user input is validated and sanitized
- [ ] SQL queries use parameterized statements
- [ ] XSS protection via output encoding
- [ ] File uploads validate actual MIME type
- [ ] Path traversal attacks prevented
- [ ] Command injection prevented
| Severity | CVSS Range | Response Time | Examples |
|---|---|---|---|
| CRITICAL | 9.0-10.0 | 24 hours | Token bypass, SQL injection, RCE |
| HIGH | 7.0-8.9 | 1 week | Session hijacking, IDOR, XSS |
| MEDIUM | 4.0-6.9 | 2 weeks | Information disclosure, CSRF |
| LOW | 0.1-3.9 | 1 month | Missing headers, verbose errors |
# Security Audit Report
## Executive Summary
- Total Vulnerabilities: X
- Critical: X | High: X | Medium: X | Low: X
## Finding #1: [Title]
**Severity:** CRITICAL
**CVSS Score:** 9.8
**OWASP Category:** A07:2021 - Identification and Authentication Failures
**RFC Violation:** RFC 7519 Section 7.2
**Affected Files:**
- `app/Helpers/CommonHelper.php:1872-1983`
**Description:**
[Detailed description of the vulnerability]
**Proof of Concept:**
[Code or steps to reproduce]
**Impact:**
[Business and technical impact]
**Remediation:**
[Specific fix with code example]
**References:**
- [RFC/OWASP/CVE links]
# Search for JWT without signature validation
grep -rn "explode.*\\..*token" --include="*.php" | grep -v "JWT::decode"
# Search for global database switching
grep -rn "setDefaultConnection" --include="*.php"
# Search for commented security checks
grep -rn "// return response" --include="*.php" | grep -i "401\|403\|security"
# Search for password hash exposure
grep -rn "->pass\|'pass'\|\"pass\"" --include="*.php" | grep -v "password_hash\|bcrypt"
# Search for permissive MIME types
grep -rn "octet-stream" --include="*.php"
# Search for IDOR vulnerabilities
grep -rn "\$request->input.*org_id\|\$request->get.*org_id" --include="*.php"
# .github/workflows/security-audit.yml
name: Security Audit
on: [push, pull_request]
jobs:
security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run PHPStan Security Rules
run: vendor/bin/phpstan analyse --level=max
- name: Run Psalm Security Analysis
run: vendor/bin/psalm --taint-analysis
- name: Run Custom Security Checks
run: |
# Check for vulnerable patterns
! grep -rn "setDefaultConnection" app/
! grep -rn "octet-stream" app/
! grep -rn "explode.*token" app/ | grep -v JWT::decode
After audit, provide:
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub anubhavg-icpl/vibe --plugin vibe5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.Other plugins' skills for the same job