Skip to content
CSRF Write-up Intermediate

Stealing Google Drive OAuth tokens from Dropbox

A CSRF vulnerability in HelloSign's external file attachment endpoint allowed an attacker to make a logged-in user's browser send a request that included the user's Google Drive OAuth token to an attacker-controlled server. The token could then be stolen from the server logs.

Sivanesh Ashok Follow

Published on blog.stazot.com

Bounty$1,728 View original

Sreeram KL and I were able to chain a harmless CSRF and SSRF in HelloSign to leak Google Drive OAuth tokens of Dropbox users. We reported the issue to Dropbox.

Sivanesh Ashok (@sivaneshashok), Sreeram KL (@kl_sree), on blog.stazot.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

HelloSign is a Dropbox product for signing and sending documents. One of its features lets a user attach a file that lives in their own Google Drive: the user signs into HelloSign, picks a Drive file, and HelloSign fetches it from Google's API on the user's behalf using the user's Google Drive OAuth token. The endpoint that performs this fetch is on app.hellosign.com and takes the Drive file id as a parameter.

Sreeram KL and the author of this write-up chained two bugs in that feature: a CSRF on the fetch endpoint and an SSRF in how the download URL was built. Together they let an attacker leak the Google Drive OAuth token of any HelloSign user who opened a crafted link. The issue was reported to Dropbox, fixed, and a bounty was paid.

Setup

The work builds directly on a public write-up by HTTPVoid, 'Hacking Google Drive Integrations', published on 1 February 2022, which described full SSRF on Dropbox servers through Drive integrations. The researchers had been testing Google Drive for the Google VRP for some time, so that write-up caught their attention and they set out to see how the integration had been changed after the earlier report.

To reproduce the chain you need a Google account (to create a Drive file and obtain a Drive file id), a HelloSign account (to observe the attachment request), and a server you control to receive the leaked token. The victim is any HelloSign user who is signed in and clicks a link.

Finding it

The earlier exploit worked like this:

  1. The attacker creates a JSON file with chosen contents in Google Drive.
  2. The attacker signs into HelloSign, uploads the created Drive file to it, and intercepts the request.
  3. The attacker injects the ?alt=media parameter into the file id value.
  4. The attacker gets the AWS metadata in the response.

The root cause of that SSRF was the alt=media parameter injection, which was used to modify the downloadUrl value. The HelloSign server then requested the downloadUrl and displayed its response.

Looking at the current behaviour, the researchers found that Dropbox had patched the SSRF by blacklisting sensitive URLs such as metadata and localhost. The parameter injection itself was not addressed, so it was still possible to make the server send requests to arbitrary external servers.

On its own that is not a serious issue. But in this flow the request carries the Google Drive Authorization token of the HelloSign user, because the request was supposed to go to the Google API and instead went to a server of the attacker's choosing. The researchers could now send their own Drive token to arbitrary servers; the remaining problem was how to make other users' tokens arrive there.

The answer was in the request that carries the injection. In step 3 the request is a GET to the following endpoint:

HTTP
GET /attachment/externalFile?service_type=G&file_reference={DRIVE_FILE_ID}&file_name=randomname&c=0.1 HTTP/1.1
Host: app.hellosign.com
Cookie: ...

That GET request was not protected against CSRF. Because the GET request was not protected from CSRF, an attacker can put it behind a link: when a signed-in HelloSign user opens the link, their Google Drive Auth token is sent to the attacker's server.

Exploitation

Step 1: Create the Drive file

Create a JSON file with chosen contents in Google Drive. The file only needs to exist and be reachable through the Drive API; its contents are not what leaks the token.

Step 2: Build the link

Note down the Drive file id and insert it into the URL. The file_reference value is where the ?alt=media parameter injection goes, modifying the downloadUrl that HelloSign will request.

Step 3: Deliver it

Send the link to a HelloSign user. When they visit it, their browser issues the GET to /attachment/externalFile with their HelloSign session, and the resulting request from HelloSign's servers carries their Google Drive OAuth token to the attacker's server. The token then appears in the attacker's server logs.

Root cause

Two mistakes combine. First, the downloadUrl is built from user-controlled input (file_reference) without preventing parameter injection, so the ?alt=media parameter can rewrite where the server sends its request. The blacklist added after the earlier report blocks sensitive destinations such as metadata and localhost, but it does not stop the request going to an arbitrary external host, and it does not stop the Authorization token from travelling with it. Second, the endpoint that triggers the fetch is a GET with no CSRF protection, so any third-party page can cause a signed-in user's browser to make the request. Either fix alone would break the chain; together they turn a harmless SSRF into token theft.

Impact

An attacker can obtain the Google Drive OAuth token of any HelloSign user who opens a crafted link while signed in. The token is delivered to a server the attacker controls and shows up in its logs. The attack requires the victim to click the link while signed in; no other interaction is described.

Fix

Dropbox fixed the issue. The report does not describe the code change; the retest on 6 April 2022 confirmed the bug was fixed, and it was marked resolved on 7 April 2022. The report does not describe the code change.

Variants to test

  • Parameter injection in URL-building code. Look for places where a user-supplied id is concatenated into a URL that the server later fetches. A positive result is the server requesting a host you control when you append a query parameter such as ?alt=media or an equivalent.
  • Blacklist-only SSRF defences. When a target blocks metadata and localhost, try arbitrary external hosts. A positive result is an outbound request to your server, especially one that carries credentials or tokens.
  • State-changing or sensitive GET endpoints. Enumerate GET endpoints that trigger server-side fetches or return sensitive data and check for anti-CSRF tokens. A positive result is the action completing from a cross-site link with the victim's session.
  • OAuth token forwarding. For any integration that stores a third-party OAuth token, check whether the token is attached to requests whose destination can be influenced. A positive result is the token appearing in logs on a host you control.

Timeline

Text
Feb 02, 2022 - Reported
Feb 04, 2022 - HackerOne triage closed and marked as duplicate
Feb 23, 2022 - Dropbox Product Security reopened
Mar 02, 2022 - Rewarded a $1,728 bounty
Apr 06, 2022 - Retested and found the bug to be fixed
Apr 07, 2022 - Marked as resolved

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

HelloSign is a product made by Dropbox. You use it to send documents to people so they can sign them online. One of its features lets you attach a file that lives in your own Google Drive: you sign in to HelloSign, pick a file from Drive, and HelloSign goes and fetches that file from Google for you. To do that, HelloSign uses a special key called an OAuth token that Google gave it permission to use on your behalf. Think of the token as a temporary visitor badge: whoever holds it can walk into your Drive through the official entrance, within the limits Google set.

Two researchers, Sreeram KL and Sivanesh Ashok, found a way to make HelloSign hand that badge to a server they controlled. They did it by combining two separate mistakes in the same feature. The first mistake let them choose where HelloSign's server sends its request. The second mistake let any website make a signed-in HelloSign user's browser trigger that request without the user noticing. Neither mistake is dangerous on its own. Together, they let an attacker steal the Google Drive token of any HelloSign user who clicked a link.

They reported it to Dropbox. Dropbox fixed it, paid a bounty of 1,728 US dollars, and the report was disclosed on 17 May 2022.

Before going further, a few words you will meet constantly:

  • An API is the way one program talks to another. It is like a service counter: you hand over a request in an agreed format, and you get an answer back. Google's Drive API is the counter where HelloSign asks for your file.
  • A cookie is a small piece of data your browser stores for a website and sends back with every request to that site. It is how a site remembers that you are signed in. If someone else gets your cookie, they can often act as you.
  • A token is a string of characters that proves permission. An OAuth token is one issued by an authorisation system (here, Google's) after you approve an app. The app shows the token instead of your password.
  • CSRF (Cross-Site Request Forgery) means tricking a signed-in user's browser into sending a request to a site the user trusts, without the user intending it. The browser automatically attaches the user's cookies, so the site believes the request came from the user.
  • SSRF (Server-Side Request Forgery) means making a server send a request to a destination the attacker chooses, rather than the one it was supposed to use.

The earlier report this builds on

On 1 February 2022, a researcher called HTTPVoid published a write-up titled 'Hacking Google Drive Integrations'. In it, they showed they could get a full SSRF on Dropbox's servers through the Drive integration. Sreeram and Sivanesh had been testing Google Drive for Google's own bug bounty programme (the Google VRP) for a while, so this write-up caught their attention. They wanted to see how the integration had been changed after that earlier report.

Here is how the earlier exploit worked, in four steps:

  1. The attacker creates a JSON file with chosen contents in Google Drive.
  2. The attacker signs into HelloSign, uploads the created Drive file to it, and intercepts the request.
  3. The attacker injects the ?alt=media parameter into the file id value.
  4. The attacker gets the AWS metadata in the response.

A JSON file is just a text file that stores data in a structured way, with names and values. "Intercepting the request" means using a tool that sits between your browser and the website so you can see and edit what the browser sends before it leaves. "AWS metadata" is a special internal address on Amazon's cloud servers that, if you can reach it, tells you things about the server and can hand out credentials. Reaching it from the outside is a classic sign of SSRF.

The root cause of that SSRF was the ?alt=media parameter injection. In a web address, everything after a ? is a set of parameters, written as name=value pairs joined by &. The alt=media parameter is a normal Google API instruction meaning "give me the actual file contents". By slipping it into the file id value, the attacker changed the downloadUrl value, which is the address HelloSign would fetch from. HelloSign's server then requested that downloadUrl and displayed whatever came back.

What the researchers found this time

When Sreeram and Sivanesh looked at the current behaviour, they found that Dropbox had patched the SSRF by blacklisting sensitive URLs such as metadata and localhost. A blacklist is a list of forbidden things: if the destination is on the list, the request is refused. Localhost is the name a machine uses for itself, so blocking it stops requests aimed back at the server's own insides.

But the parameter injection itself was not addressed. So it was still possible to make the server send requests to arbitrary external servers, that is, to any server on the internet that the attacker names.

On its own, that is not a serious issue: a server fetching a page from somewhere else is normal. But in this flow, the request carries the Google Drive Authorization token of the HelloSign user. That makes sense, because the request was supposed to go to the Google API, and instead it went to a server of the attacker's choosing. The token travels along as proof of permission, and the new destination simply reads it.

The researchers could now send their own Drive token to arbitrary servers. The remaining problem was how to make other users' tokens arrive there. They needed a way to make a victim's browser start the request.

The CSRF

The answer was in the request that carries the injection. In step 3 above, the request is a GET to the following endpoint:

HTTP
GET /attachment/externalFile?service_type=G&file_reference={DRIVE_FILE_ID}&file_name=randomname&c=0.1 HTTP/1.1
Host: app.hellosign.com
Cookie: ...

Line by line:

  • GET /attachment/externalFile?... HTTP/1.1 is the first line of an HTTP request. GET is the method used to ask for something. /attachment/externalFile is the path on the server that handles attaching an external file. Everything after the ? is the query string, the parameters sent with the request. HTTP/1.1 is the version of the protocol being spoken.
  • service_type=G tells HelloSign which external service the file comes from. G stands for Google.
  • file_reference={DRIVE_FILE_ID} is the identifier of the Drive file. The curly braces are a placeholder: in a real request this is replaced by the actual file id. This is the value where the ?alt=media injection goes.
  • file_name=randomname is the name to give the attachment. It is just a label.
  • c=0.1 is a cache-busting value. Browsers and servers sometimes reuse stored answers; a changing number forces a fresh request each time.
  • Host: app.hellosign.com says which website the request is for. One server can host many sites, and this header tells it which one you want.
  • Cookie: ... is where the browser sends the user's cookies, including the one that proves the user is signed in. The dots stand for the actual cookie value, which is not shown here.

And this GET request was not protected from CSRF. That means the request had no CSRF protection, so any page on the internet can point the victim's browser at this address. Without it, any page on the internet can point the victim's browser at this address.

This means the researchers could create a link which, when opened by a HelloSign user, would send that user's Google Drive Auth token to their server. The browser attaches the user's HelloSign cookie automatically, HelloSign treats the request as coming from the signed-in user, and the injected parameter redirects the fetch to the attacker.

The chain

Putting the two mistakes together gives three steps:

  1. Create a JSON file with the following contents in Google drive
  2. Note down the drive file id, and insert it in the following URL
  3. Send the link to a HelloSign user. When they visit it, you should get their Google Drive OAuth token in your server logs.

Step 1 gives you a real Drive file to point at, so HelloSign's code takes the normal path. Step 2 builds the malicious link: the file id is where the ?alt=media parameter injection goes, which changes the downloadUrl that HelloSign will request. Step 3 delivers it: the victim's browser issues the GET to /attachment/externalFile with the victim's HelloSign session, and the resulting request from HelloSign's servers carries the victim's Google Drive OAuth token to the attacker's server, where it appears in the logs.

Why it worked

Two mistakes combine. First, the downloadUrl is built from user-controlled input (file_reference) without preventing parameter injection, so the ?alt=media parameter can rewrite where the server sends its request. The blacklist added after the earlier report blocks sensitive destinations such as metadata and localhost, but it does not stop the request going to an arbitrary external host, and it does not stop the Authorization token from travelling with it. Second, the endpoint that triggers the fetch is a GET with no CSRF protection, so any third-party page can cause a signed-in user's browser to make the request. Either fix alone would break the chain; together they turn a harmless SSRF into token theft.

What an attacker could do with it

An attacker can obtain the Google Drive OAuth token of any HelloSign user who opens a crafted link while signed in. The token is delivered to a server the attacker controls and shows up in its logs. The attack requires the victim to click the link while signed in; no other interaction is described.

The fix

Dropbox fixed the issue. The report does not describe the code change; the retest on 6 April 2022 confirmed the bug was fixed, and it was marked resolved on 7 April 2022. The report does not describe the code change.

Things worth testing elsewhere

  • Parameter injection in URL-building code. Look for places where a user-supplied id is concatenated into a URL that the server later fetches. A positive result is the server requesting a host you control when you append a query parameter such as ?alt=media or an equivalent.
  • Blacklist-only SSRF defences. When a target blocks metadata and localhost, try arbitrary external hosts. A positive result is an outbound request to your server, especially one that carries credentials or tokens.
  • State-changing or sensitive GET endpoints. Enumerate GET endpoints that trigger server-side fetches or return sensitive data and check for anti-CSRF tokens. A positive result is the action completing from a cross-site link with the victim's session.
  • OAuth token forwarding. For any integration that stores a third-party OAuth token, check whether the token is attached to requests whose destination can be influenced. A positive result is the token appearing in logs on a host you control.

Timeline

Text
Feb 02, 2022 - Reported
Feb 04, 2022 - HackerOne triage closed and marked as duplicate
Feb 23, 2022 - Dropbox Product Security reopened
Mar 02, 2022 - Rewarded a $1,728 bounty
Apr 06, 2022 - Retested and found the bug to be fixed
Apr 07, 2022 - Marked as resolved

Line by line: the report was filed on 2 February 2022. Two days later, the first triage on HackerOne (the bug bounty platform) closed it and marked it as a duplicate. On 23 February, Dropbox's Product Security team reopened it. On 2 March a bounty of 1,728 US dollars was paid. On 6 April the researchers retested and found the bug fixed, and on 7 April it was marked resolved.

Glossary

  • API: the agreed way for one program to ask another program for data or actions, like a service counter with fixed forms.
  • Attachment: a file that is added to a document or message rather than written in its body.
  • AWS metadata: an internal address on Amazon cloud servers that can reveal information and credentials about the server itself.
  • Blacklist: a list of things that are forbidden; anything on the list is refused, anything not on it is allowed.
  • Bounty: a reward paid by a company to someone who reports a security problem to it.
  • Cache-busting: adding a changing value to a request so that stored copies are not reused and a fresh answer is fetched.
  • Cookie: a small piece of data a browser stores for a site and sends back with each request, often used to keep you signed in.
  • CSRF (Cross-Site Request Forgery): making a signed-in user's browser send a request to a site they trust, without their intent, so the site acts as if the user asked.
  • Disclosure: making the details of a security report public.
  • Download URL: the address a server fetches a file from.
  • Duplicate: a report that describes a problem someone else already reported.
  • Endpoint: a specific address on a server that performs a specific action.
  • GET: the HTTP method used to ask a server for something, normally without changing anything.
  • Google VRP: Google's Vulnerability Reward Program, its bug bounty scheme.
  • Header: an extra line of information sent with an HTTP request or response, such as Host or Cookie.
  • HelloSign: a Dropbox product for sending and signing documents online.
  • Host header: the part of a request that says which website on a server is being addressed.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • Intercept: to capture a request between browser and server so it can be inspected or changed.
  • JSON: a text format for structured data, made of names and values.
  • Localhost: the name a computer uses to refer to itself.
  • OAuth token: a string issued by an authorisation system that lets an app act on your behalf without your password.
  • Parameter: a name=value pair in a URL after the ?, used to pass information to the server.
  • Parameter injection: slipping extra parameters into a value so that the code building a URL treats them as its own.
  • Query string: everything after the ? in a URL, made of parameters joined by &.
  • Scope: the set of permissions a token grants.
  • SSRF (Server-Side Request Forgery): making a server send a request to a destination the attacker chooses.
  • Triage: the first review of a bug report, where it is checked, classified and routed.
  • URL: the address of something on the web.

More by Sivanesh Ashok

View all

1 more disclosed report, best first.

More from Dropbox

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.