Skip to content
XSS Write-up Intermediate

Bug Bounty Guest Post: Local File Read via Stored XSS in The Opera Browser

Renwa Hiwa Follow

Published on blogs.opera.com

Bounty$4,000 View original

In this post, Opera’s Security Team has invited Bug Bounty Hunter Renwa to write about a recent vulnerability that he reported, which was subsequently fixed and a $4,000 USD reward given. What follows is his write-up and experience.

Renwa (@RenwaX23), on blogs.opera.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

Opera runs a bug bounty program on Bugcrowd, and its security team occasionally invites researchers to write up their findings on the company blog. This post is one of those guest write-ups: Renwa (@RenwaX23) describes a stored XSS in Opera's Pinboards feature that he chained into a local file read, for which Opera paid a $4,000 USD reward.

The target is the Opera Browser and, specifically, its Pinboards feature. Pinboards are a note and bookmark saver that can be shared with other users; a pinboard holds text, images and links. The web front end lives at https://pinboard.opera.com/, but when opened inside Opera the browser redirects to opera:pinboards. The opera: scheme is a privileged internal location, comparable to Chrome's chrome:, and pages loaded there have permissions that ordinary web pages do not.

The image shows a pin on the researcher's own Opera Pinboard, the starting point for the whole chain.

Setup

No accounts, roles or special tooling are described beyond a fresh install of the Opera Browser and a web proxy to observe the traffic between the Pinboards UI and its API. The researcher's own pinboard and the ability to add pins to it are the only preconditions. The proxy is what exposed the API endpoint and request shape below.

Finding it

Because Opera is Chromium-based, the researcher downloaded a fresh build and looked at the features Opera had added on top of Chromium. Pinboards stood out as a feature with a server-side API and a privileged client-side view.

Watching the traffic while adding a new link as a pin revealed that the browser parses the URI inside the tag and sends it to the pinboard API before the pin is added to the local copy in opera:pinboards. The request looks like this:

HTTP
POST /v1/items HTTP/2
Host: pinboard.opera-api.com
Content-Type: application/json

{"items":[{"pos":{"x":6,"y":1},"title":{"v":"Hello"},"desc":{"v":"Check my cool website"},"video":false,"link":{"href":"https://renwax23.github.io/X/","title":"it's me"}}]}

The request body carries the link that will become the clickable pin. The reasoning was straightforward: if a pin could be created whose href is a javascript: URI, the code would run from inside the privileged opera: scheme, which is XSS with far more reach than a normal origin.

Exploitation

Step 1: get a javascript URI accepted as a pin

After many tests, the researcher found that pinning the URI javascript:@opera.com was possible, and it appeared in the pinboard as a clickable link. That alone did not run code: the value appeared in the pinboard as a clickable link.

Step 2: make the payload actually execute

After further attempts the working payload was: After further attempts the working payload was:

Text
javascript:'@opera.com/';alert(1)

Clicking it inside the pinboard produced a popup.

There was one obstacle: the tag in the pinboard interface used the attribute target=_blank, so a normal click opened the link in a new window instead of executing the JavaScript in the page. The workaround is to Command (Ctrl) + Click or Middle-Click the link, which runs the code successfully.

Step 3: turn the popup into something worth reporting

A popup on click is a weak impact, so the researcher looked at what the opera: scheme grants. Compared with a normal web page it has access to some native function calls, can view other tabs (bypassing the same-origin policy), and can load the file: scheme to view local files. Not every native function was available: the ones that would give complete control over other tabs, such as injecting JavaScript that copies a page's contents to an attacker server, were not permitted.

The chain that was possible:

  1. Create a new tab with the native function chrome.tabs.create, opening file:///etc/passwd.
  2. Screenshot the opened tab with opr.pinboardPrivate.getThumbnail, the same function Pinboards uses to generate thumbnails for pins.
  3. Send the screenshot, as a base64-encoded PNG, to the researcher's server.

Step 4: deliver it as a stored pin

The researcher created a new pinboard that imported the script performing these steps, and added a pin which, when clicked, sent back a screenshot of the stolen /etc/passwd file. Video proof of concept was submitted through Opera's Bugcrowd page.

Root cause

Pinning a javascript: URI was possible, and it appeared in the pinboard as a clickable link in the privileged opera:pinboards page. Because the rendering page runs under the opera: scheme, the resulting script executes with permissions a normal origin would never have: native function calls, cross-tab visibility that bypasses the same-origin policy, and the ability to load file: URLs. The target=_blank attribute on the link is a usability detail rather than a defence, and it is defeated by Ctrl+Click or middle-click. The report does not describe any server-side or client-side validation that was meant to catch this, so the exact missing check is not stated.

Impact

A pin holding a javascript: URI, clicked with Ctrl+Click or middle-click, runs JavaScript in the privileged opera: context. From there the script can open local files via file: and capture a screenshot of the resulting tab through opr.pinboardPrivate.getThumbnail, then exfiltrate it as a base64 PNG. The researcher demonstrated this against /etc/passwd. The report notes that the most powerful native functions, which would have allowed full control of other tabs, were not available, so the demonstrated impact is limited to what the permitted functions allow: reading local files through screenshots and viewing other tabs. The attack requires user interaction on the click.

Fix

Opera fixed the bug within one day of the report, and the reward was paid about one month later. The report does not describe the specific change that was made.

Variants to test

  • Other privileged schemes. Try the same stored-link trick against any internal page that renders user-supplied URLs, such as browser-internal bookmark or note features. A positive result is a stored javascript: value that executes when the link is activated in the privileged context.
  • Scheme filtering bypasses. Where a scheme allowlist exists, try case variation, whitespace or control characters inside the scheme, and values that only become javascript: after normalisation. A positive result is a stored value that the renderer treats as script.
  • Click-target attributes. Look for links rendered with target=_blank or similar; test Ctrl+Click and middle-click, which may execute where a plain click does not.
  • Thumbnail and screenshot APIs. Enumerate privileged functions that render or capture page content, such as thumbnail generators, and check whether they can be pointed at file: or other sensitive URLs. A positive result is a captured image of content the page should not be able to read.
  • Cross-tab access from privileged pages. Check whether a script running in an internal scheme can enumerate or read other tabs. A positive result is reading another tab's content without same-origin permission.
From the original on blogs.opera.com

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

Opera is a web browser, a program you use to visit websites. Like many software companies, Opera runs a bug bounty program: a scheme where outside people who find security mistakes in the company's software can report them and get paid. Opera's program is hosted on a platform called Bugcrowd. When a report is especially good, Opera's security team invites the researcher to write about it on the company blog. This article is one of those guest posts, written by a researcher called Renwa (@RenwaX23).

What Renwa found was a way for a pin in the privileged opera:pinboards page to make the browser take a picture of a local file and send it to his server. The file he used to prove it was /etc/passwd. Opera paid a $4,000 USD reward for the report.

The feature involved is called Pinboards. A pinboard is a place to save notes, images and links, a bit like a shared noticeboard or a collection of bookmarks you can show to other people. The website part of Pinboards lives at https://pinboard.opera.com/, but when you open that address inside the Opera browser, Opera sends you instead to opera:pinboards. The opera: prefix is a special internal address, similar to chrome: in Google Chrome. Pages that live at these internal addresses are not ordinary websites: the browser gives them extra powers that a normal website never gets. That difference in power is the heart of the whole story.

The image shows a pin on the researcher's own Opera Pinboard, which is where the whole chain of steps begins.

Setting the scene

The report does not describe any special accounts, roles or tools beyond two things: a fresh installation of the Opera Browser, and a web proxy. A proxy is a program that sits between your browser and the internet and lets you watch, and sometimes change, every request and response that passes through. Think of it as standing between two people talking and writing down everything they say. The proxy is what let Renwa see the exact request the Pinboards page sends when you add a pin. The only other precondition is having your own pinboard and being able to add pins to it, which any user of the feature can do.

How the problem was found

Opera is built on top of Chromium, the open-source engine that also powers Google Chrome. Because the underlying engine is the same, the interesting part for a security researcher is what Opera has added on top. So Renwa downloaded a fresh copy of Opera and looked through the features Opera had built itself. Pinboards stood out because it has two halves: a part that runs on Opera's servers (the API, explained below) and a part that runs inside the browser at a privileged address.

While adding a new link as a pin, with the proxy watching, Renwa saw that the browser reads the address inside the tag and sends it to the pinboard API before the pin is added to the local copy shown at opera:pinboards. The request looked like this:

HTTP
POST /v1/items HTTP/2
Host: pinboard.opera-api.com
Content-Type: application/json

{"items":[{"pos":{"x":6,"y":1},"title":{"v":"Hello"},"desc":{"v":"Check my cool website"},"video":false,"link":{"href":"https://renwax23.github.io/X/","title":"it's me"}}]}

Line by line, in plain words:

  • POST /v1/items HTTP/2 is the first line of an HTTP request. HTTP is the language browsers and servers use to talk. POST means "I am sending you data to create something". /v1/items is the address on the server of the thing being created, here an item, meaning a pin. HTTP/2 is the version of the language being used.
  • Host: pinboard.opera-api.com says which server the request is for. An API (application programming interface) is a server built to be talked to by a program rather than by a person clicking around; it accepts structured requests and answers with structured data. This host is the Pinboards API.
  • Content-Type: application/json tells the server what format the body is in. JSON is a simple text format for structured data, using curly braces, names in quotes, and values. It is the same idea as a labelled form: each field has a name and a value.
  • The blank line separates the headers (the labels above) from the body (the actual data).
  • The body is one JSON object. items is a list containing one item. Inside that item, pos gives the pin's position on the board (x and y coordinates), title and desc hold the pin's title and description, video is a true/false flag, and link holds the link itself. The important part is link.href, which carries the address that will become the clickable pin. In this example it is https://renwax23.github.io/X/, an ordinary web address.

The reasoning from there was simple. If a pin could be created whose href is not an ordinary web address but a javascript: address, then the code inside it would run from inside the privileged opera: page. That is cross-site scripting, usually shortened to XSS: a class of bug where an attacker gets their own code to run inside a page or context it was never meant to run in. Running code inside a privileged internal page is far more dangerous than running it on an ordinary website, because of the extra powers described earlier.

Carrying out the attack

Step 1: get a javascript address accepted as a pin

A javascript: address is a special kind of link. Instead of pointing at a page, it contains code, and when the link is activated the browser runs that code. After many tests, Renwa found that pinning the address javascript:@opera.com was possible, and it appeared in the pinboard as a clickable link. That on its own did not run code: the value appeared in the pinboard as a clickable link. "Stored" means the malicious value is kept and shown again later, rather than being used once and forgotten.

Step 2: make the payload actually run

After further attempts, the working payload was: After further attempts, the working payload was:

Text
javascript:'@opera.com/';alert(1)

Clicking it inside the pinboard produced a popup. Then alert(1) is a built-in browser command that shows a small popup box with the number 1 in it. Seeing that popup is proof that the code ran, because only running code can call alert.

There was one obstacle. The link in the pinboard interface carried the attribute target=_blank. An attribute is an extra setting written on an HTML element; target=_blank tells the browser to open the link in a new window. So a normal click opened the link in a new window instead of running the JavaScript in the page. The workaround is to Command (Ctrl) + Click or Middle-Click the link, which runs the code successfully. In other words, the setting that was meant to control where links open turned out not to be a defence at all, just a detail that a different kind of click gets around.

Step 3: turn the popup into something worth reporting

A popup that appears when someone clicks a link is a weak result. Anyone can make a popup; it does not show that anything private can be reached. So Renwa looked at what the opera: address actually grants compared with a normal web page. It has access to some native function calls, meaning built-in browser commands that ordinary pages cannot call. It can view other tabs, which gets around the same-origin policy: the browser rule that one website may not read another website's content. And it can load the file: address scheme, which points at files on the local computer rather than on the internet. Not every native function was available, though: the ones that would give complete control over other tabs, such as injecting JavaScript that copies a whole page's contents and sends it to an attacker's server, were not permitted.

The chain that was possible:

  1. Create a new tab with the native function chrome.tabs.create, opening file:///etc/passwd. chrome.tabs.create is a built-in command that opens a browser tab. file:///etc/passwd is an address that points at a file on the computer itself, here the standard user-account file on Linux and macOS.
  2. Take a screenshot of the opened tab with opr.pinboardPrivate.getThumbnail, the same function Pinboards uses to generate thumbnails for pins. A thumbnail is the small preview picture of a page. The point is that the browser already has a built-in way to turn a page into an image, and that way could be pointed at a local file.
  3. Send the screenshot, as a base64-encoded PNG, to the researcher's server. PNG is an image file format. Base64 is a way of writing binary data, such as an image, as plain text so it can be sent inside a normal request. Sending it to his own server meant Renwa could open the picture and see the file's contents.

Step 4: deliver it as a stored pin

Renwa created a new pinboard that imported the script performing these steps, and added a pin which, when clicked, sent back a screenshot of the stolen /etc/passwd file. In other words, the whole attack was packaged as a pinboard that could be shared, and the trigger was a click on a pin. Video proof of concept was submitted through Opera's Bugcrowd page. A proof of concept is a working demonstration that the bug is real, rather than a theoretical claim.

Why it worked

Pinning a javascript: address was possible, and it appeared in the pinboard as a clickable link in the privileged opera:pinboards page. Because the page showing the link runs under the opera: address, the script that runs when the link is activated gets permissions an ordinary website would never have: native function calls, the ability to see other tabs in spite of the same-origin policy, and the ability to load file: addresses. The target=_blank attribute is a usability setting, not a security control, and Ctrl+Click or middle-click defeats it.

What the impact was

A pin holding a javascript: address, clicked with Ctrl+Click or middle-click, runs JavaScript in the privileged opera: context. From there the script can open local files through file: and capture a screenshot of the resulting tab with opr.pinboardPrivate.getThumbnail, then send it out as a base64 PNG. Renwa demonstrated this against /etc/passwd. The report notes that the most powerful native functions, the ones that would have allowed full control of other tabs, were not available, so the demonstrated impact is limited to what the permitted functions allow: reading local files through screenshots and viewing other tabs. The attack also needs the user to click.

The fix

Opera fixed the bug within one day of the report, and the reward was paid about one month later.

From the original on blogs.opera.com

Related things worth testing

These are the kinds of follow-up checks a researcher would try after finding something like this. They are written as things to look for, not as instructions to attack anyone.

  • Other privileged addresses. Try the same stored-link trick against any internal page that shows addresses supplied by users, such as a browser's built-in bookmark or note features. A positive result is a stored javascript: value that runs when the link is activated in the privileged context.
  • Getting around address filtering. Where a list of allowed address types exists, try changing the case of letters, adding spaces or control characters inside the scheme name, and values that only become javascript: after the browser tidies them up. A positive result is a stored value that the page treats as code.
  • Link settings. Look for links shown with target=_blank or similar settings, and test Ctrl+Click and middle-click, which may run code where a plain click does not.
  • Thumbnail and screenshot functions. List the privileged functions that draw or capture page content, such as thumbnail generators, and check whether they can be pointed at file: or other sensitive addresses. A positive result is a captured image of content the page should not be able to read.
  • Seeing other tabs from privileged pages. Check whether a script running at an internal address can list or read other tabs. A positive result is reading another tab's content without same-origin permission.

Glossary

  • API: a server built to be talked to by a program rather than a person, accepting structured requests and returning structured data.
  • Attribute: an extra setting written on an HTML element, such as target=_blank.
  • Base64: a way of writing binary data, such as an image, as plain text so it can travel inside a normal request.
  • Bug bounty program: a scheme where outside researchers report security mistakes and are paid for valid reports.
  • Chromium: the open-source browser engine that Opera and Google Chrome are built on.
  • Cross-site scripting (XSS): a bug class where an attacker gets their own code to run inside a page or context it was never meant to run in.
  • file: scheme: an address type that points at files on the local computer rather than on the internet.
  • HTTP: the language browsers and servers use to exchange requests and responses.
  • JSON: a simple text format for structured data, using curly braces, quoted names and values.
  • Native function call: a built-in browser command that ordinary web pages are not allowed to call.
  • opera: scheme: a privileged internal address in Opera, comparable to chrome: in Chrome, whose pages have powers ordinary websites do not.
  • Payload: the piece of code or value an attacker uses to trigger a bug.
  • PNG: an image file format.
  • Proof of concept: a working demonstration that a bug is real, rather than a theoretical claim.
  • Same-origin policy (SOP): the browser rule that one website may not read another website's content.
  • Stored XSS: XSS where the malicious value is saved on the server and shown again later, rather than used once.
  • target=_blank: an HTML attribute that tells the browser to open a link in a new window.
  • Thumbnail: a small preview picture of a page.
  • Web proxy: a program that sits between your browser and the internet and lets you watch, and sometimes change, the traffic that passes through.

More by Renwa Hiwa

View all

10 more disclosed reports, best first.

More from Opera

View all

The newest disclosed reports for this program.

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.