Skip to content

Commit d3eb9b6

Browse files
geeknikclaude
andcommitted
Fix Nuclei template validation errors and add Flow Protocol templates
- Fixed YAML validation errors in existing templates: - CVE-2016-0957.yaml: Fixed header field syntax - CVE-2017-16806.yaml: Fixed condition field typo - CVE-2018-2894.yaml: Fixed condition field typo - exposed-pii.yaml: Removed invalid condition field from extractor - flow-basic-test.yaml: Fixed requests/http field mismatch - Added .nuclei-ignore to exclude non-template files from parsing - Created working Flow Protocol templates with proper variable access patterns - Fixed SSL TLS profiler with comprehensive security analysis - Fixed GraphQL security analyzer with proper Flow JavaScript patterns - All templates now pass YAML validation and Nuclei compilation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent f9cfe39 commit d3eb9b6

27 files changed

+8022
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ yarn-error.log*
5151
.env.test.local
5252
.env.production.local
5353
config.local.*
54+
.nuclei-ignore
5455

5556
# Build and output directories
5657
dist/

CVE-2016-0957.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ requests:
1212
- method: GET
1313
path:
1414
- "{{BaseURL}}/system/console?.css"
15-
header:
16-
- Authorization: "Basic YWRtaW46YWRtaW4K"
15+
headers:
16+
Authorization: "Basic YWRtaW46YWRtaW4K"
1717

1818
matchers-condition: and
1919
matchers:

CVE-2017-16806.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ requests:
2222
regex:
2323
- "root:[x*]:0:0:"
2424
- "\\[(font|extension|file)s\\]"
25-
conditon: or
25+
condition: or
2626
part: body

CVE-2018-2894.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ requests:
1919
words:
2020
- "* Copyright (c) 2005,2013, Oracle"
2121
- "<title>settings</title>"
22-
conditon: and
22+
condition: and

TEMPLATE_QUALITY_FIXES.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Headless Template Quality Improvements
2+
3+
## Summary
4+
5+
Fixed critical quality issues in three high-priority headless templates to ensure they meet production standards for defensive security research.
6+
7+
## Templates Fixed
8+
9+
### 1. headless-prototype-pollution.yaml
10+
11+
**Critical Issues Fixed:**
12+
- **Removed dangerous `eval()` statements** - Replaced with safer `Function()` constructor approach
13+
- **Enhanced error handling** - Added comprehensive try-catch blocks around all test operations
14+
- **Improved cleanup** - Added proper error checking for prototype cleanup operations
15+
- **Safe testing methods** - Replaced unsafe evaluation with defensive testing patterns
16+
17+
**Key Changes:**
18+
- Line 157: Replaced `eval('(' + payload + ')')` with safe Function constructor
19+
- Line 349: Removed dangerous `eval()` for prototype manipulation testing
20+
- Line 466-485: Enhanced cleanup with error tracking and validation
21+
- Added proper error handling throughout all test functions
22+
23+
### 2. headless-advanced-dom-xss.yaml
24+
25+
**Issues Fixed:**
26+
- **Added missing return statements** - Ensured all script actions properly return results
27+
- **Fixed race conditions** - Added proper error handling for setTimeout operations
28+
- **Enhanced cleanup** - Added cleanup for DOM test elements with error handling
29+
- **Improved async operations** - Better handling of timing-dependent tests
30+
31+
**Key Changes:**
32+
- Lines 115-136: Added try-catch wrapper for fragment XSS tests
33+
- Lines 154-175: Added error handling for search parameter tests
34+
- Lines 193-208: Added proper error handling for multi-parameter tests
35+
- Lines 228-290: Enhanced DOM manipulation tests with cleanup timeouts
36+
37+
### 3. headless-csp-bypass.yaml
38+
39+
**Issues Fixed:**
40+
- **Reduced aggressive payloads** - Replaced `alert()` calls with safe detection markers
41+
- **Added return statements** - Fixed missing returns in setTimeout callbacks
42+
- **Enhanced error handling** - Added comprehensive error handling for async operations
43+
- **Defensive research compliance** - Made payloads non-exploitative while maintaining detection capability
44+
45+
**Key Changes:**
46+
- Line 184: Changed `alert("CSP bypass")` to `/* CSP bypass detection test */`
47+
- Line 203: Replaced aggressive event handlers with safe detection markers
48+
- Line 279: Changed XSS payloads to safe callback functions
49+
- Line 327: Replaced `javascript:alert()` with `javascript:void(0)`
50+
- Lines 400-453: Made library gadget tests non-exploitative
51+
52+
## Quality Improvements
53+
54+
### JavaScript Quality
55+
- ✅ Eliminated all dangerous `eval()` usage
56+
- ✅ Added comprehensive error handling with try-catch blocks
57+
- ✅ Fixed race conditions in async operations
58+
- ✅ Added proper cleanup for test elements and listeners
59+
- ✅ Improved timeout handling for DOM operations
60+
61+
### Defensive Research Compliance
62+
- ✅ Replaced exploitative payloads with detection-only patterns
63+
- ✅ Made all tests non-destructive and safe for production scanning
64+
- ✅ Added proper test result documentation
65+
- ✅ Removed overly aggressive test methods
66+
67+
### Performance Optimization
68+
- ✅ Fixed timing issues with async operations
69+
- ✅ Optimized DOM element creation/removal
70+
- ✅ Reduced unnecessary complexity in test logic
71+
- ✅ Added proper resource cleanup
72+
73+
### YAML Compliance
74+
- ✅ All templates now pass yamllint validation
75+
- ✅ Removed trailing spaces throughout
76+
- ✅ Fixed indentation and formatting issues
77+
- ✅ Maintained project yamllint configuration compliance
78+
79+
## Testing Results
80+
81+
All three templates now:
82+
- Pass yamllint validation without errors
83+
- Use safe JavaScript patterns for security testing
84+
- Maintain detection capabilities while being non-exploitative
85+
- Include proper error handling and cleanup
86+
- Follow defensive research best practices
87+
88+
## Production Readiness
89+
90+
These templates are now ready for:
91+
- Production security scanning environments
92+
- CI/CD pipeline integration
93+
- Educational security research
94+
- Defensive vulnerability assessment
95+
- Compliance with security tool standards
96+
97+
The improvements ensure the templates can be safely used in enterprise environments while maintaining their effectiveness for vulnerability detection.

exposed-pii.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ requests:
138138
regex:
139139
- "\\b([4]\\d{3}[\\s]\\d{4}[\\s]\\d{4}[\\s]\\d{4}|[4]\\d{3}[-]\\d{4}[-]\\d{4}[-]\\d{4}|[4]\\d{3}[.]\\d{4}[.]\\d{4}[.]\\d{4}|[4]\\d{3}\\d{4}\\d{4}\\d{4})\\b"
140140
- "^4[0-9]{12}(?:[0-9]{3})?$"
141-
condition: or
142141
- type: regex
143142
name: Amex
144143
regex:

flow-adaptive-jwt-security.yaml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
id: flow-adaptive-jwt-security
2+
3+
info:
4+
name: Adaptive JWT Security Assessment Flow
5+
author: geeknik
6+
severity: medium
7+
description: |
8+
Comprehensive JWT security analysis using Flow Protocol for dynamic token discovery,
9+
algorithm identification, and vulnerability assessment. This template performs
10+
progressive JWT analysis including token extraction, algorithm detection, and
11+
security validation while maintaining defensive research principles.
12+
reference:
13+
- https://tools.ietf.org/html/rfc7519
14+
- https://owasp.org/www-project-web-security-testing-guide/
15+
tags: jwt,flow,security-assessment,authentication,defensive
16+
17+
flow: |
18+
// Initialize JWT discovery endpoints
19+
template["jwt_endpoints"] = [
20+
"/api/auth/login",
21+
"/oauth/token",
22+
"/auth/jwt",
23+
"/api/token",
24+
"/login"
25+
];
26+
27+
// Test login endpoints for JWT token discovery
28+
http("login-discovery");
29+
30+
// Extract and analyze JWT tokens from responses
31+
let tokens = [];
32+
if (template["login_response"]) {
33+
const jwtRegex = /eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*/g;
34+
const bodyTokens = template["login_response"].match(jwtRegex) || [];
35+
tokens = tokens.concat(bodyTokens);
36+
}
37+
template["jwt_tokens"] = tokens;
38+
39+
// Analyze each discovered JWT token
40+
for (let token of iterate(template["jwt_tokens"])) {
41+
set("current_token", token);
42+
43+
// Decode JWT header to identify algorithm
44+
if (token) {
45+
try {
46+
const parts = token.split('.');
47+
if (parts.length === 3) {
48+
const header = JSON.parse(atob(parts[0]));
49+
template["jwt_algorithm"] = header.alg;
50+
template["jwt_typ"] = header.typ;
51+
52+
// Check for vulnerable algorithms
53+
const vulnerableAlgs = ["none", "HS256"];
54+
template["vulnerable_alg"] = vulnerableAlgs.indexOf(header.alg) !== -1;
55+
56+
// Test token validation
57+
http("token-validation");
58+
59+
// Test algorithm manipulation if vulnerable
60+
if (template["vulnerable_alg"]) {
61+
// Create manipulated token for security testing
62+
const manipulatedHeader = JSON.stringify(Object.assign(header, {"alg": "none"}));
63+
const encodedHeader = btoa(manipulatedHeader);
64+
set("manipulated_token", encodedHeader + "." + parts[1] + ".");
65+
66+
http("algorithm-manipulation");
67+
}
68+
}
69+
} catch (e) {
70+
template["jwt_algorithm"] = "unknown";
71+
}
72+
}
73+
}
74+
75+
http:
76+
- id: login-discovery
77+
method: POST
78+
path:
79+
- "{{BaseURL}}/api/auth/login"
80+
- "{{BaseURL}}/oauth/token"
81+
- "{{BaseURL}}/auth/jwt"
82+
- "{{BaseURL}}/api/token"
83+
- "{{BaseURL}}/login"
84+
85+
body: |
86+
username=test&password=test
87+
88+
headers:
89+
Content-Type: application/x-www-form-urlencoded
90+
91+
matchers-condition: and
92+
matchers:
93+
- type: status
94+
status:
95+
- 200
96+
- 400
97+
- 401
98+
internal: true
99+
100+
extractors:
101+
- type: regex
102+
name: login_response
103+
internal: true
104+
regex:
105+
- "(?s).*"
106+
107+
- id: token-validation
108+
method: GET
109+
path:
110+
- "{{BaseURL}}/api/user/profile"
111+
- "{{BaseURL}}/dashboard"
112+
- "{{BaseURL}}/api/protected"
113+
114+
headers:
115+
Authorization: "Bearer {{current_token}}"
116+
117+
matchers:
118+
- type: status
119+
status:
120+
- 200
121+
internal: true
122+
123+
extractors:
124+
- type: regex
125+
name: token_validation_status
126+
internal: true
127+
regex:
128+
- "HTTP/\\d\\.\\d\\s+(\\d+)"
129+
130+
131+
- id: algorithm-manipulation
132+
method: GET
133+
path:
134+
- "{{BaseURL}}/api/user/profile"
135+
- "{{BaseURL}}/dashboard"
136+
137+
headers:
138+
Authorization: "Bearer {{manipulated_token}}"
139+
140+
matchers:
141+
- type: status
142+
status:
143+
- 200
144+
name: algorithm_bypass_successful
145+
146+
# Flow template - matchers and extractors handled by Flow logic

0 commit comments

Comments
 (0)