Skip to content
Leaked secrets Write-up Beginner

API secret key Leakage leads to disclosure of Employee’s Information

A JavaScript file on an employee sign-in subdomain contained a Base64-encoded BambooHR API key. The finder used it to dump the employee list and to view, update and delete employee records through the vendor's API.

Ace Candelario Follow

Published on medium.com

Bounty$2,000 View original

Ace Candelario

Ace Candelario, on medium.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. 5 min read.

Context

The target was a site the author calls redacted.com, found through Google Dorking while looking for something sensitive to test. The interesting part of the target was a subdomain, [redacted].redacted.com, which presents a Sign-In tab for employees and redirects to Google for authentication. In other words, the dashboard behind it is meant to be reachable only by someone holding a valid @redacted.com email address, or by an employee.

The bug is an information disclosure: an API key for the company's BambooHR account was embedded in the front-end JavaScript of that internal subdomain. BambooHR is an HR platform, and its API exposes employee records. The key was still valid, so it gave the author the same access to the HR tenant that a logged-in company user would have.

Setup

The author viewed the page source and found a single JavaScript file, main.js, without needing an account. The tools used were:

  • assetfinder for subdomain enumeration
  • httprobe to filter hosts that answer HTTP
  • get-title to print page titles
  • sort -u to deduplicate
  • curl to talk to the BambooHR API
  • the BambooHR API documentation, to work out the endpoints

The author wrapped the enumeration tools in a shell function:

Bash
quickie () { assetfinder -subs-only $1 | httprobe | get-title }

assetfinder -subs-only prints subdomains only, httprobe keeps the ones that respond over HTTP, and get-title fetches each page title so the output is readable at a glance.

Finding it

Step 1: enumerate subdomains

Running the function against redacted.com produced a list within about a minute. The first entry on the output stood out, and it was [redacted].redacted.com. The name is simple.

Step 2: look at the login page

Visiting the subdomain shows a Sign-In tab for employees, with authentication delegated to Google. To get into the dashboard you need a valid @redacted.com email or an employee account. Viewing the page source revealed that the page loads a single JavaScript file.

From the original on medium.com

Step 3: read the JavaScript

Opening main.js was the turning point: unlike most sites, the file was not minified. That makes it practical to read and to grep. The author's usual keyword list for this kind of review is company name, domain (for hidden or internal subdomains), file extensions, obvious API paths (for hidden endpoints), secret, access[_|-], access[k|t], api[_|-], [-|_]key, https: and http:. Searching the file for the company name, redacted, was enough.

**Drum rolls** From the original on medium.com

Exploitation

Step 1: identify the credential

The search turned up a Base64-encoded authentication credential. It turned out to be the company's BambooHR API key.

Step 2: confirm the key is live

The BambooHR API documentation is straightforward, so the author could quickly work out how to call it and verify that the leaked key still worked. Using curl against the BambooHR API endpoint, the employee list came back. The same key also allowed viewing, deleting, removing and updating existing employees. In effect it was equivalent to having a redacted.com login on bamboohr.com. The screenshot below is an example dump of employees returned by the API.

From the original on medium.com

Step 3: report and confirm the fix

The issue was submitted to the company. In under 24 hours the API key had been revoked, and the author confirmed the issue was fixed.

The author's closing advice: when you find a sensitive API key or secret, make sure you can actually use it and that it is not expired. Confirm that the key really discloses, updates, removes or deletes something. Read the vendor's documentation so you know what to do with it. And when hunting for credentials, be creative with your keywords.

Root cause

A BambooHR API key was present in the main.js file of the internal subdomain. Because the file is delivered to anyone who loads the page, the key was readable without authentication. The file was also not minified, which made the key easy to spot by grepping for the company name. The key was still working when the author tested it, and was revoked after the report. The report does not describe how the key came to be in the file or what review process, if any, existed.

Impact

Anyone who could reach the login page and read main.js could extract the key and use the BambooHR API as the company would. According to the report that meant reading the full employee list and also viewing, deleting, removing and updating existing employees. The key allowed dumping the employee list and viewing, deleting, removing and updating employees. The reward was $2,000, and the issue was High Severity.

Fix

The company revoked the API key, which the author retested and confirmed. The report does not describe any other change, such as removing the key from the JavaScript or restricting where the key can be used. The general lesson is that secrets should not be shipped to the browser at all; server-side code should hold them, and any key that has been exposed should be rotated.

Variants to test

  1. Unminified bundles on internal-looking subdomains. Run subdomain enumeration, keep hosts that answer, and fetch titles to spot login and dashboard pages. A positive result is a host such as internal. or smh. that serves its login page and JavaScript to an unauthenticated visitor.
  2. Keyword grep of front-end JavaScript. Download every script the login page loads and search for the company name, secret, access[_|-], access[k|t], api[_|-], [-|_]key, https: and http:. A positive result is a string that decodes to a credential or looks like a token.
  3. Base64 blobs. Decode any Base64-looking string you find. A positive result is a readable API key, username and password pair, or token.
  4. Third-party SaaS keys. When a key belongs to a SaaS provider, read that provider's documentation and make a read-only call first. A positive result is a successful authenticated response, such as a list of records, proving the key is live and privileged.
  5. Write capability check. Only where the program permits it, test whether the key allows modifying or deleting records. A positive result is a successful update or delete on a test record you control.

Timeline

  • February 5, 2020: report submitted; acknowledged the same day and triaged.
  • February 6, 2020: retest; the token had already been revoked.
  • February 11, 2020: reward of $2,000, High Severity.
  • February 13, 2020: reward received.

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

What happened, in plain words

A security researcher found a website (called redacted.com here) that had a hidden internal page for employees. That page loaded a JavaScript file, which is code your browser downloads and runs. Inside that file was a secret key for the company's HR system, BambooHR. The key was in the JavaScript file, which the author could read. With that key, the researcher could use BambooHR's API (a way for programs to talk to a service) to see the list of employees and even change or delete records. The company fixed it by cancelling the key, and paid a $2,000 reward.

This is called an information disclosure: private information (here, a secret key) was exposed to people who should not have it. The key was in the browser-side code.

Background: what is an API and what is a key?

An API (Application Programming Interface) is a set of rules that lets one program ask another program for data or actions. Think of it as a waiter in a restaurant: you (a program) tell the waiter what you want from the kitchen (the service), and the waiter brings it back. You do not go into the kitchen yourself.

A key (often called an API key or token) is like a password that a program uses to prove to the API that it is allowed to ask. If someone else gets your key, they can pretend to be you and ask the API for the same things you can.

BambooHR is a service (software as a service, SaaS) that companies use to store employee records: names, contact details, job information and so on. It has an API so that other software can read and update those records. The company in this report had a BambooHR account, and the API key for that account was the secret that leaked.

JavaScript is the programming language that web pages use to make things happen in your browser. When you visit a page, your browser downloads JavaScript files and runs them. Anything written in those files is visible to anyone who looks, because the browser has to receive the file to run it. That is why secrets should never be placed in JavaScript that is sent to the browser.

Base64 is a way of writing data using only letters, digits and a couple of symbols. It is not encryption; it is just a different alphabet, like writing a message in Morse code. Anyone can decode it back to the original. A Base64 string often looks like a long jumble of characters ending with = or ==.

Subdomain: a domain name can have parts in front of it, like shop.example.com or mail.example.com. Each of those is a subdomain. Companies often use subdomains for internal tools, and sometimes those are not meant to be public.

Google Dorking means using advanced search operators in Google (like site: or inurl:) to find pages that are not linked from anywhere obvious. The researcher used it to find a site worth testing.

The tools used

The researcher used four command-line tools. You do not need to install them to follow the story, but here is what each does:

  • assetfinder: given a domain, it lists subdomains that are known publicly (from certificate logs, search engines and other sources).
  • httprobe: takes a list of hostnames and checks which ones actually respond to web requests (HTTP or HTTPS).
  • get-title: for each responding host, it fetches the page and prints its title, so you can guess what the page is.
  • sort -u: sorts lines and removes duplicates.
  • curl: a command-line tool to send requests to a web server or API and print the response.

The researcher put the first three together in a shell function (a reusable command):

Bash
quickie () { assetfinder -subs-only $1 | httprobe | get-title }

Line by line:

  • quickie () { ... } defines a function named quickie. You call it later by typing quickie example.com.
  • assetfinder -subs-only $1 runs assetfinder on the domain you passed as the first argument ($1). The -subs-only flag tells it to print only subdomains, not the main domain or other findings.
  • | is a pipe: it takes the output of the command on the left and feeds it as input to the command on the right.
  • httprobe reads hostnames and prints only those that answer a web request.
  • | get-title again pipes the surviving hosts into get-title, which prints each page's title.

Why this step? The goal is to find parts of the company's infrastructure that are reachable from the internet but perhaps forgotten. A login page on an internal-sounding subdomain is a good candidate for a closer look.

Finding the target

Step 1: enumerate subdomains

The researcher ran the function against redacted.com. Within about a minute, a list appeared. The first entry stood out: [redacted].redacted.com. The word internal in the name suggests it is not meant for public use, which makes it interesting.

The image shows the output of the enumeration command, with that subdomain at the top.

Step 2: look at the login page

Visiting [redacted].redacted.com shows a Sign-In tab for employees. The authentication is handled by Google: you are redirected to Google to sign in, and only a valid @redacted.com email address (or an employee account) gets you into the dashboard behind it.

Even without logging in, the researcher viewed the page source (in a browser, right-click and choose "View Page Source", or press Ctrl+U). The source showed that the page loads a single JavaScript file.

From the original on medium.com

Why this matters: the login page itself is public. If it loads a JavaScript file, that file is also public, because the browser must download it to run it. Any secret inside it is therefore public too.

Step 3: read the JavaScript

The researcher opened the JavaScript file, named main.js. The surprise was that it was not minified. Minification is a process that removes spaces, line breaks and shortens variable names to make a file smaller. Minified code is hard for humans to read. This file was readable, which made searching it practical.

The researcher had a list of keywords to search for in JavaScript files:

  • the company name
  • the domain (to find hidden or internal subdomains)
  • file extensions
  • obvious API paths (to find hidden endpoints)
  • secret
  • access[_|-]
  • access[k|t]
  • api[_|-]
  • [-|_]key
  • https:
  • http:

These are patterns: for example, access[_|-] matches access_ or access-, and [-|_]key matches -key or _key. They are common ways programmers name secret values.

Searching for the company name, redacted, was enough to find something.

**Drum rolls** From the original on medium.com

Exploitation: using the key

Step 1: identify the credential

The search found a Base64-encoded authentication credential. It turned out to be the company's BambooHR API key.

Why this step? A Base64 string is not secret by itself; it is just encoded. Decoding tells you what it actually is, so you know which service it belongs to and how to use it.

Step 2: confirm the key is live

The researcher read the BambooHR API documentation. Documentation explains which URLs (endpoints) to call, what headers or parameters to send, and what the response looks like. With that, the researcher used curl to call the BambooHR API and check whether the key still worked.

The call returned the employee list. The same key also allowed viewing, deleting, removing and updating existing employees. In effect, it was like having a redacted.com login on bamboohr.com.

From the original on medium.com

The image shows an example dump of employees returned by the API.

Why this step? Finding a key is not enough; you must show that it is valid and that it gives access to something sensitive. A key that is expired or has no permissions is not a vulnerability. The researcher's advice is exactly this: make sure the key works and that it discloses, updates, removes or deletes something. Always read the vendor's documentation so you know what to do with the key.

Step 3: report and confirm the fix

The researcher submitted the issue to the company. In less than 24 hours, the company had revoked the API key (cancelled it so it no longer works). The researcher retested and confirmed the issue was fixed.

Root cause

A BambooHR API key was present in the main.js file of the internal subdomain. Because the file is delivered to anyone who loads the page, the key was readable without authentication. The file was also not minified, which made the key easy to spot by searching for the company name. The key was still working when the author tested it, and was revoked after the report. The report does not describe how the key came to be in the file or what review process, if any, existed.

Impact

Anyone who could reach the login page and read main.js could extract the key and use the BambooHR API as the company would. According to the report, that meant reading the full employee list and also viewing, deleting, removing and updating existing employees. The key allowed dumping the employee list and viewing, deleting, removing and updating employees. The reward was $2,000, and the issue was High Severity.

Fix

The company revoked the API key, which the author retested and confirmed. The report does not describe any other change, such as removing the key from the JavaScript or restricting where the key can be used. The general lesson is that secrets should not be shipped to the browser at all; server-side code should hold them, and any key that has been exposed should be rotated.

Variants to test

  1. Unminified bundles on internal-looking subdomains. Run subdomain enumeration, keep hosts that answer, and fetch titles to spot login and dashboard pages. A positive result is a host such as internal. or smh. that serves its login page and JavaScript to an unauthenticated visitor.
  2. Keyword grep of front-end JavaScript. Download every script the login page loads and search for the company name, secret, access[_|-], access[k|t], api[_|-], [-|_]key, https: and http:. A positive result is a string that decodes to a credential or looks like a token.
  3. Base64 blobs. Decode any Base64-looking string you find. A positive result is a readable API key, username and password pair, or token.
  4. Third-party SaaS keys. When a key belongs to a SaaS provider, read that provider's documentation and make a read-only call first. A positive result is a successful authenticated response, such as a list of records, proving the key is live and privileged.
  5. Write capability check. Only where the program permits it, test whether the key allows modifying or deleting records. A positive result is a successful update or delete on a test record you control.

Timeline

  • February 5, 2020: report submitted; acknowledged the same day and triaged.
  • February 6, 2020: retest; the token had already been revoked.
  • February 11, 2020: reward of $2,000, High Severity.
  • February 13, 2020: reward received.

Glossary

  • API: a set of rules that lets one program ask another program for data or actions, like a waiter taking your order to the kitchen.
  • API key: a secret string that a program uses to prove to an API that it is allowed to make requests; like a password for software.
  • assetfinder: a command-line tool that lists subdomains of a domain.
  • Base64: an encoding that turns data into letters, digits and a few symbols; it is not encryption and anyone can decode it.
  • BambooHR: a cloud service that companies use to store employee records.
  • Client-side: code that runs in the user's browser, as opposed to server-side code that runs on the company's servers.
  • curl: a command-line tool for sending requests to web servers and APIs.
  • Endpoint: a specific URL of an API that performs a particular action, such as listing employees.
  • get-title: a tool that fetches a web page and prints its title.
  • Google Dorking: using advanced search operators in Google to find pages that are not easily found otherwise.
  • httprobe: a tool that checks which hostnames respond to web requests.
  • Information disclosure: a vulnerability where private information is exposed to people who should not have it.
  • JavaScript: the programming language that web pages use to run code in your browser.
  • Key (token): see API key.
  • Minification: removing spaces, line breaks and shortening names in code to make the file smaller; minified code is hard to read.
  • SaaS: software as a service; software that you use over the internet instead of installing it.
  • sort -u: a command that sorts lines and removes duplicates.
  • Subdomain: a part of a domain name in front of the main domain, like shop.example.com.
  • Token: another word for a key or credential used by software.
  • Vulnerability: a weakness in a system that allows someone to do something harmful or unintended.

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.