Skip to content
UI spoofing Write-up Intermediate

binary.com clickjacking vulnerability exploiting HTML5 security features

A subdomain of a trading site lacked clickjacking protection, allowing an attacker to frame the service and trick users into unwanted actions. After the team added a JavaScript frame-busting fix, the researcher bypassed it using a sandboxed iframe that allowed scripts and forms while preventing top-level navigation.

Ameer Assadi Follow

Published on medium.com

Modern Web Applications nowadays are relaying on a lot of technologies where typical web applications vulnerabilities are hard to find (eg. Clickjacking is an ABC security bug) but bug hunters are always the best!

Ameer Assadi, 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. 6 min read.

Context

Binary.com is one of the oldest and most respected names in online binary trading. Customers use it to trade currencies, indices, stocks and commodities 24/7. The service is owned and operated by the Binary Ltd. group of companies: in the UK and Isle of Man clients trade through Binary (IOM) Ltd, in the European Union (except the UK) through Binary (Europe) Ltd and Binary Investments (Europe) Ltd, and in the rest of the world through Binary (C.R.) S.A.

The target of this research was not the main site but a subdomain, ticktrade.binary.com. The report does not describe what the ticktrade application does beyond being part of the Binary.com service; the relevant point is that it is a full web application served on its own hostname.

Setup

The researcher was doing pentesting and bug hunting and, as a matter of habit, tested subdomains rather than only the main site. No accounts, roles, tools or versions are described in the report.

Finding it

While testing ticktrade.binary.com, the researcher found that the subdomain was not protected against clickjacking. Neither of the two usual defences was present:

  • the X-Frame-Options response header, and
  • the JavaScript frame busting technique.

Without either, a malicious attacker is capable of iframing the whole service and tricking end users into performing unwanted actions. The researcher describes clickjacking itself as an ABC security bug, meaning a well-known and basic class of issue, but notes that bug hunters still find it because modern web applications rely on many technologies.

Exploitation

Step 1: prove the framing

The vulnerability was reported to Binary.com with this proof of concept:

HTML
<html><body><iframe src="https://ticktrade.binary.com/" width=600 height=400><p>Your browser does not support iframes.</p></iframe></body></html>

The page embeds https://ticktrade.binary.com/ in a 600 by 400 iframe. The paragraph inside the iframe element is fallback content shown only by browsers that do not support iframes. Because the target sent no X-Frame-Options and ran no frame busting script, the application rendered inside the attacker's frame.

The security team replied the same day, and two days later he received a reply that the issue had been fixed.

From the original on medium.com

Step 2: work out how it was fixed

The researcher likes to bypass resolved issues, so the next step was to look at how the security team had patched the vulnerability: either by adding X-Frame-Options or by using the JavaScript frame busting technique. The answer was that the team used JavaScript frame busting.

Step 3: bypass the patch with a sandboxed iframe

The bypass exploits an HTML5 security feature: sandboxed iframes. The sandbox attribute enables an extra set of restrictions for the content in the iframe. When the sandbox attribute is present, it will:

  • treat the content as being from a unique origin
  • block form submission
  • block script execution
  • disable APIs
  • prevent links from targeting other browsing contexts
  • prevent content from using plugins through <embed>, <object>, <applet>, or other means
  • prevent the content from navigating its top-level browsing context
  • block automatically triggered features (such as automatically playing a video or automatically focusing a form control)

Those restrictions are the default. The attribute accepts a list of tokens that selectively lift them, and that is what the bypass uses. The final bypassing proof of concept is:

HTML
<html><body><iframe sandbox="allow-modals allow-scripts allow-forms allow-popups allow-same-origin"src="http://ticktrade.binary.com" width=600 height=400><p>Bypassed By @AmeerAssadi.</p></iframe></body></html>

The sandbox attribute carries five tokens:

Token Effect
allow-modals lets the framed content open modal dialogs
allow-scripts lets the framed content run scripts
allow-forms lets the framed content submit forms
allow-popups lets the framed content open popups
allow-same-origin keeps the content in its real origin instead of a unique one

That last restriction is the key to the bypass: the frame busting script tries to break out of the frame by changing the top window, and the sandbox stops it. The application therefore stays framed, and the attacker can still rely on scripts and forms working inside the frame.

The attack scenario the researcher describes is iframing the Settings page, or any other sensitive page, with a sandboxed iframe: the sandbox prevents the redirect to the top window and allows scripts to keep running, so the user can be fooled into performing unwanted actions.

Root cause

The original defect is the absence of any anti-framing control on ticktrade.binary.com: no X-Frame-Options header and no frame busting script, so the whole application could be embedded in an attacker's page.

The patch addressed this with JavaScript frame busting only. Frame busting is enforced by code running inside the framed document, and the framing page controls the sandbox in which that document runs. By adding allow-scripts and allow-same-origin while withholding the ability to navigate the top-level browsing context, the attacker lets the application's scripts run but denies them the one action the frame busting check depends on. The report does not show the frame busting code itself, so the exact check it performs is not stated; the mechanism above is what the sandbox tokens imply.

Impact

An attacker can frame the Binary.com ticktrade application and trick users into performing unwanted actions. The researcher's scenario is framing the Settings page or any other sensitive page and fooling users into unwanted actions.

The report does not enumerate which specific actions could be triggered or what the consequences of each would be.

Fix

The report describes the sequence rather than the final implementation. The first fix, JavaScript frame busting, was bypassed as shown above. The researcher sent the patch bypass on Wednesday, 25th May 2016, and the issue was patched on Wednesday, 8th June 2016.

For a durable fix, the control has to be enforced by the browser rather than by script inside the framed page: an X-Frame-Options header (for example DENY or SAMEORIGIN) or a Content-Security-Policy with a frame-ancestors directive. Frame busting alone remains bypassable by a sandboxed iframe that grants allow-scripts and allow-same-origin but not top-level navigation.

Timeline

Date Event
Monday, 23rd May 2016 Issue reported
Monday, 23rd May 2016 Issue confirmed and triaged
Wednesday, 25th May 2016 Issue resolved and team asks the researcher to verify the fix
Wednesday, 25th May 2016 Patch bypass sent
Wednesday, 8th June 2016 Issue patched

Binary's security team rewarded the researcher with a bounty and added the name to the Hall of Fame page.

From the original on medium.com

Variants to test

  1. Frame busting without X-Frame-Options. Load any sensitive page in a plain iframe. A positive result is the page rendering inside the frame instead of the browser refusing to display it.
  2. Sandboxed iframe against frame busting. If the plain iframe is blocked by a script, retry with sandbox="allow-modals allow-scripts allow-forms allow-popups allow-same-origin". A positive result is the page staying framed and its scripts still running, with no top-level navigation.
  3. Partial token sets. Try the sandbox with only allow-scripts allow-same-origin, and with allow-scripts allow-forms allow-same-origin, to see which combination the application needs. A positive result is the page rendering and remaining interactive with fewer tokens.
  4. Sensitive pages specifically. Apply the same framing test to settings, profile, payment and trading pages rather than only the landing page. A positive result is any page whose controls can be framed and clicked.
  5. Header check. Inspect the response headers of each subdomain for X-Frame-Options and Content-Security-Policy with frame-ancestors. A positive result is a subdomain serving neither, which makes it a candidate for the tests above.

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. 14 min read.

What happened, in plain words

A security researcher found that a part of the Binary.com website could be secretly embedded inside another website. That trick is called clickjacking. He reported it, the company fixed it, and then he found a way around the fix. The company then patched it and paid him a reward.

This article walks through the whole story from the beginning, assuming you have never done security testing before. You only need to know how to use a browser. Every technical word is explained the first time it appears, and there is a glossary at the end.

The target: Binary.com and its subdomain

Binary.com is one of the oldest and most respected names in online binary trading. Customers use it to trade currencies, indices, stocks and commodities, 24 hours a day, seven days a week. The service is owned and operated by the Binary Ltd. group of companies. In the UK and Isle of Man, clients trade through Binary (IOM) Ltd. In the European Union, except the UK, they trade through Binary (Europe) Ltd and Binary Investments (Europe) Ltd. In the rest of the world, they trade through Binary (C.R.) S.A.

The researcher did not test the main site. He tested a subdomain, ticktrade.binary.com. A subdomain is a smaller site that belongs to the same company but lives at its own address, like a separate department inside the same building. The report does not describe what the ticktrade application does beyond being part of the Binary.com service. What matters here is that it is a full web application served on its own hostname.

The idea behind the bug: clickjacking

Before the steps, you need to understand the attack itself.

A web page can contain another web page inside a rectangular window. That window is called an iframe (short for inline frame). It is like a picture frame hanging on a wall: the wall is the attacker's page, and the picture inside the frame is somebody else's site. The browser draws the framed site exactly as if you had opened it directly.

Clickjacking abuses this. An attacker builds a page with the victim site inside an invisible or disguised iframe, and places fake buttons on top of it, or simply positions the frame so that the real buttons sit where the user expects something harmless. The user thinks they are clicking one thing, but the click lands on the real site underneath. The everyday comparison: someone puts a transparent sheet with a fake "Close" button over a real cash machine screen, and your finger presses the real "Withdraw" button below it.

Because the framed site is the genuine one, the user's browser sends the user's own session along with every click. A session is the state of being logged in: after you sign in, the site gives your browser a small piece of data (often called a cookie) so it can recognise you on the next request. The attacker never sees that cookie; the browser attaches it automatically because the request goes to the real site. That is why clickjacking is dangerous: the attacker does not need your password, only your click.

Sites defend against this in two common ways:

  1. The X-Frame-Options response header. A response header is a short line of information the server sends back with the page, before the page content. X-Frame-Options tells the browser whether the page is allowed to be shown inside a frame at all. If the server says no, the browser refuses to draw it in the frame.
  2. JavaScript frame busting. JavaScript is the programming language that runs inside web pages and makes them interactive. A frame busting script is a small piece of JavaScript placed in the page that checks, when the page loads, whether it is inside a frame. If it is, the script tries to break out, typically by telling the browser to load the page in the top window instead. The top window is the outermost browser window, the one the user actually sees, as opposed to the little frame inside it.

Both defences are enforced differently. The header is enforced by the browser itself, before any page code runs. Frame busting is enforced by code inside the framed page, which means the page that does the framing may be able to interfere with it. Keep that difference in mind; it is the whole story.

Finding it

The researcher was doing pentesting and bug hunting. Pentesting (penetration testing) means deliberately attacking a system you have permission to test, to find its weaknesses before criminals do. Bug hunting is the same idea, often run as a public programme where companies invite researchers to report flaws, sometimes for a reward called a bounty. As a habit, he tested subdomains rather than only the main site, because companies often protect the front door and forget the side doors.

While testing ticktrade.binary.com, he found that the subdomain was not protected against clickjacking. Neither of the two usual defences was present:

  • the X-Frame-Options response header, and
  • the JavaScript frame busting technique.

Without either one, an attacker can iframe the whole service and trick end users into performing unwanted actions. The researcher calls clickjacking an ABC security bug, meaning a well-known and basic class of issue. He still finds it worth testing because modern web applications rely on many technologies, and basic bugs survive in the gaps between them.

The report does not mention any accounts, roles, tools or software versions.

Step 1: prove the framing

The vulnerability was reported to Binary.com with this proof of concept. A proof of concept (PoC) is a small, harmless demonstration that the bug is real, so the company can reproduce it.

HTML
<html><body><iframe src="https://ticktrade.binary.com/" width=600 height=400><p>Your browser does not support iframes.</p></iframe></body></html>

Line by line:

  • <html><body> opens a minimal web page. Every page has a body, the part the browser displays.
  • <iframe src="https://ticktrade.binary.com/" width=600 height=400> creates the frame. src is the address of the page to load inside it, here the ticktrade site over HTTPS, the encrypted version of the web. width=600 height=400 sets the frame to 600 pixels wide and 400 pixels tall.
  • <p>Your browser does not support iframes.</p> is fallback text. It is shown only by very old browsers that cannot display frames at all. Modern browsers ignore it.
  • </iframe></body></html> closes the frame, the body and the page.

Why this step: it is the smallest possible test. If the target page appears inside the 600 by 400 box, the site has no anti-framing defence. Because the target sent no X-Frame-Options and ran no frame busting script, the application rendered inside the attacker's frame.

The security team replied the same day, and two days later he received a reply that the issue had been fixed.

From the original on medium.com

Step 2: work out how it was fixed

The researcher likes to bypass resolved issues, so the next step was to look at how the security team had patched the vulnerability. There were two possibilities: adding X-Frame-Options, or using the JavaScript frame busting technique. The answer was that the team used JavaScript frame busting.

Why this matters: frame busting is a check performed by code running inside the framed page. The page that does the framing decides how that framed page is allowed to run. If the attacker can change those conditions, the check can be defeated. A header, by contrast, is enforced by the browser before the page code gets a say, which is why it is the stronger defence.

Step 3: bypass the patch with a sandboxed iframe

The bypass exploits an HTML5 security feature: sandboxed iframes. HTML5 is the current version of the language web pages are written in. A sandbox is a set of restrictions applied to something so it cannot do harm, like putting a child in a playpen: they can still play, but only inside the fence.

The sandbox attribute enables an extra set of restrictions for the content in the iframe. When the sandbox attribute is present, it will:

  • treat the content as being from a unique origin
  • block form submission
  • block script execution
  • disable APIs
  • prevent links from targeting other browsing contexts
  • prevent content from using plugins through <embed>, <object>, <applet>, or other means
  • prevent the content from navigating its top-level browsing context
  • block automatically triggered features (such as automatically playing a video or automatically focusing a form control)

A few of those terms need unpacking:

  • Origin means the combination of protocol, hostname and port that identifies where content came from, for example https://ticktrade.binary.com. Browsers use it to decide whether two pieces of content are allowed to talk to each other. Treating content as a unique origin means giving it a made-up identity that matches nothing else, so it is isolated.
  • API (application programming interface) here means the built-in abilities the browser offers to page code, such as storing data locally or asking for the user's location. Disabling APIs takes those abilities away.
  • Browsing context is a window or frame that displays a page. Targeting another browsing context means making a link open in a different window or frame.
  • Plugins are add-on programs such as old-style embedded media players, loaded through tags like <embed>, <object> and <applet>.
  • Navigating the top-level browsing context means making the outermost window load a different address. This is exactly the action frame busting relies on: the script tries to make the top window leave the attacker's page.

Those restrictions are the default. The attribute accepts a list of tokens that selectively lift them, and that is what the bypass uses. A token here is just a keyword in the attribute's value that switches one restriction off. The final bypassing proof of concept is:

HTML
<html><body><iframe sandbox="allow-modals allow-scripts allow-forms allow-popups allow-same-origin"src="http://ticktrade.binary.com" width=600 height=400><p>Bypassed By @AmeerAssadi.</p></iframe></body></html>

Line by line:

  • <html><body> opens the attacker's page, as before.
  • <iframe sandbox="..." creates a frame with the sandbox switched on, then lists the restrictions to lift.
  • src="http://ticktrade.binary.com" loads the ticktrade site inside the frame. Note this PoC uses plain http:// rather than https://.
  • width=600 height=400 keeps the same frame size as the first test.
  • <p>Bypassed By @AmeerAssadi.</p> is fallback text for browsers without frame support, this time crediting the researcher.
  • </iframe></body></html> closes everything.

The sandbox attribute carries five tokens:

Token Effect
allow-modals lets the framed content open modal dialogs
allow-scripts lets the framed content run scripts
allow-forms lets the framed content submit forms
allow-popups lets the framed content open popups
allow-same-origin keeps the content in its real origin instead of a unique one

A modal dialog is a small box that appears over the page and demands an answer before you can continue, such as an "Are you sure?" prompt. A form is the part of a page where you type information and press a submit button, for example a login box or a settings form. A popup is a new window opened by the page.

That last restriction is the key to the bypass. The frame busting script tries to break out of the frame by changing the top window, and the sandbox stops it. The application therefore stays framed, and the attacker can still rely on scripts and forms working inside the frame.

The attack scenario the researcher describes is iframing the Settings page, or any other sensitive page, with a sandboxed iframe. The sandbox prevents the redirect to the top window and allows scripts to keep running, so the user can be fooled into performing unwanted actions.

Why the fix failed

The original defect was the absence of any anti-framing control on ticktrade.binary.com: no X-Frame-Options header and no frame busting script, so the whole application could be embedded in an attacker's page.

The patch addressed this with JavaScript frame busting only. Frame busting is enforced by code running inside the framed document, and the framing page controls the sandbox in which that document runs. By adding allow-scripts and allow-same-origin while withholding the ability to navigate the top-level browsing context, the attacker lets the application's scripts run but denies them the one action the frame busting check depends on.

What an attacker could do with it

An attacker can frame the Binary.com ticktrade application and trick users into performing unwanted actions. The researcher's scenario is framing the Settings page or any other sensitive page and fooling users into unwanted actions.

The report does not enumerate which specific actions could be triggered or what the consequences of each would be.

How it was finally fixed

The report describes the sequence rather than the final implementation. The first fix, JavaScript frame busting, was bypassed as shown above. The researcher sent the patch bypass on Wednesday, 25th May 2016, and the issue was patched on Wednesday, 8th June 2016.

For a durable fix, the control has to be enforced by the browser rather than by script inside the framed page: an X-Frame-Options header, for example DENY or SAMEORIGIN, or a Content-Security-Policy with a frame-ancestors directive. Content-Security-Policy is another response header in which a site lists rules the browser must enforce, and frame-ancestors is the rule that says which pages may frame it. Frame busting alone remains bypassable by a sandboxed iframe that grants allow-scripts and allow-same-origin but not top-level navigation.

Timeline

Date Event
Monday, 23rd May 2016 Issue reported
Monday, 23rd May 2016 Issue confirmed and triaged
Wednesday, 25th May 2016 Issue resolved and team asks the researcher to verify the fix
Wednesday, 25th May 2016 Patch bypass sent
Wednesday, 8th June 2016 Issue patched

Triaged means the company has reviewed the report, accepted that it is a real issue and put it in the queue to be fixed. Binary's security team rewarded the researcher with a bounty and added the name to the Hall of Fame page.

From the original on medium.com

Variants to test

If you want to try this kind of testing yourself, these are the variations worth trying. Only test sites you own or that explicitly invite testing through a bug bounty programme.

  1. Frame busting without X-Frame-Options. Load any sensitive page in a plain iframe. A positive result is the page rendering inside the frame instead of the browser refusing to display it.
  2. Sandboxed iframe against frame busting. If the plain iframe is blocked by a script, retry with sandbox="allow-modals allow-scripts allow-forms allow-popups allow-same-origin". A positive result is the page staying framed and its scripts still running, with no top-level navigation.
  3. Partial token sets. Try the sandbox with only allow-scripts allow-same-origin, and with allow-scripts allow-forms allow-same-origin, to see which combination the application needs. A positive result is the page rendering and remaining interactive with fewer tokens.
  4. Sensitive pages specifically. Apply the same framing test to settings, profile, payment and trading pages rather than only the landing page. A positive result is any page whose controls can be framed and clicked.
  5. Header check. Inspect the response headers of each subdomain for X-Frame-Options and Content-Security-Policy with frame-ancestors. A positive result is a subdomain serving neither, which makes it a candidate for the tests above. You can see response headers in your browser's developer tools, under the Network tab, by clicking a request and looking at its headers.

Glossary

  • API: the built-in abilities a browser offers to page code, such as local storage or location access; in a sandbox these can be disabled.
  • Bounty: a reward, usually money, paid by a company to a researcher who reports a valid security flaw.
  • Browsing context: a window or frame that displays a web page.
  • Bug hunting: searching for security flaws in software, often under a company's public programme.
  • Clickjacking: tricking a user into clicking controls on a real site that has been hidden inside an attacker's page.
  • Content-Security-Policy: a response header in which a site gives the browser rules to enforce, including which pages may frame it via frame-ancestors.
  • Cookie: a small piece of data a site stores in your browser so it can recognise you, for example to keep you logged in.
  • Fallback content: text inside an element that a browser shows only if it cannot display that element.
  • Form: the part of a page where you type information and submit it.
  • Frame busting: a JavaScript technique that tries to break a page out of an iframe by loading it in the top window.
  • HTML5: the current version of the language web pages are written in.
  • HTTPS: the encrypted version of the web, shown by a padlock in the address bar.
  • Iframe: a rectangular window inside a page that displays another page.
  • JavaScript: the programming language that runs inside web pages and makes them interactive.
  • Modal dialog: a box that appears over a page and requires an answer before you can continue.
  • Origin: the combination of protocol, hostname and port that identifies where content came from.
  • Pentesting: deliberately attacking a system you have permission to test, to find weaknesses before criminals do.
  • Plugin: an add-on program embedded in a page, such as an old-style media player.
  • Popup: a new window opened by a page.
  • Proof of concept (PoC): a small demonstration that a bug is real and reproducible.
  • Response header: a short line of information a server sends with a page, before the page content.
  • Sandbox: a set of restrictions applied to framed content so it cannot do harm.
  • Session: the state of being logged in, maintained by data such as a cookie.
  • Subdomain: a smaller site belonging to the same company, at its own address.
  • Token: here, a keyword in the sandbox attribute that lifts one restriction.
  • Top window: the outermost browser window the user sees, as opposed to a frame inside it.
  • Triaged: reviewed and accepted as a real issue, and queued for fixing.
  • X-Frame-Options: a response header that tells the browser whether a page may be shown inside a frame.

Similar reports

View all

Same bug class and techniques, clearest first.

Clickjacking and UI spoofing

The lesson behind this report.

The interface lies to the user: a framed page catches their clicks, or a browser shows the wrong address or a fake prompt. Paid when it leads to a sensitive action or convincing phishing.