Make-Recruiting-Referrals-On-Behalf-Of-Facebook
A GraphQL mutation intended for Facebook employees to refer job candidates could be called by any non-employee, allowing them to send emails from the [redacted] address with limited control over the body.
Published on philippeharewood.com
There is a GraphQL call that makes it possible to send emails via [email protected]. This seems to be meant for Facebook employees who want to refer possible candidates.
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.
What the report shows
Facebook exposes a GraphQL endpoint at graph.facebook.com. Among its mutations is one that creates a recruiting referral, and that mutation sends an email through [redacted]. The feature appears to be intended for Facebook employees who want to refer possible candidates.
The researcher found that the mutation could be invoked by an account that is not an employee. The proof of concept is a single GraphQL mutation sent as a non-employee:
HTTP POST (graph.facebook.com)
q=Mutation SyncAddMutations : SyncAddMutationsResponse {recruiting_referral_create(<input>){client_mutation_id,recruiting_referral}}
query_params={"input":"{\"actor_id\":\"userid\",\"client_mutation_id\":\"1\",\"lead_name\":\"phwd\",\"email\":\"[redacted]\",\"notes\":\"whitehat\",\"sent_to_candidate\":\"true\",\"is_legal_notice_accepted\":\"true\",\"is_draft\":\"true\",\"source\":\"quick_referral\"}"}
The input carries the actor's user id, a client mutation id, the lead name, the candidate email address, free-text notes, and several flags: sent_to_candidate, is_legal_notice_accepted, is_draft, plus a source value of quick_referral.
The response does not report an error. It returns the mutation id and a null referral object:
{
"recruiting_referral_create": {
"client_mutation_id": "1",
"recruiting_referral": null
}
}
Despite the null object, the email is sent. The report states that the email is sent despite the null referral object.
The report's impact statement is deliberately hedged: this could have let a malicious user send emails on behalf of [redacted], with limited control over the email body. The timeline records the report on 24 October 2017, a request for additional details on 30 October, those details sent the same day, further investigation by Facebook on 31 October, and a bounty awarded on 6 December 2017. The report gives no severity rating, no CVSS score and no description of the fix.
Root cause
The report does not state a root cause. The null recruiting_referral in the response suggests the object creation path did not complete, yet the email was still dispatched, so the authorisation decision and the side effect are not tied together.
Impact
An ordinary user could cause mail to be sent from a trusted Facebook recruiting address to an address of their choosing, with some control over the body content through the supplied fields. The report notes only that emails could be sent on behalf of the recruiting address with limited control over the body. The report limits the claim to limited control over the body, so the practical ceiling is a convincing but not fully arbitrary message.
How this kind of bug works
GraphQL APIs expose a schema of queries and mutations, and each mutation is a server-side function with arguments. Access control has to be enforced inside each resolver, because the schema itself usually does not distinguish who may call what. When a feature is built for a privileged group, such as staff, the restriction is often applied in the web client that hides the button, or in one older endpoint, and the newer GraphQL mutation is added without the same check. The mutation then runs with the server's own privileges, including the ability to send mail from a corporate address.
A second pattern makes the bug harder to notice: mutations that return null or an empty object while still committing side effects. Testers who judge success only by the response body will miss it, and developers who rely on the response to signal failure will not see the unauthorised action in logs.
Defences are straightforward in principle: enforce authorisation in the resolver, not the client; treat every mutation as a public entry point; and separate side effects such as sending mail from object creation so that a failed or unauthorised creation cannot trigger them.
How to test for it
- Map the GraphQL schema. Introspection, if enabled, gives mutation names and argument types; otherwise observe the traffic of the privileged feature in a client you can access, or read public JavaScript bundles for operation names.
- Identify mutations with side effects: anything that sends mail or messages, invites users, creates referrals, grants roles or triggers notifications.
- Replay the mutation from an account that should not have the feature, keeping the original arguments and substituting your own identifiers and a mailbox you control.
- Vary the privilege signals: omit or alter role fields, use a low-privilege account, and try the mutation with the actor id of the low-privilege user.
- Check the out-of-band effect, not the response. Look in the receiving mailbox, the notification centre or the audit log. A null result object with a delivered message is a positive finding.
A positive result is a side effect that reaches a real recipient or changes real state while the caller lacks the role the feature is meant for. Common false positives are: the mutation returning an error that you did not read carefully; the mail being sent to the caller's own address only, which may be intended; the action being permitted for a broader group than you assumed; and cached or delayed responses that make a failed call look successful. Confirm with a fresh recipient address each time.
How this could be fixed
Enforce the role check inside the mutation resolver, on the server, for every caller regardless of client. Return an authorisation error before any side effect runs. Decouple mail dispatch from object creation so that a mutation that fails to create its object cannot send anything. Add server-side logging of who invoked each mutation and what it dispatched, and review other mutations built for staff or internal teams for the same missing check.
Hunting notes
These bugs cluster around features that only some users should reach: staff tools, recruiting, support, billing, moderation and internal notifications. GraphQL endpoints are a common home because new mutations are added quickly and the schema is often reachable by any authenticated user. Recon signals include operation names in JavaScript bundles that mention internal teams, mutations whose names do not appear in the normal UI, and responses that return null while something clearly happened.
To make the report land, show the request, the response, and independent proof of the side effect, such as the received message. State the boundary you crossed: which role you held and which role the feature requires. Keep the impact claim to what you demonstrated, as this report does with its note about limited control over the body.
What happened, in plain words
Facebook has a feature for its employees: staff who know a good job candidate can refer that person to the recruiting team. When an employee fills in the referral, Facebook sends an email to the candidate from the address [redacted]. That address belongs to Facebook, so a message from it looks official.
Behind the scenes, the website talks to Facebook's servers through an interface called GraphQL. You can think of GraphQL as a menu of actions the server offers: each action has a name and takes some inputs, and the server performs it when asked. One of those actions is called recruiting_referral_create, and it is the action that creates a referral and sends the email.
The researcher found that this action could be triggered by a non-employee account, not just by an employee. In other words, the door marked "staff only" was unlocked for everyone. He sent the action from a non-employee account and the email went out.
The request
Here is the request he sent, exactly as it appears in the report:
HTTP POST (graph.facebook.com)
q=Mutation SyncAddMutations : SyncAddMutationsResponse {recruiting_referral_create(<input>){client_mutation_id,recruiting_referral}}
query_params={"input":"{\"actor_id\":\"userid\",\"client_mutation_id\":\"1\",\"lead_name\":\"phwd\",\"email\":\"[redacted]\",\"notes\":\"whitehat\",\"sent_to_candidate\":\"true\",\"is_legal_notice_accepted\":\"true\",\"is_draft\":\"true\",\"source\":\"quick_referral\"}"}
Line by line:
HTTP POST (graph.facebook.com)says the request is sent to Facebook's GraphQL server atgraph.facebook.com. A POST request is the usual way a browser or tool sends data to a server.q=Mutation SyncAddMutations ...is the instruction: run the action namedrecruiting_referral_createand return two pieces of information,client_mutation_idandrecruiting_referral. The word "mutation" in GraphQL means an action that changes something on the server, as opposed to a query, which only reads.query_params={"input": ...}carries the details of the referral. Inside it:actor_idis the id of the account making the request. The report shows the placeholderuserid.client_mutation_idis a label the client attaches so it can match the answer to its request. Here it is1.lead_nameis the name of the person being referred, shown asphwd.emailis the candidate's address, shown as[redacted].notesis free text, herewhitehat.sent_to_candidate,is_legal_notice_acceptedandis_draftare on/off flags, all set totrue.sourcerecords where the referral came from, herequick_referral.
Why this matters: nothing in the request proves the sender is an employee.
The response
{
"recruiting_referral_create": {
"client_mutation_id": "1",
"recruiting_referral": null
}
}
The server answered without an error. It echoed back the label 1, and the recruiting_referral field is null, meaning no referral object was returned. A reader might conclude nothing happened. But the email was sent anyway, as the report states.
This gap between the answer and the real effect is the heart of the finding: the server did the side effect (sending mail) even though the visible result looked empty.
Impact
The report is careful about what this allowed. A malicious user could send emails on behalf of [redacted], with limited control over the email body. The report notes only that emails could be sent on behalf of the recruiting address with limited control over the body. The report does not claim full control of the message, only limited control.
Timeline
- 24 October 2017: report sent.
- 30 October 2017: Facebook asked for additional details, which were sent the same day.
- 31 October 2017: further investigation by Facebook.
- 6 December 2017: bounty awarded.
The report gives no severity rating, no CVSS score and no description of the fix.
In general, how this kind of bug works
A GraphQL server is like a restaurant menu: it lists actions (mutations) and what each one needs. The menu itself does not decide who is allowed to order what. That decision has to be made in the kitchen, meaning inside the code that handles each action. If the check is only in the website's buttons, anyone who sends the request directly skips it.
A second trap is an action that returns nothing useful but still does something real. If testers judge success only by the reply, they miss it, and if developers rely on the reply to detect failure, they miss the unauthorised action in their logs.
A fix would be to check the caller's role on the server before any side effect runs, and to keep sending mail separate from creating the object.
How to test for it
- Find out which actions the server offers. Some servers publish a list; otherwise watch the traffic of the feature in a browser you can use.
- Pick actions with real effects: sending mail or messages, inviting people, creating referrals, granting roles.
- Repeat the action from an account that should not have the feature, using your own identifiers and a mailbox you control.
- Try changing the role-related fields, and use a low-privilege account.
- Check the real-world effect, not the reply: look in the receiving mailbox or the notification centre. A null result with a delivered message is a positive finding.
Common false positives: an error you did not read carefully, mail sent only to your own address, the action being allowed for a wider group than you assumed, or delayed responses. Use a fresh address each time to confirm.
How this could be fixed
Check the role inside the server code for every caller, return an error before any side effect, separate mail sending from object creation, log who did what, and review other staff-only actions for the same missing check.
Hunting notes
These bugs cluster around staff tools: recruiting, support, billing, moderation, internal notifications. GraphQL is a common home because new actions are added quickly. Signals include action names in website code that mention internal teams, and replies that look empty while something clearly happened. To make a report land, show the request, the response and independent proof of the effect, and state which role you held and which role the feature requires. Keep the impact claim to what you demonstrated.
Glossary
- GraphQL: an interface where a client asks a server to run named actions and choose which fields to get back.
- Mutation: a GraphQL action that changes something on the server, such as creating a record or sending mail.
- Query: a GraphQL action that only reads data.
- Endpoint: the address a request is sent to, here
graph.facebook.com. - Request: a message a browser or tool sends to a server.
- Response: the server's reply to a request.
- POST: an HTTP method used to send data to a server.
- Parameter: a named value sent with a request, such as
email. - Field: a named piece of data in a GraphQL request or response.
- Null: an empty value, meaning no data.
- Side effect: something real that happens as a result of an action, such as an email being sent.
- Authorisation: deciding whether a user is allowed to do something.
- Privilege: the level of access an account has.
- Resolver: the server code that carries out a GraphQL action.
- Phishing: tricking someone with a message that pretends to come from a trusted source.
- Bounty: a reward paid for reporting a security bug.
- CVSS: a standard score for how severe a vulnerability is.
- False positive: a result that looks like a bug but is not.
- Out-of-band effect: a result seen somewhere other than the response, such as a delivered email.