Bypassing WAF to perform XSS
A reflected parameter on an admin login page echoed user input without sanitisation, allowing HTML injection. A web application firewall blocked common XSS payloads, but the author bypassed it by encoding JavaScript in Base64 and executing it via an SVG onload handler, achieving script execution.
Published on medium.com
{{media:0}}
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
The target was a website the author refers to as website.com for privacy reasons. It exposed an admin login form in the /admin directory. The interesting behaviour was not in the login logic itself but in how the application reported a failed login: the error message was passed in a query parameter and rendered back into the page.

The screenshot shows the admin panel at website.com/admin.
Setup
The report describes no special tooling, accounts or versions. The work was done by hand in a browser: submitting the login form, watching the resulting URL, and then editing the msg parameter directly. The only precondition was access to the public /admin login page.
Finding it
The author entered random credentials to see how the application responded. The failed login redirected to this URL:
/admin/index.php?msg=Invalid Email and Password

The error text is carried in ?msg= and displayed on the page. Reflecting a message supplied by the request is a common implementation, and it is exactly the kind of place where user input reaches the HTML.
To confirm that the parameter value is echoed verbatim, the author changed it to a plain string:
website.com/admin/index.php?msg=Hello World

The value came back in the red-fonted error text, and the author notes that every input entered into msg is reflected there.
Exploitation
Step 1: HTML injection
With reflection confirmed, the next test was whether HTML tags survive:
?msg=<h1>Hello World</h1>

The tag was rendered as markup, giving HTML injection. That gives HTML injection, and the next question is whether script can be made to run.
Step 2: Probing the filter
The author tried more than 50 basic XSS payloads. The ones shown in the report are:
?msg=<script>alert(1)</script>
?msg=<img src=xss onerror=alert(1)>
?msg=<input/onmouseover=”javaSCRIPT:confirm(1)”
?msg=<iframe %00 src=”	javascript:prompt(1)	”%00>
All of them were blocked by the server. The pattern of blocks suggested a web application firewall in front of the application. From the payloads that were rejected, the author concluded that the WAF filters:
- every payload containing
<script,<frame,<inputor<form, which are blocked directly; - every payload containing
alert( ), which is also blocked directly.
The screenshot shows the malicious XSS requests being blocked by the WAF.
Step 3: Trying img
While probing, the author noticed that <img was not filtered. The next payload was built around it:
?msg=<img/src=`%00`%20onerror=this.onerror=confirm(1)
It was reflected, but no XSS fired.

The screenshot shows the img payload reflected without execution. The image route reflected the input but did not execute anything inside it, so the author moved on.
Step 4: Trying svg
Next, <svg> turned out not to be filtered either. Since alert( ) is blocked, the author switched to confirm( ), which had worked in earlier attempts:
<svg><script%20?>confirm(1)

This was reflected as a blank space, with no popup. The reflection suggested the author was close, so the next step was to keep trying bypasses, including Base64 decoding with eval.atob, still using <svg> because it was getting through.
Step 5: Base64 payload
The payload that worked:
<svg/onload=eval(atob(‘YWxlcnQoJ1hTUycp’))>
The Base64 string decodes to alert('XSS'). The blocked keyword never appears literally in the request, and the browser decodes and executes it on the onload event of the svg element. The popup fired.
The screenshot shows the resulting XSS popup.
Step 6: Reading cookies
With the technique confirmed, the author used the same construction to read the document cookie:
<svg/onload=eval(atob(‘YWxlcnQoZG9jdW1lbnQuY29va2llKQ==’))>
This Base64 string decodes to alert(document.cookie), and it executed as expected.
Encoding a payload that the WAF blocks into Base64 gives the freedom to execute whatever is needed, because the encoded form is not detected. The author notes that the whole XSS took about 20 minutes and was more of a fun challenge than a long hunt.
Root cause
The application reflects the msg query parameter into the page without HTML-encoding it, so any markup supplied in the URL becomes part of the document. That is the underlying flaw: the error message is treated as trusted HTML.
The WAF in front of the application is a blacklist. It blocks specific tags (<script, <frame, <input, <form) and the string alert( ), but it does not block <svg> or <img. Because the browser evaluates eval(atob(...)) at runtime, the dangerous code never appears literally in the request. The defence therefore fails at the point where it matters: it filters syntax rather than preventing the injection itself.
Impact
Opening a crafted /admin/index.php?msg= URL runs JavaScript in the browser in the context of the site, as the author demonstrated with a popup. In the report the author demonstrates reading document.cookie, which is the usual route to session theft. The report does not state which cookies are set, whether they are HttpOnly, or what an attacker could reach with a stolen admin session; those details are not given. The practical impact depends on who visits the link and what the session allows, and the report does not go beyond the cookie read.
Fix
The report does not describe any fix or vendor response. The change that addresses the root cause is to HTML-encode the msg value before rendering it, so that markup in the parameter is displayed as text rather than parsed. A WAF rule blocking <svg> or eval/atob would only raise the bar; it would not remove the injection. Output encoding is the fix, and the WAF is at best a secondary layer.
Variants to test
- Other unfiltered tags. The author found
<imgand<svg>were not blocked. On another target, enumerate tags the filter misses and check whether the reflection executes. A positive result is a popup from a tag the WAF allowed through. - Event handlers instead of
alert. Sincealert( )was blocked,confirm( )was used. Try other sinks such asprompt,printor DOM writes. A positive result is any of them executing from the reflected parameter. - Encoding to evade keyword filters. The working bypass was Base64 with
eval(atob(...)). Try other encodings the browser can decode, and check whether the decoded payload executes. A positive result is execution while the request contains no blocked literal. - Reflected error parameters generally. Any parameter that echoes an error message back into the page, such as
msg,errorormessage, is worth testing with a harmless tag first. A positive result is the tag rendering as markup rather than text.
What happened, in plain words
A security researcher was looking for a common web bug called cross-site scripting, usually shortened to XSS. In plain terms, XSS means that a website takes something a visitor typed or put in a link and shows it back on the page as if it were part of the site's own code. If the visitor can sneak in a small piece of code, the browser will run it, and that code can do things on the site's behalf.
The researcher found a website with an admin login page. When a login failed, the site put the error message into the web address and showed it on the page. That is the opening: anything placed in that part of the address appears on the page. The researcher tried to put HTML (the language web pages are written in) and then JavaScript (the language browsers run) into that spot. A protective filter, called a web application firewall (WAF), blocked the obvious attempts. The researcher then hid the code inside a different encoding, Base64, so the filter did not detect it, and the browser decoded and ran it. The result was a popup proving the bug, and then a popup showing the visitor's cookies.
This article walks through the same steps slowly, explaining each idea as it appears.
The target
The researcher refers to the site as website.com to protect its identity. It had an admin login form in a folder called /admin. A folder in a web address is just a path, like a directory on your computer; /admin is where the site keeps its administration pages.

The screenshot shows the admin panel at website.com/admin.
An admin panel is the private area where the people who run the site log in to manage it. A login form is the usual pair of boxes for a username or email and a password.
Setup
No special tools were used. The work was done by hand in an ordinary browser: filling in the login form, looking at the address bar afterwards, and then editing part of the address directly. The only thing needed was that the public /admin login page could be opened.
This is worth noting for beginners: you do not need a hacking toolkit to find this kind of bug. A browser, patience and curiosity are enough.
Finding it
The researcher typed random credentials into the login form to see what would happen. "Credentials" simply means the username and password you enter. The login failed, as expected, and the browser was sent to this address:
/admin/index.php?msg=Invalid Email and Password

Let us read that address piece by piece.
/admin/index.phpis the page being loaded.index.phpis a common name for the main file of a folder, and.phptells you the server builds the page with the PHP programming language.- The
?marks the start of extra information sent along with the address. msg=Invalid Email and Passwordis that extra information.msgis the name of a value, and everything after the=is the value itself. This pair is called a query parameter, or just a parameter. Think of it as a sticky note attached to the address: the name on the front, the content on the back.
The page then displayed that error text. Showing an error message is normal, but carrying it in the address and printing it on the page is a habit the researcher notes seeing on many sites. It matters because the address is something a visitor can edit, so anything in it is under the visitor's control.
To check whether the value is copied back exactly, the researcher replaced it with a harmless phrase:
website.com/admin/index.php?msg=Hello World

Line by line:
website.comis the site./admin/index.phpis the same page as before.?msg=Hello Worldsets the parametermsgto the wordsHello World.
The words came back in the red error text on the page. In security language, the value is "reflected": the site takes what you sent and bounces it straight back into the page. The author notes that every input placed in msg appears there.
Exploitation
Step 1: HTML injection
Now that the value is known to be echoed, the next question is whether the page treats it as plain text or as HTML. HTML is the markup language that tells a browser what to display: <h1> around some words, for example, makes them a large heading. The researcher sent this:
?msg=<h1>Hello World</h1>

Line by line:
?msg=starts the parameter again.<h1>is an opening HTML tag meaning "big heading".Hello Worldis the text inside the heading.</h1>closes the heading.
The words appeared as a large heading, which means the browser was given real HTML and obeyed it. This is called HTML injection: you injected markup into the page. The next question is whether actual code, JavaScript, can be made to run.
Step 2: Probing the filter
The researcher tried more than 50 basic XSS payloads. A payload is simply the piece of input you send to test for a bug. The ones shown in the report are:
?msg=<script>alert(1)</script>
?msg=<img src=xss onerror=alert(1)>
?msg=<input/onmouseover=”javaSCRIPT:confirm(1)”
?msg=<iframe %00 src=”	javascript:prompt(1)	”%00>
Line by line:
?msg=<script>alert(1)</script>puts a script tag into the page.<script>tells the browser that what follows is JavaScript, andalert(1)is the classic test command that opens a small popup showing the number 1.</script>closes the tag.?msg=<img src=xss onerror=alert(1)>uses an image tag.src=xsspoints the image at a file that does not exist, andonerror=alert(1)says: if loading the image fails, runalert(1). Because the file never loads, the popup would fire.?msg=<input/onmouseover=”javaSCRIPT:confirm(1)”uses an input field.onmouseovermeans "when the mouse moves over this element". The value is written with HTML entities::is a colon,(is an opening bracket and)is a closing bracket. So the browser reads it asjavaSCRIPT:confirm(1), andconfirm(1)is a popup with an OK and Cancel button. The mixed capitalisation ofjavaSCRIPTis an attempt to slip past a filter that looks for the exact lowercase word.?msg=<iframe %00 src=”	javascript:prompt(1)	”%00>uses an iframe, a box inside the page that loads another page.%00is a null byte, an invisible character, and	is a tab character; both are attempts to confuse the filter.javascript:prompt(1)would run a popup that asks for input.
All of them were blocked by the server. A server is the computer that stores the site and sends pages to your browser. When several different attempts are all refused in the same way, it suggests something is inspecting the requests before they reach the site. That something is a web application firewall, or WAF: a filter that sits in front of a website and rejects requests that look malicious, a bit like a bouncer checking names against a list at the door.
From the payloads that were rejected, the researcher concluded that the WAF filters:
- every payload containing
<script,<frame,<inputor<form, which are blocked directly; - every payload containing
alert( ), which is also blocked directly.
The screenshot shows the malicious XSS requests being blocked by the WAF.
A filter like this is called a blacklist: it names the things it dislikes and blocks those. The weakness of a blacklist is that it only stops what someone thought to list.
Step 3: Trying img
While probing, the researcher noticed that <img was not filtered. The next payload was built around it:
?msg=<img/src=`%00`%20onerror=this.onerror=confirm(1)
Line by line:
?msg=starts the parameter.<imgbegins an image tag, which the filter did not block./src=is the image source, written with a slash instead of a space. Browsers are lenient about this kind of formatting.`%00`is the source value: a null byte, an invisible character, wrapped in backticks. The idea is to break up the text so a filter does not recognise a pattern.%20is an encoded space.onerror=this.onerror=confirm(1)says: when the image fails to load, runconfirm(1), a popup with OK and Cancel.
It was reflected, but no XSS fired.

The screenshot shows the img payload reflected without execution. In other words, the text appeared on the page, but the browser did not run anything from it. The image route got through the filter but did not produce code execution, so the researcher moved on.
Step 4: Trying svg
Next, <svg> turned out not to be filtered either. SVG stands for Scalable Vector Graphics: a format for drawing shapes on a web page, and it is written in HTML-like tags. Since alert( ) is blocked, the researcher switched to confirm( ), which had worked in earlier attempts:
<svg><script%20?>confirm(1)
Line by line:
<svg>opens an SVG drawing area.<script%20?>is an attempt to write a script tag with%20(an encoded space) and a?inside it, to avoid matching the blocked<scriptpattern.confirm(1)is the popup command.

This was reflected as a blank space, with no popup. The screenshot shows the SVG injected but no XSS popup. The fact that something appeared at all suggested the researcher was close, so the next step was to keep trying bypasses, including Base64 decoding with eval.atob, still using <svg> because it was getting through.
Two new ideas appear here. Base64 is a way of writing any text using only ordinary letters, digits and a couple of symbols. It is used everywhere on the web to carry data safely through places that only expect plain characters. atob is a built-in browser function that turns a Base64 string back into ordinary text. eval is a built-in browser function that takes text and runs it as JavaScript. Put together, eval(atob(...)) means: decode this text, then run the result as code. A useful comparison is a letter written in a simple substitution cipher: the postal worker sees only scrambled letters, but the recipient knows how to unscramble it and read the real message.
Step 5: Base64 payload
The payload that worked:
<svg/onload=eval(atob(‘YWxlcnQoJ1hTUycp’))>
Line by line:
<svgopens an SVG element./onload=attaches an event handler. An event handler is a piece of code that waits for something to happen;onloadmeans "when this element has finished loading".eval(atob(starts the decode-then-run sequence.‘YWxlcnQoJ1hTUycp’is the Base64 text. Decoded, it readsalert('XSS').))>closes the function calls and the tag.
The Base64 string decodes to alert('XSS'). The blocked keyword never appears literally in the request, and the encoded payload was not detected by the WAF. The browser, however, does not care how the code was written down: it decodes the string and runs it when the SVG finishes loading. The popup fired.
The screenshot shows the resulting XSS popup.
Step 6: Reading cookies
With the technique confirmed, the researcher used the same construction to read the document cookie:
<svg/onload=eval(atob(‘YWxlcnQoZG9jdW1lbnQuY29va2llKQ==’))>
Line by line:
- The structure is identical to the previous payload: an SVG element, an
onloadhandler, andeval(atob(...)). ‘YWxlcnQoZG9jdW1lbnQuY29va2llKQ==’is the Base64 text. Decoded, it readsalert(document.cookie).
A cookie is a small piece of data that a website asks your browser to store and send back with later requests. Cookies are how a site remembers that you are logged in, so they often act like a temporary key. document.cookie is the browser's way of referring to the cookies for the current page. Showing them in a popup proves that code running on the page can read them.
This Base64 string decodes to alert(document.cookie), and it executed as expected.
Encoding a payload that the WAF blocks into Base64 gives the freedom to execute whatever is needed, because the encoded form is not detected. The researcher notes that the whole XSS took about 20 minutes and was more of a fun challenge than a long hunt.
Root cause
The application reflects the msg query parameter into the page without HTML-encoding it, so any markup supplied in the address becomes part of the document. HTML encoding means converting special characters into harmless stand-ins, so that < becomes something the browser displays as a character rather than treats as the start of a tag. That is the underlying flaw: the error message is treated as trusted HTML.
The WAF in front of the application is a blacklist. It blocks specific tags (<script, <frame, <input, <form) and the string alert( ), but it does not block <svg> or <img. Because the browser evaluates eval(atob(...)) at runtime, the dangerous code never appears literally in the request. The defence therefore fails at the point where it matters: it filters syntax rather than preventing the injection itself.
Impact
Opening a crafted /admin/index.php?msg= link runs JavaScript in the browser in the context of the site, as the author demonstrated with a popup. "In the context of the site" means the code is treated as if it came from the site itself, so it can do what the site's own code could do. In the report the researcher demonstrates reading document.cookie, which is the usual route to session theft: if a cookie identifies a logged-in session, someone who reads it may be able to act as that user. The report does not state which cookies are set, whether they are HttpOnly (a setting that hides a cookie from JavaScript), or what an attacker could reach with a stolen admin session. The practical impact depends on who visits the link and what the session allows, and the report does not go beyond the cookie read.
Fix
The report does not describe any fix or vendor response. The change that addresses the root cause is to HTML-encode the msg value before rendering it, so that markup in the parameter is displayed as text rather than parsed. A WAF rule blocking <svg> or eval/atob would only raise the bar; it would not remove the injection. Output encoding is the fix, and the WAF is at best a secondary layer.
Variants to test
- Other unfiltered tags. The researcher found
<imgand<svg>were not blocked. On another target, list the tags the filter misses and check whether the reflection executes. A positive result is a popup from a tag the WAF allowed through. - Event handlers instead of
alert. Sincealert( )was blocked,confirm( )was used. Try other sinks such asprompt,printor DOM writes. A positive result is any of them executing from the reflected parameter. - Encoding to evade keyword filters. The working bypass was Base64 with
eval(atob(...)). Try other encodings the browser can decode, and check whether the decoded payload executes. A positive result is execution while the request contains no blocked literal. - Reflected error parameters generally. Any parameter that echoes an error message back into the page, such as
msg,errorormessage, is worth testing with a harmless tag first. A positive result is the tag rendering as markup rather than text.
Glossary
- XSS (cross-site scripting): a bug where a site puts visitor-supplied input into a page in a way that lets code run in the visitor's browser.
- HTML: the markup language that describes what a web page contains, using tags such as
<h1>and<img>. - HTML injection: getting your own HTML tags into a page through input the site does not encode.
- HTML encoding: converting special characters into harmless stand-ins so they display as text instead of being treated as markup.
- JavaScript: the programming language that browsers run to make pages interactive.
- Payload: the piece of input you send to test for a bug.
- Query parameter: a name and value pair attached to a web address after a
?, such asmsg=Hello World. - Reflection: when a site sends back input you supplied and displays it on the page.
- WAF (web application firewall): a filter in front of a website that inspects requests and blocks ones that look malicious.
- Blacklist: a filter that blocks a list of known-bad things, rather than allowing only known-good things.
- Server: the computer that stores a website and sends its pages to your browser.
- Credentials: the username and password used to log in.
- Admin panel: the private area where the people who run a site manage it.
- Event handler: code attached to an element that runs when something happens, such as
onloadoronerror. alert,confirm,prompt: browser popup functions used to prove that code ran.- SVG: a format for drawing shapes on a web page, written in HTML-like tags.
- iframe: a box inside a page that loads another page.
- Null byte: an invisible character, written
%00in a web address, sometimes used to confuse filters. - Base64: a way of writing any text using only ordinary letters, digits and a couple of symbols.
atob: a browser function that decodes a Base64 string back into ordinary text.eval: a browser function that runs text as JavaScript.- Cookie: a small piece of data a site asks your browser to store and send back with later requests, often used to remember that you are logged in.
document.cookie: the browser's way of referring to the cookies for the current page.- Session: a logged-in period on a site, usually tracked by a cookie.
- Session theft: stealing a cookie that identifies a logged-in session so you can act as that user.
HttpOnly: a cookie setting that hides the cookie from JavaScript.- DOM: the browser's in-memory model of the page, which code can read and change.