JavaScript Surface Analyzer
Purpose
Extract attacker-relevant intelligence from front-end code and convert it into testable hypotheses.
Inputs
target_url
seed_pages (optional)
auth_context (optional)
Workflow
Phase 1: Asset Enumeration
- Collect static and dynamic script URLs.
- Expand via source maps and chunk manifests where available.
- Track script origin, load condition, and execution context.
Phase 2: Artifact Extraction
- Endpoints, route builders, and API clients.
- Header/token construction logic.
- Feature flags, debug modes, hidden route toggles.
- Secret candidates and key material references.
Phase 3: Sink Analysis
- DOM write sinks:
innerHTML, outerHTML, template insertion.
- Code execution sinks:
eval, Function, setTimeout string usage.
- URL/navigation sinks: dynamic redirects, iframe/src assignments.
- Storage sinks: local/session storage of sensitive artifacts.
Phase 4: Controllability Assessment
- Determine if attacker can influence source data.
- Trace sanitization or encoding at boundaries.
- Estimate exploit preconditions per sink.
Phase 5: Follow-up Planning
- Create endpoint verification cases.
- Create DOM-XSS and open redirect probes.
- Create token misuse and privilege abuse checks.
Minimum Extraction Targets
| Category |
Required Extraction |
| API surface |
method + path hints + caller context |
| Secrets |
key/token candidates with confidence tag |
| Sinks |
sink type + source controllability |
| Hidden features |
flag name + activation condition |
Output Contract
{
"script_inventory": [],
"endpoint_candidates": [],
"secret_candidates": [],
"sink_map": [],
"hidden_features": [],
"follow_up_tests": []
}
Constraints
- Treat secret candidates as sensitive.
- Mark uncertainty for heavily obfuscated code.
Quality Checklist
Detailed Operator Notes
Static + Runtime Correlation
- Correlate bundled route constants with observed network calls.
- Correlate feature flags with guarded code branches.
- Correlate secret candidates with call-site usage.
Sink Prioritization Heuristics
- Prioritize sinks fed by URL, query string, postMessage, or storage.
- Prioritize sinks reachable pre-auth and in shared pages.
- Prioritize sinks with partial sanitization or legacy wrappers.
Obfuscation Strategy
- Start with string table recovery and call-graph sketch.
- Identify decoder/dispatcher stubs before deep tracing.
- Mark unresolved obfuscated segments as explicit unknowns.
Reporting Rules
- Include
controllable_source for each sink candidate.
- Include
execution_context (HTML, attribute, JS string, URL).
- Include follow-up payload family per sink.
Quick Scenarios
Scenario A: Authorization Drift
- Baseline with owned resource.
- Replay with foreign resource identifier.
- Repeat with role shift and fresh session.
- Confirm read/write/delete differences.
Scenario B: Input Handling Weakness
- Send syntactically valid control payload.
- Send semantically malicious variant.
- Verify parser or execution side effect.
- Re-test with content-type variation.
Scenario C: Workflow Bypass
- Execute expected state sequence.
- Attempt out-of-order transition.
- Attempt repeated action replay.
- Confirm server-side state enforcement.
Conditional Decision Matrix
| Condition |
Action |
Evidence Requirement |
| Endpoint found in code but not traffic |
create targeted trigger path for invocation |
call-site + trigger proof |
| Secret candidate appears in multiple bundles |
map runtime use and scope |
usage map with confidence |
| Sink appears sanitized |
verify context-specific sanitizer match |
sink-context trace |
| Obfuscated dispatcher controls routes |
recover dispatcher map before sink triage |
dispatcher mapping artifact |
| Feature flag gates privileged behavior |
test activation constraints and fallback paths |
flag-state behavior diff |
Advanced Coverage Extensions
- Correlate source-map names with production minified call sites.
- Extract hidden API capabilities from autogenerated client stubs.
- Detect unsafe postMessage listeners and origin validation gaps.
- Detect dynamic import paths controlled by user data.
- Detect insecure local storage coupling to auth flows.
1---2name: javascript-surface-analyzer3description: Enumerate and analyze client-side JavaScript for hidden endpoints, secrets, dangerous sinks, and exploitable browser behaviors.4---56# JavaScript Surface Analyzer78## Purpose9Extract attacker-relevant intelligence from front-end code and convert it into testable hypotheses.1011## Inputs12- `target_url`13- `seed_pages` (optional)14- `auth_context` (optional)1516## Workflow17### Phase 1: Asset Enumeration181. Collect static and dynamic script URLs.192. Expand via source maps and chunk manifests where available.203. Track script origin, load condition, and execution context.2122### Phase 2: Artifact Extraction231. Endpoints, route builders, and API clients.242. Header/token construction logic.253. Feature flags, debug modes, hidden route toggles.264. Secret candidates and key material references.2728### Phase 3: Sink Analysis291. DOM write sinks: `innerHTML`, `outerHTML`, template insertion.302. Code execution sinks: `eval`, `Function`, `setTimeout` string usage.313. URL/navigation sinks: dynamic redirects, iframe/src assignments.324. Storage sinks: local/session storage of sensitive artifacts.3334### Phase 4: Controllability Assessment351. Determine if attacker can influence source data.362. Trace sanitization or encoding at boundaries.373. Estimate exploit preconditions per sink.3839### Phase 5: Follow-up Planning401. Create endpoint verification cases.412. Create DOM-XSS and open redirect probes.423. Create token misuse and privilege abuse checks.4344## Minimum Extraction Targets45| Category | Required Extraction |46|---|---|47| API surface | method + path hints + caller context |48| Secrets | key/token candidates with confidence tag |49| Sinks | sink type + source controllability |50| Hidden features | flag name + activation condition |5152## Output Contract53```json54{55 "script_inventory": [],56 "endpoint_candidates": [],57 "secret_candidates": [],58 "sink_map": [],59 "hidden_features": [],60 "follow_up_tests": []61}62```6364## Constraints65- Treat secret candidates as sensitive.66- Mark uncertainty for heavily obfuscated code.6768## Quality Checklist69- [ ] Dynamic script loading is covered.70- [ ] Sink report includes controllability.71- [ ] Follow-up tests are concrete and scoped.7273## Detailed Operator Notes74### Static + Runtime Correlation75- Correlate bundled route constants with observed network calls.76- Correlate feature flags with guarded code branches.77- Correlate secret candidates with call-site usage.7879### Sink Prioritization Heuristics80- Prioritize sinks fed by URL, query string, postMessage, or storage.81- Prioritize sinks reachable pre-auth and in shared pages.82- Prioritize sinks with partial sanitization or legacy wrappers.8384### Obfuscation Strategy85- Start with string table recovery and call-graph sketch.86- Identify decoder/dispatcher stubs before deep tracing.87- Mark unresolved obfuscated segments as explicit unknowns.8889### Reporting Rules90- Include `controllable_source` for each sink candidate.91- Include `execution_context` (HTML, attribute, JS string, URL).92- Include follow-up payload family per sink.9394## Quick Scenarios95### Scenario A: Authorization Drift96- Baseline with owned resource.97- Replay with foreign resource identifier.98- Repeat with role shift and fresh session.99- Confirm read/write/delete differences.100101### Scenario B: Input Handling Weakness102- Send syntactically valid control payload.103- Send semantically malicious variant.104- Verify parser or execution side effect.105- Re-test with content-type variation.106107### Scenario C: Workflow Bypass108- Execute expected state sequence.109- Attempt out-of-order transition.110- Attempt repeated action replay.111- Confirm server-side state enforcement.112113## Conditional Decision Matrix114| Condition | Action | Evidence Requirement |115|---|---|---|116| Endpoint found in code but not traffic | create targeted trigger path for invocation | call-site + trigger proof |117| Secret candidate appears in multiple bundles | map runtime use and scope | usage map with confidence |118| Sink appears sanitized | verify context-specific sanitizer match | sink-context trace |119| Obfuscated dispatcher controls routes | recover dispatcher map before sink triage | dispatcher mapping artifact |120| Feature flag gates privileged behavior | test activation constraints and fallback paths | flag-state behavior diff |121122## Advanced Coverage Extensions1231. Correlate source-map names with production minified call sites.1242. Extract hidden API capabilities from autogenerated client stubs.1253. Detect unsafe postMessage listeners and origin validation gaps.1264. Detect dynamic import paths controlled by user data.1275. Detect insecure local storage coupling to auth flows.