Skip to content
Leaked secrets Write-up Beginner

Facebook Messenger for MacOS contained valid hardcoded FB access token (employee's token?)

The Facebook Messenger for macOS app contained a hardcoded, valid Facebook access token embedded in a URL. An attacker who extracted the token could use it to access Facebook API resources with the token's permissions, though the token appeared to have only normal user privileges.

Dzmitry Follow

Published on vulnano.com

Bounty$725 View original

By Dzmitry - September 23, 2021

Dzmitry, on vulnano.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. 3 min read.

Context

Facebook Messenger for MacOS is the desktop client for Meta's messaging service. The researcher, Dzmitry, spent part of summer 2021 looking at the application's code for hardcoded data. The target here is not a server-side endpoint but the shipped binary itself: anything embedded in it is distributed to every user who installs the app.

Setup

The only tooling described is a grep over the application's code to extract URLs, followed by manual analysis of the results. The version tested was:

  • Facebook Messenger v. 97.11.116 (97.11.116.283083801) for MacOS

No accounts, roles or special preconditions are mentioned. The researcher simply had the app installed and access to its code.

Finding it

The researcher grepped all URLs out of the code and started to analyse them. Quickly, a few URLs stood out because they carried an access_token value in the query string. The screenshot below shows those URLs as they appeared in the extracted strings:

From the original on vulnano.com

A token embedded in a client application is interesting on its own, but the question that matters is whether it is still live. A stale token from an old build is noise; a valid one is a credential handed to anyone who downloads the app.

Exploitation

Step 1: Check whether the token is still valid

To answer that question the researcher opened the Access Token Debugger, passing the token found in the app:

Text
https://developers.facebook.com/tools/debug/accesstoken/?access_token=

The debugger confirmed that the token was valid. The screenshot shows the result of that check:

From the original on vulnano.com

At that point the researcher stopped experimenting and sent a report to the Facebook team straight away, rather than probing what the token could reach.

Step 2: Wait for triage

Throughout the period before the bounty decision, the researcher hoped the token carried some extra internal permissions. It did not: it appears to have been a normal token, probably belonging to a Facebook employee, with no additional access. The likely explanation given is that a software developer placed the link inside the app by mistake and it shipped to the whole world.

Root cause

A URL containing an access_token query parameter was embedded in the Messenger for MacOS client, so the credential travelled with every copy of the build. The report does not describe how the link came to be in the code beyond the suggestion that a developer added it by mistake. The debugger accepted the token as valid, and the researcher later concluded it was a normal token without extra internal permissions.

Impact

Anyone who obtained the app could extract the token and use it for as long as it remained valid. The researcher's own assessment is that the token was a normal one without extra internal permissions, so the practical reach of the credential was limited to whatever a normal token of that kind allows. The report does not enumerate those permissions or the data the token could access.

Fix

The token was invalidated. The timeline recorded in the report:

Event Date and time
Submitted 27.07.2021 10:08AM
Triaged 27.07.2021 12:36AM
Fixed (token became invalid) 27.07.2021 12:45AM
Fix notification 04.08.2021
Reward $500 (+$125 bonus) on 08.09.2021

The researcher notes that it is unclear whether the system invalidated the token automatically or the Facebook team did it. The report does not say whether the hardcoded URL was removed from the application itself.

Variants to test

  • Grep desktop and mobile clients for access_token, token=, api_key and similar parameter names in embedded URLs. A positive result is a hit that the platform's own token debugger accepts as valid.
  • Check any token you find against the provider's debugger before doing anything else, and report immediately if it is live, as the researcher did here.
  • The researcher hoped the token, probably an employee's, would carry extra internal permissions; it did not.
  • Apply the same extraction to other build artefacts that ship to users, such as bundled configuration files and resources, since a link added by mistake in one place tends to appear in others.

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

What happened, in plain words

In the summer of 2021, a security researcher named Dzmitry spent some time looking inside the Mac version of Facebook Messenger. Messenger is Meta's messaging app, and the Mac version is a program you install on an Apple computer, just like any other desktop application. When you install a program like this, you get a copy of a file (often called a binary) that was built by the company and then handed out to everyone who downloads it. Anything written inside that file is therefore on every user's computer, whether the company meant to share it or not.

Dzmitry was looking for something specific: hardcoded data. "Hardcoded" means a value that a programmer typed directly into the program's source code, rather than something the program fetches from a server at runtime. A hardcoded value is baked into the file and travels with every copy. If that value is a secret, such as a password or a token, then the secret is effectively public.

A token, in this context, is a short string of characters that acts like a temporary key. When you log in to a service, the service gives your app a token, and the app sends that token with each request to prove who it is. It is similar to a coat-check ticket: whoever holds the ticket can collect the coat, no questions asked. If someone else gets hold of your ticket, they can use it too, at least until it expires or is cancelled.

The researcher found a few web addresses (URLs) inside the Messenger app that contained an access_token value. A URL is just the address of something on the internet, like https://example.com/page. The part after the ? is called the query string, and it carries extra information in the form of name=value pairs. An access_token in a query string is a token being sent as part of the address, which is a common pattern but also a risky one if the address ends up somewhere public.

The important question was whether the token was still valid. An old token from a previous version of the app would be harmless noise. A live token would mean that anyone who downloaded Messenger for Mac could pull the token out and use it. Dzmitry checked the token using Facebook's own token debugger tool, and the tool confirmed the token was valid. At that point the researcher stopped experimenting and sent a report to Facebook straight away.

While waiting for the bounty decision, Dzmitry hoped the token had extra internal permissions, which would have made the impact much bigger. It did not. The token appears to have been a normal one, probably belonging to a Facebook employee, with no additional access. The likely explanation is that a developer placed the link inside the app by mistake, and it shipped to the whole world.

Setup

The only tooling described in the report is a grep over the application's code to pull out URLs, followed by manual analysis of the results. Grep is a command-line tool that searches text for a pattern and prints the matching lines. If you have ever used your computer's search box to find a word in a document, grep does the same thing but for files and folders, and it is very fast.

The version tested was:

  • Facebook Messenger v. 97.11.116 (97.11.116.283083801) for MacOS

No accounts, roles or special preconditions are mentioned. The researcher simply had the app installed and access to its code. In other words, this was not a case of breaking into a server. It was a case of reading what was already sitting on the researcher's own machine.

Finding it

The researcher grepped all URLs out of the code and started to analyse them. Quickly, a few URLs stood out because they carried an access_token value in the query string. The screenshot below shows those URLs as they appeared in the extracted strings:

From the original on vulnano.com

A token embedded in a client application is interesting on its own, but the question that matters is whether it is still live. A stale token from an old build is noise; a valid one is a credential handed to anyone who downloads the app. Think of it like finding a key taped under a bench in a public park. The key itself is interesting, but the real question is whether it still opens a door.

Exploitation

Step 1: Check whether the token is still valid

To answer that question the researcher opened the Access Token Debugger, passing the token found in the app:

Text
https://developers.facebook.com/tools/debug/accesstoken/?access_token=

Line by line, in plain words:

  • https://developers.facebook.com is the address of Facebook's developer site. The https part means the connection is encrypted, so nobody between you and the server can read it.
  • /tools/debug/accesstoken/ is the path to a specific page on that site. This page is Facebook's own tool for inspecting tokens: you give it a token and it tells you whether the token is valid and what it can do.
  • ?access_token= starts the query string. The name is access_token, and the value after the = is where the token would go. In the report the value is left blank, because the actual token is a secret and is not reproduced here.

The debugger confirmed that the token was valid. The screenshot shows the result of that check:

From the original on vulnano.com

At that point the researcher stopped experimenting and sent a report to the Facebook team straight away, rather than probing what the token could reach. This is a deliberate choice. Once you have confirmed that a credential is live, the responsible thing is to tell the owner and let them shut it down, not to keep poking around to see how far it goes.

Step 2: Wait for triage

Triage is the process a security team uses to look at a report, decide whether it is a real issue, and route it to the right people. Throughout the period before the bounty decision, the researcher hoped the token carried some extra internal permissions. It did not: it appears to have been a normal token, probably belonging to a Facebook employee, with no additional access. The likely explanation given is that a software developer placed the link inside the app by mistake and it shipped to the whole world.

Root cause

A URL containing an access_token query parameter was embedded in the Messenger for MacOS client, so the credential travelled with every copy of the build. The report does not describe how the link came to be in the code beyond the suggestion that a developer added it by mistake. The debugger accepted the token as valid, and the researcher later concluded it was a normal token without extra internal permissions.

"Scoped down" means the token was limited to a small set of permissions. Tokens can be issued with different levels of access, just like a hotel key card can open only your room or every room in the building. A scoped-down token is less dangerous if it leaks, because it cannot do much. The report does not say whether this token was scoped down, only that the debugger accepted it as valid.

Impact

Anyone who obtained the app could extract the token and use it for as long as it remained valid. The researcher's own assessment is that the token was a normal one without extra internal permissions, so the practical reach of the credential was limited to whatever a normal token of that kind allows. The report does not enumerate those permissions or the data the token could access.

Fix

The token was invalidated. Invalidating a token means telling the server to stop accepting it, so even if someone still has the string, it no longer works. It is like cancelling a credit card: the number is still written down somewhere, but it cannot be used to pay for anything.

The timeline recorded in the report:

Event Date and time
Submitted 27.07.2021 10:08AM
Triaged 27.07.2021 12:36AM
Fixed (token became invalid) 27.07.2021 12:45AM
Fix notification 04.08.2021
Reward $500 (+$125 bonus) on 08.09.2021

The researcher notes that it is unclear whether the system invalidated the token automatically or the Facebook team did it.

Variants to test

  • Grep desktop and mobile clients for access_token, token=, api_key and similar parameter names in embedded URLs. A positive result is a hit that the platform's own token debugger accepts as valid.
  • Check any token you find against the provider's debugger before doing anything else, and report immediately if it is live, as the researcher did here.
  • The researcher hoped the token, probably an employee's, would carry extra internal permissions; it did not.
  • Apply the same extraction to other build artefacts that ship to users, such as bundled configuration files and resources, since a link added by mistake in one place tends to appear in others.

Glossary

  • API: Application Programming Interface. A set of rules that lets one program talk to another, like a menu in a restaurant: you order from the menu and the kitchen does the work, without you going into the kitchen.
  • Access token: A string of characters that proves an app is allowed to act on behalf of a user or service. Like a coat-check ticket: whoever holds it can collect the coat.
  • Binary: The compiled file of a program that you install and run. It is what the developer builds and ships to users.
  • Bounty: A reward paid by a company to a researcher who reports a security issue responsibly.
  • Credential: Anything used to prove identity, such as a password, a token or a key.
  • Debugger (token debugger): A tool that inspects a token and reports whether it is valid and what it can do.
  • Grep: A command-line tool that searches text for a pattern and prints matching lines.
  • Hardcoded: A value typed directly into a program's source code, so it is baked into every copy of the program.
  • Invalidate: To tell a server to stop accepting a token or credential, so it no longer works even if someone still has it.
  • MacOS: Apple's operating system for Mac computers.
  • Query string: The part of a URL after the ?, made of name=value pairs that carry extra information.
  • Scope (permissions): The set of actions a token is allowed to perform. A scoped-down token can do less, so it is less dangerous if it leaks.
  • Triage: The process a security team uses to review a report, decide whether it is a real issue, and route it to the right people.
  • URL: Uniform Resource Locator. The address of something on the internet, like https://example.com/page.
  • Valid (token): Still accepted by the server. A valid token can be used; an invalid one cannot.

More by Dzmitry

View all

1 more disclosed report, best first.

More from Meta

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Leaked secrets and credentials

The lesson behind this report.

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.