Skip to content
XSS Write-up Intermediate

Exploiting Imported Libraries to Bypass WAF

Greg Gibson Follow

Published on medium.com

{{media:0}}

Greg Gibson, on medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

A private bug bounty program had previously scoped only its mobile apps. The researcher, Greg Gibson, had not had success there, since his strength is finding logic bugs in web applications rather than mobile targets. The program then announced a new scope item: the company's primary landing page, www.redacted.com/*.

That landing page is described as mostly static. It delivers content about the company's various business offerings and redirects to subdomains that were out of scope at the time. One feature stood out because it accepted a URL parameter: a search box that takes a US Zip Code and redirects to a service page with the value reflected into an <input> box.

Setup

The work was done against the newly scoped landing page with no special accounts or roles mentioned. The tools were ordinary: basic reconnaissance, a browser, and the browser's Inspector console. The only precondition was that the site accepted a Zip Code and reflected it into the page at www.redacted.com/service/?zipCode=12345.

Finding it

After basic recon on the mostly static site, nothing of interest appeared. The researcher then looked for a page with URL parameters and found that entering a US Zip Code into one search box redirected to:

Text
www.redacted.com/service/?zipCode=12345

The value was reflected into the <input> box. That reflection is what made the parameter worth testing.

Exploitation

Step 1: HTML content injection

The <input> field lacked the most critical sanitisation. An attacker could escape from the value attribute using " and close the tag using >. That is content injection, which the researcher rates as a P5: a single point and no bounty payout, because on its own there is no actual security impact.

Image for post
The zipCode parameter is vulnerable to content injection and possible further exploit. Shown here are several attributes of the input tag now floating as text just below the input box. From the original on medium.com

The screenshot shows the zipCode parameter vulnerable to content injection, with several attributes of the input tag now floating as text just below the input box.

Rather than submit a P5 and move on, the researcher chose to sit on the injection and try to escalate it.

Step 2: The obvious payload is blocked

The first attempt was the straightforward kill shot:

HTML
"><script>alert(1);</script>

Expectations were low for a company of this size and stature, but it was worth trying. The response was a block.

The screenshot shows a 403 block response from a suspected Cloudflare WAF.

Step 3: Recon against the filter

The next step was to develop a list of HTML tags, attributes and events that pass the filter, so that an injection string could be crafted that survives it. The findings:

Element Result
<script>, <style>, <img> blocked
<a>, <svg>, <object>, <div> allowed
<svg src=> blocked
<object data=> blocked
alert() blocked
confirm() blocked
prompt() not blocked
inline style 403
events seemingly all blocked
onwebkitanimationstart passes

The obscure event onwebkitanimationstart got through by chance. Every example the researcher found for triggering XSS with that event relied on inline style, which was blocked. One such example, from Brute Logic, is:

HTML
<style> div{width:100px;height:100px;-webkit-animation-name:n;}@-webkit-keyframes n{}</style><vulntag attrib=""onwebkitanimationstart=alert(9)><div>    <!-- @brutelogic -->

Since style could not be injected, the researcher searched the Inspector console for webkit-animation to see whether any existing classes could serve as the trigger. That search turned up the Bootstrap Progress bar. Specifically, the Animated Stripes feature, through the classes class="progress-bar progress-bar-striped progress-bar-animated", would act as the trigger.

Step 4: The working payload

Using the Bootstrap documentation to create the wrapper div and the component div, the researcher crafted a new injection string:

Text
https://www.redacted.com/service/?zipCode="><div class=progress><div onwebkitanimationstart=prompt(document.domain) class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100">

The role and aria-* attributes match the documented component markup.

After a few nights of progressive work, identifying the vulnerability, conducting recon to determine what could bypass the filter, and finally leveraging existing libraries to provide the necessary trigger, the researcher demonstrated an impact and escalated a P5 content injection to P3 reflected cross site scripting. The webkit animation is visible in the blue progress bar just below the input box.

Image for post
A successful XSS injection using Bootstrap’s Progress bar. From the original on medium.com

The screenshot shows a successful XSS injection using Bootstrap's Progress bar.

Root cause

The <input> field did not sanitise the reflected zipCode value: neither the double quote that escapes the value attribute nor the > that closes the tag was encoded. The WAF in front of the site blocked the obvious payloads, but its blocklist was incomplete. It allowed several tags, including <div>, and it missed the onwebkitanimationstart event handler. Because inline style was blocked, the usual way of triggering that event was unavailable, but the page already loaded Bootstrap, whose animated striped progress bar provides the animation the event needs. The input was not sanitised, and the filter let through an event that a library already on the page could trigger.

Impact

The crafted zipCode URL runs script in the context of www.redacted.com. The demonstrated payload reads document.domain through prompt(). The report does not describe any further actions, data access or persistence. The escalation from P5 to P3 rests on showing a real security impact rather than on any specific post-exploitation capability.

Fix

The report does not say what the program changed.

Variants to test

  1. Enumerate the filter before choosing a payload. Send individual tags, attributes and events and record which return 403. A positive result is a tag or handler that is reflected unblocked.
  2. Look for animation and transition events that survive. onwebkitanimationstart passed here. Try related handlers and check whether the response reflects them.
  3. Search the page's own libraries for a trigger. If inline style is blocked, look in the Inspector console for existing CSS animations, such as Bootstrap's animated striped progress bar, that a surviving event handler can hook. A positive result is a handler that fires without any injected style.
  4. Check which JavaScript functions are blocked. Here alert() and confirm() were blocked but prompt() was not. A positive result is an unblocked function that can demonstrate execution.
  5. Test attribute-level escapes on other reflected parameters. Try " and > in any parameter reflected into an attribute. A positive result is markup appearing as text or as new elements below the input.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

A security researcher named Greg Gibson was looking at a company's website through a bug bounty programme. A bug bounty programme is an arrangement where a company invites outside people to look for security problems in its systems and report them, often for a reward. This particular programme was private, meaning you had to be invited or accepted to take part, and it had previously only covered the company's mobile apps. Greg had not found anything there, because his strength is finding logic bugs in web applications rather than in mobile apps. A logic bug is a flaw in how a feature is meant to work, rather than a crash or a memory error.

Then the programme added a new item to its scope. Scope is the list of systems you are allowed to test. The new item was the company's main landing page, written as www.redacted.com/*. The * is a wildcard meaning "anything under this address".

Greg did his usual basic reconnaissance. Reconnaissance, or recon, means looking around a target to see what it is made of before attacking anything: what pages exist, what technology they use, what inputs they accept. The landing page turned out to be mostly static, meaning it serves the same content to everyone and does not do much processing on the server. It described the company's various business offerings and redirected visitors to subdomains that were out of scope at the time. A subdomain is a section of a domain, like shop.example.com under example.com.

One feature stood out because it accepted a value in the URL. A URL is the address you type in the browser, and the part after a question mark is the query string, a set of name and value pairs the page receives. A search box on the page took a US Zip Code and redirected to a service page with that value placed into an <input> box.

Greg found that the reflected value was not properly cleaned. He could break out of the HTML attribute it sat in and add his own markup. That is content injection, which the programme rated P5, the lowest priority, worth a single point and no bounty, because on its own it has no real security impact. Rather than submit that and move on, he spent time trying to turn it into something worse. His first obvious attempt, a script tag, was blocked by a web application firewall. A web application firewall, or WAF, is a filter that sits in front of a website and inspects incoming requests, blocking ones that look malicious.

So he mapped the filter: which HTML tags, attributes and events got through and which were blocked. He found that most things were blocked, but a few tags were allowed and one obscure event handler, onwebkitanimationstart, passed. That event fires when a CSS animation starts. Every example he could find of using it needed inline style, which was blocked. So he searched the page's own code for existing animations and found the Bootstrap Progress bar, whose animated striped variant provides exactly the animation the event needs. Combining the allowed tag, the allowed event and the library already on the page, he got script to run in the victim's browser. That is reflected cross site scripting, or XSS, and it escalated the finding from P5 to P3.

Greg Gibson
Greg Gibson From the original on medium.com

The starting point

The work was done against the newly scoped landing page. No special accounts or roles are mentioned. The tools were ordinary: basic recon, a browser, and the browser's Inspector console. The Inspector console is a panel built into browsers, opened with developer tools, where you can inspect the page's HTML and CSS and run JavaScript. The only precondition was that the site accepted a Zip Code and reflected it into the page at www.redacted.com/service/?zipCode=12345.

Finding it

After basic recon on the mostly static site, nothing of interest appeared. Greg then looked specifically for a page with URL parameters, because parameters are where user input enters a page. He found that entering a US Zip Code into one search box redirected to:

Text
www.redacted.com/service/?zipCode=12345

Here zipCode is the parameter name and 12345 is the value. The value was reflected into the <input> box. That reflection is what made the parameter worth testing: if the page puts your text back without cleaning it, you can try to make that text do something.

Exploitation

Step 1: HTML content injection

HTML is the language web pages are written in. It is made of tags like <input>, and tags can carry attributes, which are name and value pairs inside the tag, such as value="12345". The browser reads the tag structure to decide what to display.

The <input> field lacked the most critical sanitisation. Sanitisation means cleaning or encoding user input so it cannot be interpreted as code. An attacker could escape from the value attribute using " and close the tag using >. In plain terms: the page wrote your text inside an attribute, and a double quote ended that attribute early, so anything after it was treated as new markup rather than as text. That is content injection, which Greg rates as a P5: a single point and no bounty payout, because on its own there is no actual security impact. Seeing extra text appear on a page is not the same as running code.

Image for post
The zipCode parameter is vulnerable to content injection and possible further exploit. Shown here are several attributes of the input tag now floating as text just below the input box. From the original on medium.com

The screenshot shows the zipCode parameter vulnerable to content injection, with several attributes of the input tag now floating as text just below the input box. In other words, the markup he typed was being displayed as page content instead of being treated as harmless text.

Rather than submit a P5 and move on, Greg chose to sit on the injection and try to escalate it.

Step 2: The obvious payload is blocked

The first attempt was the straightforward kill shot:

HTML
"><script>alert(1);</script>

Expectations were low for a company of this size and stature, but it was worth trying. The response was a block.

The screenshot shows a 403 block response from a suspected Cloudflare WAF. HTTP status code 403 means "forbidden": the server refused the request. Cloudflare is a company that provides a WAF and other protection in front of websites, and the block page suggested it was in use here.

Step 3: Recon against the filter

The next step was to develop a list of HTML tags, attributes and events that pass the filter, so that an injection string could be crafted that survives it. An event is something that happens in the browser, like a click or an animation starting, and an event handler is an attribute such as onclick that tells the browser what to run when that event happens. The findings:

Element Result
<script>, <style>, <img> blocked
<a>, <svg>, <object>, <div> allowed
<svg src=> blocked
<object data=> blocked
alert() blocked
confirm() blocked
prompt() not blocked
inline style 403
events seemingly all blocked
onwebkitanimationstart passes

The obscure event onwebkitanimationstart got through by chance. It fires when a CSS animation starts in WebKit-based browsers. CSS is the language that styles a page, and an animation is a change over time, such as a bar filling up. Every example Greg found for triggering XSS with that event relied on inline style, meaning a style attribute written directly into the tag, which was blocked. One such example, from Brute Logic, is:

HTML
<style> div{width:100px;height:100px;-webkit-animation-name:n;}@-webkit-keyframes n{}</style><vulntag attrib=""onwebkitanimationstart=alert(9)><div>    <!-- @brutelogic -->

Since style could not be injected, Greg searched the Inspector console for webkit-animation to see whether any existing classes could serve as the trigger. A class is a label on an HTML element that CSS uses to apply styles. That search turned up the Bootstrap Progress bar. Bootstrap is a popular front-end library, a collection of ready-made CSS and JavaScript that many sites load to build their pages. Specifically, the Animated Stripes feature, through the classes class="progress-bar progress-bar-striped progress-bar-animated", would act as the trigger: those classes make a striped bar animate, and the animation fires the event.

Step 4: The working payload

Using the Bootstrap documentation to create the wrapper div and the component div, Greg crafted a new injection string:

Text
https://www.redacted.com/service/?zipCode="><div class=progress><div onwebkitanimationstart=prompt(document.domain) class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100">

After a few nights of progressive work, identifying the vulnerability, conducting recon to determine what could bypass the filter, and finally leveraging existing libraries to provide the necessary trigger, Greg demonstrated an impact and escalated a P5 content injection to P3 reflected cross site scripting. The webkit animation is visible in the blue progress bar just below the input box.

Image for post
A successful XSS injection using Bootstrap’s Progress bar. From the original on medium.com

The screenshot shows a successful XSS injection using Bootstrap's Progress bar.

Root cause

The <input> field did not sanitise the reflected zipCode value: neither the double quote that escapes the value attribute nor the > that closes the tag was encoded. Encoding means converting special characters into harmless equivalents, so a quote becomes text rather than markup. The WAF in front of the site blocked the obvious payloads, but its blocklist was incomplete. A blocklist is a list of things that are forbidden; anything not on the list is allowed. It allowed several tags, including <div>, and it missed the onwebkitanimationstart event handler. Because inline style was blocked, the usual way of triggering that event was unavailable, but the page already loaded Bootstrap, whose animated striped progress bar provides the animation the event needs. The defence therefore failed on two counts: the application did not encode output, and the filter's blocklist did not cover an event that a library already present on the page could trigger.

Impact

An attacker who can get a victim to open a crafted zipCode URL can run script in the context of www.redacted.com. Running script in the site's context means the code executes as if it came from that site. The demonstrated payload reads document.domain through prompt(). The report does not describe any further actions, data access or persistence. The escalation from P5 to P3 rests on showing a real security impact rather than on any specific post-exploitation capability.

Fix

The report does not say what the programme changed.

Variants to test

  1. Enumerate the filter before choosing a payload. Send individual tags, attributes and events and record which return 403. A positive result is a tag or handler that is reflected unblocked.
  2. Look for animation and transition events that survive. onwebkitanimationstart passed here. Try related handlers and check whether the response reflects them.
  3. Search the page's own libraries for a trigger. If inline style is blocked, look in the Inspector console for existing CSS animations, such as Bootstrap's animated striped progress bar, that a surviving event handler can hook. A positive result is a handler that fires without any injected style.
  4. Check which JavaScript functions are blocked. Here alert() and confirm() were blocked but prompt() was not. A positive result is an unblocked function that can demonstrate execution.
  5. Test attribute-level escapes on other reflected parameters. Try " and > in any parameter reflected into an attribute. A positive result is markup appearing as text or as new elements below the input.

Glossary

  • Bug bounty programme: an arrangement where a company invites outside researchers to find and report security problems, often for a reward.
  • Private programme: a bug bounty programme you must be accepted into before you can take part.
  • Scope: the list of systems and addresses a researcher is allowed to test.
  • Logic bug: a flaw in how a feature is meant to work, rather than a crash or memory error.
  • Reconnaissance (recon): looking around a target to learn what pages, technology and inputs it has before testing.
  • Static site: a site that serves the same content to everyone and does little processing on the server.
  • Subdomain: a section of a domain, such as shop.example.com under example.com.
  • URL: the address of a page, including the query string after the question mark.
  • Query string / parameter: the name and value pairs in a URL after the question mark, such as zipCode=12345.
  • HTML: the language web pages are written in, made of tags and attributes.
  • Tag: a markup element such as <input> or <div>.
  • Attribute: a name and value pair inside a tag, such as value="12345".
  • Sanitisation: cleaning or encoding user input so it cannot be interpreted as code.
  • Content injection: getting your own markup into a page without running code; low impact on its own.
  • Web application firewall (WAF): a filter in front of a website that inspects requests and blocks ones that look malicious.
  • Blocklist: a list of forbidden things; anything not on the list is allowed.
  • HTTP status code 403: "forbidden", meaning the server refused the request.
  • Cloudflare: a company that provides a WAF and other protection in front of websites.
  • JavaScript: the programming language browsers run to make pages interactive.
  • alert(), confirm(), prompt(): JavaScript functions that show dialog boxes; prompt() also takes text input.
  • document.domain: a JavaScript property holding the current page's domain name.
  • Event: something that happens in the browser, such as a click or an animation starting.
  • Event handler: an attribute such as onclick or onwebkitanimationstart that tells the browser what to run when an event happens.
  • CSS: the language that styles a page, including animations.
  • Inline style: a style attribute written directly into a tag.
  • Class: a label on an element that CSS uses to apply styles.
  • Bootstrap: a popular front-end library of ready-made CSS and JavaScript used to build pages.
  • Inspector console: a browser developer tool for inspecting the page's HTML and CSS and running JavaScript.
  • Cross site scripting (XSS): a vulnerability where an attacker gets their own script to run in another user's browser in the context of a website.
  • Reflected XSS: XSS where the malicious input is reflected back in the response to a crafted request.
  • P5 / P3: priority ratings; P5 is the lowest, P3 higher, reflecting demonstrated impact.
  • Accessibility attributes (role, aria-*): attributes that describe an element to assistive technology.
  • Encoding: converting special characters into harmless equivalents so they are treated as text, not markup.

More by Greg Gibson

View all

3 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.