Skip to content
Leaked secrets Disclosed report Beginner

Github access token exposure

A GitHub access token belonging to a Shopify employee was found inside a public macOS Electron app, giving read and write access to Shopify's private repositories. An attacker could have used it to push code or backdoors to those repositories.

augustozanellato Follow

Originally disclosed on HackerOne

Bounty$50,000 Critical 10.0 View original
  • Triaged in 2 hours
  • Fixed in 2 months
  • Paid in 7 days
  • Disclosed after 6 months

Summary by the program

On January 26, @augustozanellato reported that while reviewing a public MacOS app, they found a valid GitHub Access Token belonging to a Shopify employee. This token had read and write access to Shopify-owned GitHub repositories. Upon validating the report, we immediately revoked the token and performed an audit of access logs to confirm no unauthorized activity had occurred.

Summary by the researcher

I was reviewing an Electron app made by one of Shopify employees (at the time I didn't know that Shopify was in any way involved), after extracting the app.asar file using npx asar extract path/to/app.asar extracted/path I found a .env file, initially I skipped it because I thought it just contained some app configuration stuff but after taking a look at the source it was clear that the app never loaded it. It was probably a leftover of the release building process. That .env contained a GH_TOKEN variable, which is (as you can probably guess) a GitHub token, I tried using it to authenticate against GitHub REST API using curl -H "Authorization: token $GH_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/user, I saw that the token was indeed valid so I decided to hit the /user/orgs API endpoint and I got back (among others) the Shopify organization, then I hit the /orgs/Shopify/repos endpoint to confirm the GitHub token scope and I successfully got back a list containing both Shopify public and private repos with "permissions": {"admin": false, "push": true, "pull": true} so at that point I knew that the token was enabling me to perform arbitrary push and pulls to Shopify repos so potentially permitting me to place backdoors and such.

The report

While dissecting an application made by one of your employees I found his GitHub Personal Access Token (PAT), he's a member of the org with pull and push access to all of your repositories. As a proof I can tell you that on the repo github.com/Shopify/shopify at commit hash cea9c273391d the sha512 of the README.md is 69750574bec56c1f1052db3471252b1daacdc9dda9f6d5332a3400a847fa413ec1caf19ef0b5501f18a5a76c232e7210d5f3b91c24c9439f4e0f64c02d6db824.

Impact

Read and write access to all your private github repositories.

The original report as published on HackerOne, by augustozanellato. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

Context

Shopify runs its engineering work on GitHub, and its employees hold GitHub Personal Access Tokens (PATs) that grant access to the company's repositories. The exposure was not in a web endpoint: it was inside a public macOS desktop application built by a Shopify employee. The application was an Electron app, and Electron apps ship their JavaScript and assets bundled inside an app.asar archive, which anyone who downloads the app can unpack.

The report was filed on 26 January and disclosed on 26 July 2021. The program rated it critical with a CVSS score of 10.0 and paid a bounty of 50,000 USD.

Setup

No special access was needed. The researcher downloaded a publicly available macOS application made by a Shopify employee and used Node's asar tool through npx to extract the bundle. The only external service involved was the GitHub REST API, reached with curl. The researcher did not know at the time that Shopify was involved with the app.

Finding it

The researcher extracted the contents of the Electron bundle:

Bash
npx asar extract path/to/app.asar extracted/path

Inside the extracted files there was a .env file. The researcher initially skipped it, assuming it held ordinary application configuration. Reading the application source showed that the app never loaded that file, so it was probably a leftover from the release build process rather than something the running app used.

The .env file contained a GH_TOKEN variable, a GitHub token. A token sitting in a shipped, publicly distributed build is wrong on its own: the build artefact is downloadable by anyone, and the token is readable without any authentication.

Exploitation

Step 1: check whether the token is valid

The researcher authenticated against the GitHub REST API with the token:

Bash
curl -H "Authorization: token $GH_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/user

The Authorization: token header carries the PAT, and the Accept header selects version 3 of the GitHub API. The call returned the authenticated user, confirming the token was valid.

Step 2: find which organisations the token belongs to

The researcher then called the organisations endpoint for the authenticated user:

Text
/user/orgs

Among the results was the Shopify organisation.

Step 3: confirm the scope of access

To establish what the token could actually do, the researcher listed the organisation's repositories:

Text
/orgs/Shopify/repos

The response contained both public and private Shopify repositories, each with the following permissions object:

JSON
"permissions": {"admin": false, "push": true, "pull": true}

No admin rights, but push and pull on the repositories returned. That meant the token allowed arbitrary pushes and pulls to Shopify repositories, which in principle would let a holder plant backdoors and similar changes.

Step 4: prove the access with a concrete artefact

To give the program something verifiable, the researcher cited a specific repository, commit and file hash:

Text
github.com/Shopify/shopify at commit hash cea9c273391d

At that commit, the SHA-512 of README.md is:

Text
[redacted]

The report cites the commit and the SHA-512 of README.md as proof.

Root cause

The token was embedded in a .env file that was packaged into the app.asar of a public release. The application source never read that file, so it was likely an artefact of the release build process that was not stripped before packaging. Because the bundle is distributed publicly, the secret was effectively published. The token itself had push and pull rights across the organisation's repositories, so a single leaked value carried broad write access.

Impact

As the researcher put it, the token gave read and write access to all of Shopify's private GitHub repositories. The permissions returned by the API were push and pull, without admin. With push access, an attacker could modify repository contents, which the researcher describes as potentially allowing backdoors to be placed. The program's summary states that the token was revoked immediately on validation and that an audit of access logs confirmed no unauthorised activity had occurred.

Fix

What the program did is stated: the token was revoked as soon as the report was validated, and access logs were audited. The report does not describe any change to the build or release process. The general lesson is to keep credentials out of build artefacts entirely, and to scope tokens narrowly rather than granting organisation-wide push and pull.

Variants to test

  1. Extract app.asar from other public Electron apps and grep the extracted tree for .env files, GH_TOKEN, AWS_, STRIPE_ and similar variable names. A positive result is a file the application source never references, which suggests a build leftover.
  2. Check whether the application loads the configuration file at runtime. If the source never reads it, the file is more likely to be a packaging mistake than a deliberate feature.
  3. For any token found, call the identity endpoint first, then the organisation and repository listing endpoints, and record the permissions object for each repository. A positive result is push: true on private repositories.
  4. Prove read access with a stable artefact such as a file hash at a named commit, rather than by making any change.

Hunting notes

This kind of bug hides in distributed client artefacts: desktop apps, mobile packages and anything else that ships a bundle to users. During recon, public release downloads and their unpacked contents are worth inspecting, and a .env file that the application code never references is a strong signal. The researcher established impact in stages: validity of the token, membership of the organisation, the exact permissions on repositories, and finally a verifiable read of a specific file at a specific commit.

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

What happened, in plain words

Shopify is a company that makes software for online shops. Its engineers keep their code on GitHub, a website where programmers store and share code. To let their computers talk to GitHub without typing a password every time, engineers use a special kind of key called a Personal Access Token, or PAT. A token is like a key card for a building: whoever holds it can get in, and the building does not check who is holding it.

One of Shopify's employees built a small desktop application for Mac computers and released it publicly, so anyone could download it. That application accidentally contained one of these GitHub keys inside it. Because the application was public, the key was public too. Anyone who downloaded the app and looked inside could find the key and use it to read and change Shopify's code.

A security researcher downloaded the app, found the key, and checked what it could do. It turned out the key could read and write to Shopify's code repositories, including private ones. The researcher reported this to Shopify through a bug bounty programme, a scheme where companies pay people for finding security problems. Shopify confirmed the problem, cancelled the key straight away, and checked its records to make sure nobody had misused it. The report was rated critical, the most serious level, with a CVSS score of 10.0 out of 10.

Background: the pieces involved

Before walking through the steps, here are the main pieces, explained from scratch.

GitHub and repositories. GitHub is a website where code is stored. A collection of code files for one project is called a repository, or repo. Repositories can be public (anyone can see them) or private (only people with permission can see them). Companies like Shopify keep huge amounts of code in private repositories.

Personal Access Token (PAT). Normally you log in to GitHub with a username and password. A token is a long string of random-looking characters that works instead of a password. You put it in a request and GitHub treats you as the person who created it. The danger is that a token is just text: if it ends up in a file that other people can read, they can use it exactly as if they were you.

Electron and app.asar. Electron is a tool for building desktop applications using web technology (the same technology as websites). When an Electron app is built, its code and files are packed into a single archive file called app.asar. Think of it like a zip file: it bundles everything together. The important point is that anyone who downloads the app can unpack this archive and read everything inside. It is not secret.

.env file. A .env file is a small text file that programs often use to store settings, and sometimes secrets like passwords or tokens. Each line is usually a name and a value, for example GH_TOKEN=something. Developers often keep such a file on their own computer while building an app.

API and REST API. An API (Application Programming Interface) is a way for one program to talk to another over the internet. You send a request to a specific address, and you get data back. GitHub has a REST API, which means you can ask GitHub questions like "who am I?" or "what repositories does this organisation have?" by sending requests to particular web addresses, called endpoints.

curl. curl is a command-line tool for sending requests to web addresses. You type a command in a terminal (a text window where you type commands), and curl sends the request and prints the response.

Headers. When a program sends a request, it can include extra pieces of information called headers. They are like the label on an envelope: they tell the receiving server things like who is sending the request and what kind of answer they want.

Commit and hash. A commit is a saved snapshot of a repository at a particular moment. Each commit has a short identifier (a commit hash). A hash is a fingerprint of a file's contents: a long string of characters produced by a mathematical function. If the file changes even slightly, the hash changes completely. Comparing hashes is a way to prove you saw exactly a certain file without copying the whole file.

CVSS and severity. CVSS is a standard scoring system for how serious a security flaw is, from 0 to 10. A score of 10.0 is the maximum. "Critical" is the label for the most severe category.

The setup

No special access was needed to find this problem. The researcher simply downloaded a publicly available macOS application that had been made by a Shopify employee. At the time, the researcher did not know that Shopify was involved with the app at all.

The only tools used were:

  1. npx, a command that runs small Node.js tools without installing them permanently. Node.js is a runtime for JavaScript, the language Electron apps are built with.
  2. The asar tool, which unpacks Electron archives.
  3. curl, to talk to GitHub's API.

The only outside service contacted was GitHub's API.

Finding it

The researcher unpacked the application's archive to see what was inside:

Bash
npx asar extract path/to/app.asar extracted/path

Line by line:

  • npx runs a tool from the Node.js ecosystem. It fetches the tool if needed and runs it.
  • asar is the name of the tool being run. It handles Electron's app.asar archive format.
  • extract tells the tool what to do: take the archive apart and write the files out.
  • path/to/app.asar is the archive file to unpack. In the real command this would be the actual location of the downloaded app's archive.
  • extracted/path is the folder where the unpacked files should be placed.

Why this step: an Electron app is just a bundle of files. Unpacking it is the equivalent of opening a parcel to see what is inside. Anyone who downloads the app can do this, so anything inside should be assumed to be public.

Inside the unpacked files there was a .env file. The researcher first skipped it, thinking it was ordinary app configuration. Then they read the application's source code and saw that the app never loaded that file. That meant the file was probably a leftover from the process of building the release, not something the running app needed.

Why this matters: a token inside a publicly distributed build is exposed by definition. The build can be downloaded by anyone, and the token can be read without logging in to anything. The fact that the app never used the file made it a mistake rather than a feature, but the exposure was just as real.

Exploitation

The researcher then worked through a series of steps to find out what the token could do. Each step answers a question, and each answer decides what to try next.

Step 1: check whether the token is valid

The first question: is this token real and still working, or is it an old one that has been cancelled? The researcher asked GitHub directly:

Bash
curl -H "Authorization: token $GH_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/user

Line by line:

  • curl is the tool sending the request.
  • -H "Authorization: token $GH_TOKEN" adds a header called Authorization. Its value is the word token followed by the token itself. $GH_TOKEN means "the value stored in the variable called GH_TOKEN", which is the token taken from the .env file. This header is how you tell GitHub who you are.
  • -H "Accept: application/vnd.github.v3+json" adds a second header called Accept. It tells GitHub which version of the API and which response format is wanted: version 3, in JSON (a common text format for structured data).
  • https://api.github.com/user is the endpoint being called. The /user endpoint answers the question "who is the person making this request?".

The response came back with the authenticated user, which confirmed the token was valid. In other words, GitHub accepted the key and said who it belonged to.

Why this step: before doing anything else, you need to know whether the key works. If it had been revoked, the request would have failed and there would be nothing more to investigate.

Step 2: find which organisations the token belongs to

Next question: which groups does this person belong to? On GitHub, a group of people and repositories is called an organisation. The researcher called this endpoint:

Text
/user/orgs

This endpoint lists the organisations that the authenticated user is a member of. Among the results was the Shopify organisation.

Why this step: a valid token on its own does not tell you how much it can reach. Knowing which organisation it belongs to tells you whose code might be at risk.

Step 3: confirm the scope of access

The next question: what can this token actually do inside that organisation? The researcher listed the organisation's repositories:

Text
/orgs/Shopify/repos

This endpoint returns the repositories belonging to the Shopify organisation. The response contained both public and private Shopify repositories. Each repository came with a permissions object like this:

JSON
"permissions": {"admin": false, "push": true, "pull": true}

What each part means:

  • "admin": false means the token does not have administrator rights over the repository. It cannot change settings or delete the repository.
  • "push": true means the token can send changes into the repository. In everyday terms, it can write to the code.
  • "pull": true means the token can read the code out of the repository.

So the token could read and write to Shopify's repositories, including private ones. In principle, someone holding it could push changes of their own choosing into the code, which the researcher describes as potentially allowing backdoors to be planted.

Why this step: this is the step that turns "a leaked key" into "a serious problem". Reading private code is bad; writing to it is worse, because changes pushed into a repository can end up in the software that Shopify ships.

Step 4: prove the access with a concrete artefact

A report is more convincing if it contains something the company can check for itself. The researcher pointed to a specific repository, a specific commit, and the fingerprint of a specific file:

Text
github.com/Shopify/shopify at commit hash cea9c273391d

At that commit, the SHA-512 of README.md is:

Text
[redacted]

What this means:

  • github.com/Shopify/shopify names a repository.
  • commit hash cea9c273391d names one saved snapshot of that repository.
  • SHA-512 is a hashing function. It takes a file and produces a long fingerprint. The string above is the fingerprint of the README.md file at that snapshot.

Why this step: a hash proves that the researcher could read the file, without the researcher having to copy the file into the report. The company can recompute the hash and compare it, and if it matches, the claim is verified.

Root cause

The token was sitting in a .env file that had been packed into the app.asar archive of a public release. The application's own code never read that file, so it was most likely a leftover from the release build process that was not removed before packaging. Because the archive is distributed publicly, the secret was effectively published to the world. On top of that, the token itself had push and pull rights across the organisation's repositories, so one leaked value carried broad write access.

Impact

As the researcher put it, the token gave read and write access to all of Shopify's private GitHub repositories. The permissions returned by the API were push and pull, without admin. With push access, an attacker could modify repository contents, which the researcher describes as potentially allowing backdoors to be placed.

The programme's summary states that the token was revoked immediately when the report was validated, and that an audit of access logs confirmed no unauthorised activity had occurred. In plain terms: the key was cancelled straight away, and the company checked its records of who accessed what and found no sign that anyone had misused it.

Fix

What the programme did is stated: the token was revoked as soon as the report was validated, and access logs were audited. The report does not describe any change to the build or release process.

The general lesson is to keep credentials out of build artefacts entirely, and to give tokens narrow permissions rather than organisation-wide push and pull. A token that can only read one repository is far less dangerous if it leaks than one that can write to everything.

Variants to test

These are the same ideas applied more widely, for anyone who wants to look for similar problems.

  1. Unpack app.asar from other public Electron apps and search the unpacked files for .env files and for variable names such as GH_TOKEN, AWS_, STRIPE_ and similar. A positive result is a file that the application's source never references, which suggests a build leftover.
  2. Check whether the application loads the configuration file at runtime. If the source never reads it, the file is more likely to be a packaging mistake than a deliberate feature.
  3. For any token found, call the identity endpoint first, then the organisation and repository listing endpoints, and record the permissions object for each repository. A positive result is push: true on private repositories.
  4. Prove read access with a stable artefact such as a file hash at a named commit, rather than by making any change.

Hunting notes

This kind of bug hides in distributed client artefacts: desktop apps, mobile packages and anything else that ships a bundle to users. During recon, public release downloads and their unpacked contents are worth inspecting, and a .env file that the application code never references is a strong signal.

The researcher established impact in stages: validity of the token, membership of the organisation, the exact permissions on repositories, and finally a verifiable read of a specific file at a specific commit.

Glossary

  • API (Application Programming Interface): a way for one program to ask another program for data or actions over the internet, by sending requests to specific addresses.
  • app.asar: the archive file that holds the code and assets of an Electron desktop application; anyone who downloads the app can unpack it.
  • Bug bounty programme: a scheme where a company pays people for finding and reporting security problems in its systems.
  • Commit: a saved snapshot of a repository at a particular moment, identified by a commit hash.
  • Commit hash: the short identifier for a commit, such as cea9c273391d.
  • Critical: the most severe rating for a security flaw.
  • curl: a command-line tool for sending requests to web addresses and printing the responses.
  • CVSS: a standard scoring system for the severity of security flaws, from 0 to 10.
  • .env file: a small text file holding settings, and sometimes secrets, as name and value pairs.
  • Electron: a tool for building desktop applications with web technology, which packs the app into an app.asar archive.
  • Endpoint: a specific web address in an API that answers a particular kind of question.
  • Hash (SHA-512): a long fingerprint produced from a file's contents; any change to the file changes the fingerprint.
  • Header: an extra piece of information attached to a request, such as who is sending it or what answer is wanted.
  • JSON: a common text format for structured data, used in API responses.
  • Node.js: a runtime for running JavaScript outside a browser; npx and the asar tool come from its ecosystem.
  • npx: a command that runs Node.js tools without installing them permanently.
  • Organisation: a group of people and repositories on GitHub, such as Shopify's.
  • Personal Access Token (PAT): a long string of characters that works like a password for GitHub; whoever holds it is treated as the person who created it.
  • Permissions object: the part of a GitHub API response that says what a token can do with a repository, such as admin, push and pull.
  • Private repository: a repository that only people with permission can see.
  • Public repository: a repository that anyone can see.
  • Pull: reading code out of a repository.
  • Push: sending changes into a repository.
  • Repository (repo): a collection of code files for one project.
  • REST API: an API style where you send requests to specific web addresses and get data back.
  • Revoke: to cancel a token so that it no longer works.
  • SHA-512: the specific hashing function used to produce the file fingerprint in this report.
  • Token: see Personal Access Token.

More from Shopify

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.