cyberaudit-skill 3.0.5 → 3.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +9 -2
- package/package.json +1 -1
- package/skills/cyberaudit/COMMANDS.md +86 -1125
- package/skills/cyberaudit/SKILL.md +102 -4
- package/skills/cyberaudit/api/API-CHECKLIST.md +102 -0
- package/skills/cyberaudit/api/API-PHILOSOPHY.md +121 -0
- package/skills/cyberaudit/api/API-REMEDIATION-LIBRARY.md +149 -0
- package/skills/cyberaudit/api/types/GRAPHQL.md +82 -0
- package/skills/cyberaudit/api/types/REST.md +71 -0
- package/skills/cyberaudit/api/types/WEBSOCKET.md +75 -0
- package/skills/cyberaudit/api/vulnerabilities/BOLA.md +41 -0
- package/skills/cyberaudit/api/vulnerabilities/BOPLA.md +38 -0
- package/skills/cyberaudit/api/vulnerabilities/INVENTORY.md +47 -0
- package/skills/cyberaudit/api/vulnerabilities/RATE-LIMITING.md +66 -0
- package/skills/cyberaudit/api/vulnerabilities/THIRD-PARTY-API.md +57 -0
- package/skills/cyberaudit/reports/REPORT-TEMPLATE-API.md +89 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# WebSocket API — Security Audit Guide
|
|
2
|
+
|
|
3
|
+
## Unique Risks
|
|
4
|
+
|
|
5
|
+
WebSockets are persistent, bidirectional, and often bypass traditional web security controls:
|
|
6
|
+
- No per-request headers or cookies after initial handshake
|
|
7
|
+
- WAFs struggle to inspect WebSocket traffic
|
|
8
|
+
- Long-lived connections increase attack surface
|
|
9
|
+
|
|
10
|
+
## Vulnerability Patterns
|
|
11
|
+
|
|
12
|
+
### CRITICAL — No Authentication on Connect
|
|
13
|
+
```javascript
|
|
14
|
+
const ws = new WebSocket('wss://api.example.com/ws');
|
|
15
|
+
// No auth token sent → anyone can connect
|
|
16
|
+
```
|
|
17
|
+
Fix: require JWT/token in connection header or first message.
|
|
18
|
+
|
|
19
|
+
### CRITICAL — No Per-Message Authorization
|
|
20
|
+
Connection is authenticated, but subsequent messages are not authorized.
|
|
21
|
+
```
|
|
22
|
+
User connects (valid token) → sends: {"action": "deleteUser", "target": 5}
|
|
23
|
+
No check if user is admin or owns user 5.
|
|
24
|
+
```
|
|
25
|
+
Fix: authorize every message independently.
|
|
26
|
+
|
|
27
|
+
### HIGH — No Input Validation
|
|
28
|
+
```
|
|
29
|
+
ws.send(JSON.stringify({ action: "query", sql: "DROP TABLE users" }));
|
|
30
|
+
```
|
|
31
|
+
Fix: validate all message content server-side. Never trust the client.
|
|
32
|
+
|
|
33
|
+
### HIGH — Message Injection
|
|
34
|
+
If messages are parsed or rendered unescaped:
|
|
35
|
+
```
|
|
36
|
+
ws.send(JSON.stringify({ action: "chat", message: "<script>...</script>" }));
|
|
37
|
+
```
|
|
38
|
+
Fix: escape output, strip HTML, validate message schema.
|
|
39
|
+
|
|
40
|
+
### MEDIUM — No Rate Limiting
|
|
41
|
+
Without per-connection rate limiting:
|
|
42
|
+
- Message flood
|
|
43
|
+
- Resource exhaustion
|
|
44
|
+
- Data exfiltration via rapid queries
|
|
45
|
+
Fix: rate limit per connection, close connections that exceed limits.
|
|
46
|
+
|
|
47
|
+
### MEDIUM — No Origin Validation
|
|
48
|
+
```javascript
|
|
49
|
+
// Server accepts connections from any origin
|
|
50
|
+
```
|
|
51
|
+
An attacker's website can open WebSocket connections on behalf of logged-in users (CSWSH — Cross-Site WebSocket Hijacking).
|
|
52
|
+
Fix: validate Origin header during handshake.
|
|
53
|
+
|
|
54
|
+
### MEDIUM — No Connection Timeout
|
|
55
|
+
Connections stay open indefinitely, consuming resources.
|
|
56
|
+
Fix: implement idle timeout, absolute timeout, and heartbeat.
|
|
57
|
+
|
|
58
|
+
### LOW — Unencrypted Connections
|
|
59
|
+
```
|
|
60
|
+
const ws = new WebSocket('ws://api.example.com/ws');
|
|
61
|
+
```
|
|
62
|
+
Fix: mandatory WSS (TLS) for all WebSocket connections.
|
|
63
|
+
|
|
64
|
+
## WebSocket-Specific Best Practices
|
|
65
|
+
|
|
66
|
+
1. Authenticate on connection (token in first message or header)
|
|
67
|
+
2. Authorize every message independently
|
|
68
|
+
3. Validate all message content and schema
|
|
69
|
+
4. Rate limit per connection
|
|
70
|
+
5. Validate Origin header during handshake
|
|
71
|
+
6. Implement idle timeout and absolute timeout
|
|
72
|
+
7. Use WSS exclusively (no plain WS)
|
|
73
|
+
8. Limit message size
|
|
74
|
+
9. Log all connections and disconnections
|
|
75
|
+
10. Monitor for abnormal message patterns
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# BOLA — Broken Object Level Authorization (API1:2023)
|
|
2
|
+
|
|
3
|
+
OWASP API Security Top 10 — #1
|
|
4
|
+
|
|
5
|
+
## Description
|
|
6
|
+
|
|
7
|
+
BOLA (also known as IDOR) occurs when an API does not verify that the requesting user is authorized to access a specific object. The attacker simply changes an object ID in the request to access another user's data.
|
|
8
|
+
|
|
9
|
+
## Detection
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
// Vulnerable: no ownership check
|
|
13
|
+
app.get('/api/orders/:id', (req, res) => {
|
|
14
|
+
const order = db.orders.findById(req.params.id);
|
|
15
|
+
res.json(order);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Secure: ownership check
|
|
19
|
+
app.get('/api/orders/:id', authenticate, (req, res) => {
|
|
20
|
+
const order = db.orders.findById(req.params.id);
|
|
21
|
+
if (order.userId !== req.user.id && !req.user.isAdmin) {
|
|
22
|
+
return res.status(403).json({ error: 'Forbidden' });
|
|
23
|
+
}
|
|
24
|
+
res.json(order);
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Testing
|
|
29
|
+
|
|
30
|
+
1. Create user A and user B
|
|
31
|
+
2. Get A's auth token
|
|
32
|
+
3. Access B's resources by changing IDs
|
|
33
|
+
4. If successful → BOLA
|
|
34
|
+
|
|
35
|
+
## Remediation
|
|
36
|
+
|
|
37
|
+
1. Verify ownership on every object access
|
|
38
|
+
2. Use UUIDs instead of sequential IDs
|
|
39
|
+
3. Implement proper authorization middleware
|
|
40
|
+
4. Log all access control failures
|
|
41
|
+
5. Test with automated scanners
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# BOPLA — Broken Function Level Authorization (API2:2023)
|
|
2
|
+
|
|
3
|
+
OWASP API Security Top 10 — #2
|
|
4
|
+
|
|
5
|
+
## Description
|
|
6
|
+
|
|
7
|
+
BOPLA occurs when an API exposes administrative or privileged functions that regular users can access. The attacker uses a regular user token to call admin endpoints.
|
|
8
|
+
|
|
9
|
+
## Detection
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
// Vulnerable: no admin check
|
|
13
|
+
app.delete('/api/admin/users/:id', authenticate, (req, res) => {
|
|
14
|
+
db.users.delete(req.params.id);
|
|
15
|
+
res.status(204).send();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Secure: role check
|
|
19
|
+
app.delete('/api/admin/users/:id', authenticate, authorize('admin'), (req, res) => {
|
|
20
|
+
db.users.delete(req.params.id);
|
|
21
|
+
res.status(204).send();
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Testing
|
|
26
|
+
|
|
27
|
+
1. Create a regular user and an admin user
|
|
28
|
+
2. Get regular user token
|
|
29
|
+
3. Try all admin endpoints with regular token
|
|
30
|
+
4. If any succeed → BOPLA
|
|
31
|
+
|
|
32
|
+
## Remediation
|
|
33
|
+
|
|
34
|
+
1. Implement role-based access control
|
|
35
|
+
2. Verify authorization on every admin function
|
|
36
|
+
3. Never rely on route-level auth alone
|
|
37
|
+
4. Use function-level authorization decorators/middleware
|
|
38
|
+
5. Test with least-privilege tokens
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# API Inventory — Asset Management
|
|
2
|
+
|
|
3
|
+
## Why It Matters
|
|
4
|
+
|
|
5
|
+
APIs proliferate faster than documentation:
|
|
6
|
+
- Shadow APIs (undeclared, unmonitored)
|
|
7
|
+
- Deprecated versions (still running, weaker security)
|
|
8
|
+
- Debug endpoints (exposed in production)
|
|
9
|
+
- Misconfigured new endpoints
|
|
10
|
+
|
|
11
|
+
## Discovery Techniques
|
|
12
|
+
|
|
13
|
+
### Automated
|
|
14
|
+
```bash
|
|
15
|
+
# Subdomain enumeration
|
|
16
|
+
subfinder -d example.com | httpx -silent
|
|
17
|
+
|
|
18
|
+
# Path enumeration
|
|
19
|
+
ffuf -w /usr/share/wordlists/api.txt -u https://api.example.com/FUZZ
|
|
20
|
+
|
|
21
|
+
# Swagger/OpenAPI discovery
|
|
22
|
+
ffuf -w endpoints.txt -u https://example.com/FUZZ/swagger.json
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Manual
|
|
26
|
+
- Review JavaScript source for API calls
|
|
27
|
+
- Check network tab in browser devtools
|
|
28
|
+
- Monitor DNS records for subdomain patterns
|
|
29
|
+
- Review job postings for tech stack hints
|
|
30
|
+
|
|
31
|
+
### From Response Analysis
|
|
32
|
+
- Look for API version headers
|
|
33
|
+
- Check response structure differences
|
|
34
|
+
- Identify internal hostnames or IPs
|
|
35
|
+
|
|
36
|
+
## Inventory Checklist
|
|
37
|
+
|
|
38
|
+
- [ ] All API subdomains mapped
|
|
39
|
+
- [ ] All API paths discovered
|
|
40
|
+
- [ ] HTTP methods tested per path
|
|
41
|
+
- [ ] Content types tested per endpoint
|
|
42
|
+
- [ ] Authentication status per endpoint
|
|
43
|
+
- [ ] Version history documented
|
|
44
|
+
- [ ] Deprecated endpoints flagged
|
|
45
|
+
- [ ] Debug/test endpoints identified
|
|
46
|
+
- [ ] Third-party API dependencies listed
|
|
47
|
+
- [ ] Shadow APIs found and documented
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Rate Limiting — API Abuse Prevention
|
|
2
|
+
|
|
3
|
+
## Why It Matters
|
|
4
|
+
|
|
5
|
+
Without rate limiting:
|
|
6
|
+
- Brute force: 10,000 passwords tested in 1 minute
|
|
7
|
+
- Enumeration: entire user database scraped
|
|
8
|
+
- DoS: server overwhelmed by single client
|
|
9
|
+
- Financial: costs from cloud API calls
|
|
10
|
+
|
|
11
|
+
## Implementation Patterns
|
|
12
|
+
|
|
13
|
+
### By IP
|
|
14
|
+
```nginx
|
|
15
|
+
limit_req_zone $binary_remote_addr zone=api:10m rate=30r/m;
|
|
16
|
+
```
|
|
17
|
+
Pros: simple, no client changes
|
|
18
|
+
Cons: shared IPs (NAT), proxy bypass
|
|
19
|
+
|
|
20
|
+
### By User ID
|
|
21
|
+
```javascript
|
|
22
|
+
// After authentication
|
|
23
|
+
const key = `ratelimit:${req.user.id}`;
|
|
24
|
+
const count = await redis.incr(key);
|
|
25
|
+
if (count > 100) return 429;
|
|
26
|
+
```
|
|
27
|
+
Pros: accurate per user
|
|
28
|
+
Cons: requires auth, unauthenticated = IP fallback
|
|
29
|
+
|
|
30
|
+
### By Token
|
|
31
|
+
```javascript
|
|
32
|
+
const key = `ratelimit:${req.headers['x-api-key']}`;
|
|
33
|
+
```
|
|
34
|
+
Pros: works for service accounts
|
|
35
|
+
Cons: tokens can be shared
|
|
36
|
+
|
|
37
|
+
### Hybrid
|
|
38
|
+
```javascript
|
|
39
|
+
const key = req.user?.id || req.ip;
|
|
40
|
+
```
|
|
41
|
+
Best approach: authenticated users by ID, anonymous by IP.
|
|
42
|
+
|
|
43
|
+
## Recommended Limits
|
|
44
|
+
|
|
45
|
+
| Endpoint Type | Limit | Window |
|
|
46
|
+
|--------------|-------|--------|
|
|
47
|
+
| Login | 5 | 15 min |
|
|
48
|
+
| Registration | 3 | 1 hour |
|
|
49
|
+
| Password Reset| 3 | 1 hour |
|
|
50
|
+
| General API | 100 | 1 min |
|
|
51
|
+
| File Upload | 10 | 1 hour |
|
|
52
|
+
| Search | 30 | 1 min |
|
|
53
|
+
| WebSocket Msg| 60 | 1 min |
|
|
54
|
+
|
|
55
|
+
## Response
|
|
56
|
+
|
|
57
|
+
```http
|
|
58
|
+
HTTP/1.1 429 Too Many Requests
|
|
59
|
+
Retry-After: 900
|
|
60
|
+
Content-Type: application/json
|
|
61
|
+
|
|
62
|
+
{
|
|
63
|
+
"error": "rate_limit_exceeded",
|
|
64
|
+
"retry_after_seconds": 900
|
|
65
|
+
}
|
|
66
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Third-Party API Security
|
|
2
|
+
|
|
3
|
+
## The Trust Problem
|
|
4
|
+
|
|
5
|
+
Your security depends on APIs you do not control:
|
|
6
|
+
- Payment gateways, auth providers, SaaS integrations
|
|
7
|
+
- Data enrichment services, analytics, monitoring
|
|
8
|
+
- AI/ML APIs, cloud functions, webhooks
|
|
9
|
+
|
|
10
|
+
## Risk Categories
|
|
11
|
+
|
|
12
|
+
### 1. Data Exposure
|
|
13
|
+
When your app sends data to third parties:
|
|
14
|
+
- Are they encrypting at rest?
|
|
15
|
+
- Do they log sensitive data?
|
|
16
|
+
- What happens to data on account deletion?
|
|
17
|
+
- Do they sell or share data?
|
|
18
|
+
|
|
19
|
+
### 2. Supply Chain Attack
|
|
20
|
+
When third-party API is compromised:
|
|
21
|
+
- Attacker controls responses
|
|
22
|
+
- Malicious data injected downstream
|
|
23
|
+
- Credential theft from third-party breach
|
|
24
|
+
|
|
25
|
+
### 3. Webhook Abuse
|
|
26
|
+
When third party calls your endpoint:
|
|
27
|
+
- Spoofed webhook calls
|
|
28
|
+
- Replay attacks
|
|
29
|
+
- Payload manipulation
|
|
30
|
+
- Webhook endpoint DDoS
|
|
31
|
+
|
|
32
|
+
## Remediation
|
|
33
|
+
|
|
34
|
+
### Outgoing Calls
|
|
35
|
+
1. Enforce HTTPS with certificate validation
|
|
36
|
+
2. Set timeouts on all requests
|
|
37
|
+
3. Implement retry logic with exponential backoff
|
|
38
|
+
4. Treat all external data as untrusted
|
|
39
|
+
5. Validate response schemas
|
|
40
|
+
6. Log all external calls for audit
|
|
41
|
+
7. Store credentials in a secrets manager
|
|
42
|
+
|
|
43
|
+
### Incoming Webhooks
|
|
44
|
+
1. Verify webhook signatures (HMAC)
|
|
45
|
+
2. Validate payload schema
|
|
46
|
+
3. Use a webhook secret per integration
|
|
47
|
+
4. Implement replay protection (timestamp + nonce)
|
|
48
|
+
5. Rate limit per webhook source
|
|
49
|
+
6. IP allowlist where possible
|
|
50
|
+
7. Return 200 quickly, process async
|
|
51
|
+
|
|
52
|
+
### Monitoring
|
|
53
|
+
1. Monitor for unusual third-party response patterns
|
|
54
|
+
2. Alert on third-party SLA breaches
|
|
55
|
+
3. Review third-party security postures regularly
|
|
56
|
+
4. Test third-party failure modes (graceful degradation)
|
|
57
|
+
5. Keep third-party dependencies minimal
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# API Security Audit Report
|
|
2
|
+
|
|
3
|
+
**Target:** [API Name/URL]
|
|
4
|
+
**Date:** [YYYY-MM-DD]
|
|
5
|
+
**Auditor:** [Name]
|
|
6
|
+
**Version:** [API Version]
|
|
7
|
+
|
|
8
|
+
## Executive Summary
|
|
9
|
+
|
|
10
|
+
[Brief overview: scope, critical findings, overall risk level]
|
|
11
|
+
|
|
12
|
+
**Risk Level:** [Critical / High / Medium / Low]
|
|
13
|
+
**Endpoints Tested:** [X]
|
|
14
|
+
**Vulnerabilities Found:** [X]
|
|
15
|
+
|
|
16
|
+
## Scope
|
|
17
|
+
|
|
18
|
+
### In Scope
|
|
19
|
+
- [Endpoint 1]
|
|
20
|
+
- [Endpoint 2]
|
|
21
|
+
- [Authentication mechanism]
|
|
22
|
+
- [API version]
|
|
23
|
+
|
|
24
|
+
### Out of Scope
|
|
25
|
+
- [Anything excluded]
|
|
26
|
+
|
|
27
|
+
## Methodology
|
|
28
|
+
|
|
29
|
+
- [X] Discovery & Mapping
|
|
30
|
+
- [X] Authentication Testing
|
|
31
|
+
- [X] Authorization Testing (BOLA/BOPLA)
|
|
32
|
+
- [X] Input Validation
|
|
33
|
+
- [X] Rate Limiting
|
|
34
|
+
- [X] Data Exposure
|
|
35
|
+
- [X] Configuration Review
|
|
36
|
+
|
|
37
|
+
## Findings
|
|
38
|
+
|
|
39
|
+
### CRITICAL
|
|
40
|
+
| # | Finding | Endpoint | Impact | Remediation |
|
|
41
|
+
|---|---------|----------|--------|-------------|
|
|
42
|
+
| 1 | [Title] | [URL] | [Impact] | [Fix] |
|
|
43
|
+
| 2 | [Title] | [URL] | [Impact] | [Fix] |
|
|
44
|
+
|
|
45
|
+
### HIGH
|
|
46
|
+
| # | Finding | Endpoint | Impact | Remediation |
|
|
47
|
+
|---|---------|----------|--------|-------------|
|
|
48
|
+
| 3 | [Title] | [URL] | [Impact] | [Fix] |
|
|
49
|
+
|
|
50
|
+
### MEDIUM
|
|
51
|
+
| # | Finding | Endpoint | Impact | Remediation |
|
|
52
|
+
|---|---------|----------|--------|-------------|
|
|
53
|
+
| 4 | [Title] | [URL] | [Impact] | [Fix] |
|
|
54
|
+
|
|
55
|
+
## Detailed Findings
|
|
56
|
+
|
|
57
|
+
### Finding 1: [Title] (Critical)
|
|
58
|
+
**Endpoint:** [URL]
|
|
59
|
+
**Description:** [Detailed description]
|
|
60
|
+
**Request:**
|
|
61
|
+
```http
|
|
62
|
+
GET /api/...
|
|
63
|
+
```
|
|
64
|
+
**Response:**
|
|
65
|
+
```http
|
|
66
|
+
HTTP/1.1 200 OK
|
|
67
|
+
{ ... }
|
|
68
|
+
```
|
|
69
|
+
**Impact:** [Business/technical impact]
|
|
70
|
+
**Remediation:** [Step-by-step fix]
|
|
71
|
+
**CVSS:** [Score]
|
|
72
|
+
|
|
73
|
+
### Finding 2: [Title]
|
|
74
|
+
...
|
|
75
|
+
|
|
76
|
+
## Recommendations
|
|
77
|
+
|
|
78
|
+
1. [Priority action]
|
|
79
|
+
2. [Priority action]
|
|
80
|
+
3. [Priority action]
|
|
81
|
+
|
|
82
|
+
## Appendix
|
|
83
|
+
|
|
84
|
+
### Tools Used
|
|
85
|
+
- [Tool/version]
|
|
86
|
+
|
|
87
|
+
### Reference
|
|
88
|
+
- OWASP API Security Top 10 (2023)
|
|
89
|
+
- [Other references]
|