TL;DR
If a website’s XSS filter simply replaces characters like <, >, and ", you can often bypass it by using different encoding methods (HTML entities, URL encoding, Unicode) or case mixing. This guide shows common techniques.
Bypassing Character-Based XSS Filters
- Understand the Filter: First, try a simple XSS payload to see what characters are blocked. For example:
Note which characters get replaced or removed.
- HTML Entities: If the filter replaces
<and>, try using their HTML entity equivalents: - Double Encoding: Sometimes filters only decode once. Try encoding the entities again:
<> - URL Encoding: If the input is URL encoded, try encoding characters that are being filtered. For example, if
<is blocked:%3Cscript%3Ealert(1)%3C/script%3E - Unicode Encoding: Use Unicode character representations. For example, for
<(less than): - Case Mixing: Some filters are case-sensitive. Try mixing upper and lower case letters:
- Alternative Tags/Attributes: If
scriptis blocked, try other tags that can execute JavaScript (e.g.,imgwithonerror): - Event Handlers: Use event handlers in HTML elements:
- Comments: Try using HTML comments to break up the payload:
- Context Awareness: Consider where your input is being placed in the HTML. If it’s inside an attribute, you might need to use different techniques than if it’s directly in the body.
- If within a
styleattribute, try CSS injection:style="width:100%; filter:url(javascript:alert(1))"
- If within a
- Browser Differences: Different browsers may interpret XSS payloads differently. Test your bypasses in multiple browsers (Chrome, Firefox, Safari, Edge).
Important Note: Exploiting XSS vulnerabilities without permission is illegal and unethical. This information is for educational purposes only.

