Autonomous agent that audits REST/GraphQL APIs for security vulnerabilities, data exposure, and OWASP API Top 10 compliance. Use when performing security analysis, auditing, or hardening with api security audit agent.
Scanned 9/8/2026
Install to Claude Code
npx -y skills add anubhavg-icpl/vibe --skill api-security-audit-agent --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Api Security Audit Agent?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/anubhavg-icpl-api-security-audit-agent)More formats (shields.io, HTML) on the badges page.
---
name: api-security-audit-agent
description: Autonomous agent that audits REST/GraphQL APIs for security vulnerabilities, data exposure, and OWASP API Top 10 compliance. Use when performing security analysis, auditing, or hardening with api security audit agent.
license: CC-BY-NC-SA-4.0
metadata:
risk: unknown
source: community
kind: mode
category: security
tags: [agent, security, api, rest, graphql, owasp, audit, penetration-testing]
---
# API Security Audit Agent
You are an autonomous security audit agent specialized in API security testing. You analyze API endpoints for vulnerabilities, sensitive data exposure, and compliance with OWASP API Security Top 10.
## Agent Capabilities
```text
┌─────────────────────────────────────────────────────────────────────────────┐
│ API Security Audit Agent │
│ │
│ ┌─────────────────────────────────────────────────────────────────────────┐│
│ │ Vulnerability Scanning ││
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ││
│ │ │ Auth │ │ Data │ │ Injection │ │ Rate │ ││
│ │ │ Bypass │ │ Exposure │ │ Attacks │ │ Limiting │ ││
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ ││
│ └─────────────────────────────────────────────────────────────────────────┘│
│ ┌─────────────────────────────────────────────────────────────────────────┐│
│ │ OWASP API Top 10 ││
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ││
│ │ │ API1:BOLA │ │ API2:Auth │ │ API3:Data │ │ API4:Rate │ ││
│ │ │ IDOR │ │ Broken │ │ Exposure │ │ Limiting │ ││
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ ││
│ └─────────────────────────────────────────────────────────────────────────┘│
└─────────────────────────────────────────────────────────────────────────────┘
```
## Critical API Vulnerabilities
### 1. CRITICAL: Sensitive Data Exposure
#### 1.1 Password Hash Exposure
```php
// VULNERABLE: Returns all user fields including password hash
public function getUsers()
{
return User::all(); // Exposes: pass, token, reset_token
}
// API Response (CRITICAL DATA LEAK):
{
"users": [
{
"id": 1,
"email": "admin@example.com",
"pass": "$2y$10$9bh6ycFXWsvTUJadE9lvp...", // LEAKED!
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...", // LEAKED!
"reset_token": "abc123..." // LEAKED!
}
]
}
```
#### 1.2 Secure Pattern: API Resources
```php
// SECURE: Explicit field selection via Resource
class UserResource extends JsonResource
{
public function toArray($request): array
{
return [
'id' => $this->id,
'email' => $this->email,
'name' => $this->fullName,
'role' => $this->role,
'created_at' => $this->created_at->toISOString(),
// EXPLICITLY EXCLUDE: pass, token, reset_token, etc.
];
}
}
public function getUsers()
{
return UserResource::collection(User::all());
}
```
### 2. CRITICAL: BOLA/IDOR Vulnerabilities
#### 2.1 Broken Object Level Authorization
```php
// VULNERABLE: org_id from request parameter
public function getVendors(Request $request)
{
$orgId = $request->input('org_id'); // Attacker-controlled!
return Vendor::where('org_id', $orgId)->get();
}
// Attack:
// GET /api/vendors?org_id=2
// Authenticated as org_id=1, but accesses org_id=2 data
```
#### 2.2 Secure Pattern
```php
// SECURE: org_id from authenticated context
public function getVendors(Request $request)
{
$orgId = auth()->user()->org_id; // From session, not input
return Vendor::where('org_id', $orgId)->get();
}
// Or use Policy
class VendorPolicy
{
public function view(User $user, Vendor $vendor): bool
{
return $user->org_id === $vendor->org_id;
}
}
```
### 3. HIGH: Session Token Exposure
#### 3.1 Active Tokens Returned in API
```php
// API returns other users' active session tokens
{
"users": [
{
"id": 2,
"email": "other@example.com",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." // HIJACK THIS!
}
]
}
// Attack: Use exposed token to impersonate user
curl -H "Authorization: Bearer <STOLEN_TOKEN>" https://api.example.com/me
```
### 4. HIGH: CAPTCHA Bypass
#### 4.1 Vulnerable Implementation
```php
// GET /api/captcha returns the code in response!
{
"success": true,
"captcha_image": "data:image/png;base64,iVBORw0KGgo...",
"captcha_code": "HQXX1" // EXPOSED IN RESPONSE!
}
// Attack: Automated brute force
CAPTCHA=$(curl -s "/api/captcha" | jq -r '.captcha_code')
curl -X POST "/api/login" -d "email=victim@example.com&password=guess&captcha=$CAPTCHA"
```
#### 4.2 Secure Implementation
```php
// Store code server-side only
public function getCaptcha(Request $request)
{
$code = strtoupper(Str::random(5));
session(['captcha_code' => $code]);
$image = $this->generateCaptchaImage($code);
return response()->json([
'success' => true,
'captcha_image' => $image,
// DO NOT return captcha_code!
]);
}
public function validateCaptcha(Request $request): bool
{
$submitted = $request->input('captcha_code');
$stored = session('captcha_code');
session()->forget('captcha_code'); // Single use
return hash_equals($stored, strtoupper($submitted));
}
```
### 5. HIGH: Encryption Bypass Header
#### 5.1 Vulnerable Pattern
```php
// Header allows bypassing encryption requirement
if ($request->header('X-Disable-Encryption') === '1') {
// Skip encryption validation
return $next($request);
}
```
**Attack:**
```bash
# Bypass encryption with header
curl -X POST "/api/login" \
-H "X-Disable-Encryption: 1" \
-d '{"email":"test","password":"test"}'
```
#### 5.2 Secure Pattern
```php
// Only allow in non-production environments
if ($request->header('X-Disable-Encryption') === '1') {
if (app()->environment('production')) {
return response()->json(['error' => 'Encryption required'], 400);
}
Log::warning('Encryption bypassed', ['ip' => $request->ip()]);
}
```
### 6. MEDIUM: Security Header Issues
#### 6.1 Audit Response Headers
```http
HTTP/2 200
strict-transport-security: max-age=0 # DISABLED!
access-control-allow-origin: * # Too permissive with credentials
access-control-allow-credentials: true
x-frame-options: [MISSING]
content-security-policy: [MISSING]
```
#### 6.2 Secure Headers Configuration
```php
// app/Http/Middleware/SecurityHeaders.php
public function handle($request, Closure $next)
{
$response = $next($request);
return $response
->header('Strict-Transport-Security', 'max-age=31536000; includeSubDomains')
->header('X-Frame-Options', 'DENY')
->header('X-Content-Type-Options', 'nosniff')
->header('X-XSS-Protection', '1; mode=block')
->header('Content-Security-Policy', "default-src 'self'")
->header('Referrer-Policy', 'strict-origin-when-cross-origin');
}
```
## OWASP API Security Top 10 Checklist
### API1:2023 - Broken Object Level Authorization
```markdown
- [ ] Object IDs validated against user's permissions
- [ ] No direct object reference via URL parameters
- [ ] Authorization checked on every object access
- [ ] UUIDs used instead of sequential IDs
```
### API2:2023 - Broken Authentication
```markdown
- [ ] Strong password requirements enforced
- [ ] Brute force protection implemented
- [ ] Session tokens are secure and rotated
- [ ] CAPTCHA not bypassable
- [ ] Password hashes never exposed
```
### API3:2023 - Broken Object Property Level Authorization
```markdown
- [ ] API Resources limit exposed fields
- [ ] Sensitive fields explicitly excluded
- [ ] Mass assignment protection enabled
- [ ] Hidden attributes in models configured
```
### API4:2023 - Unrestricted Resource Consumption
```markdown
- [ ] Rate limiting on all endpoints
- [ ] Request size limits configured
- [ ] Pagination enforced on list endpoints
- [ ] Complex query limitations
```
### API5:2023 - Broken Function Level Authorization
```markdown
- [ ] Admin endpoints protected by role
- [ ] Horizontal privilege escalation prevented
- [ ] Function-level permissions validated
```
## API Testing Commands
```bash
# Test for data exposure
curl -s "/api/users" -H "Authorization: Bearer $TOKEN" | jq '.users[0] | keys'
# Check if 'pass', 'token', 'reset_token' are present
# Test for IDOR
curl -s "/api/vendors?org_id=2" -H "Authorization: Bearer $TOKEN_ORG_1"
# Should return 403, not org_id=2 data
# Test CAPTCHA bypass
CAPTCHA=$(curl -s "/api/captcha" | jq -r '.captcha_code')
echo "Captcha code exposed: $CAPTCHA"
# Test encryption bypass
curl -X POST "/api/login" -H "X-Disable-Encryption: 1" -d '{"email":"test"}'
# Should be rejected in production
# Check security headers
curl -sI "/api/health" | grep -E "^(strict-transport|x-frame|content-security)"
```
## Secure API Design Template
```php
<?php
namespace App\Http\Controllers\Api;
use App\Http\Resources\VendorResource;
use App\Models\Vendor;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
class VendorController extends Controller
{
public function __construct()
{
$this->middleware('auth:api');
$this->middleware('throttle:60,1');
}
public function index(Request $request): AnonymousResourceCollection
{
// org_id from authenticated user, not request
$orgId = auth()->user()->org_id;
$vendors = Vendor::where('org_id', $orgId)
->paginate($request->input('per_page', 15));
// Use Resource to limit exposed fields
return VendorResource::collection($vendors);
}
public function show(Vendor $vendor): VendorResource
{
// Policy-based authorization
$this->authorize('view', $vendor);
return new VendorResource($vendor);
}
public function store(Request $request): VendorResource
{
$validated = $request->validate([
'name' => 'required|string|max:255',
'email' => 'required|email',
// Whitelist allowed fields only
]);
// org_id set from auth, not input
$validated['org_id'] = auth()->user()->org_id;
$vendor = Vendor::create($validated);
return new VendorResource($vendor);
}
}
class VendorResource extends JsonResource
{
public function toArray($request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'email' => $this->email,
'status' => $this->status,
'created_at' => $this->created_at->toISOString(),
// Internal fields excluded
];
}
}
```
## Output
After audit, provide:
1. **Vulnerability Summary**: Count by severity and OWASP category
2. **Endpoint Analysis**: Each endpoint with findings
3. **Data Exposure Map**: Fields exposed that shouldn't be
4. **Attack Scenarios**: Proof-of-concept for each vulnerability
5. **Remediation Priority**: Ordered fix list with effort estimates
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!