Skip to content
Misconfiguration Write-up Beginner

My debut with a Critical Bug: How I found my first bug (API misconfiguration)

An API key with dangerous permissions was exposed in a JavaScript file. An attacker could use it to add or delete objects, potentially bringing down a blog site.

whit3ros3 Follow

Published on medium.com

{{media:0}}

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

Context

The target was an e-commerce website, referred to throughout the write-up as "example.com". The feature at the centre of the finding is the site's blog, which is served through Contentful and searched through Algolia. The Algolia host the researcher later focused on is reached at https://(application_id).algolianet.com, where (application_id) stands in for the real application identifier.

Nothing in the report describes the site's authentication model, user roles or the application's own endpoints. The whole finding lives in the JavaScript the site ships to browsers and in the Algolia API keys those files expose.

Setup

The researcher worked with a small toolchain and no special access:

  • gau to collect known URLs for the domain.
  • grep to filter those URLs down to JavaScript files.
  • httpx to keep only the ones that answered with HTTP 200.
  • VS Code, to read the downloaded JavaScript comfortably.
  • Burp Suite, to review the requests already recorded against the target.

The only precondition was a target whose JavaScript bundles reference third-party services. No account, role or credential was needed to reach the files.

Finding it

After a couple of days of unsuccessful attempts at login bypass, XSS and subdomain takeover, the researcher changed approach after reading a Medium post in which another researcher found sensitive data inside JavaScript files. The plan was to enumerate the target's JavaScript and read it.

The enumeration command was:

Bash
echo "example.com" | gau | grep .js | httpx -mc 200

gau supplies historical URLs for the domain, grep .js keeps the JavaScript ones, and httpx -mc 200 filters to those that currently respond with 200. The result was a large number of JS files. One of them looked suspicious, so its contents were copied into VS Code to be read more easily.

Inside that file the researcher found what the write-up calls intriguing data: Algolia and Contentful API keys, plus further sensitive data. The report does not reproduce the file or the key values.

As a beginner, the researcher did not know how to use the keys, so the next phase was research: Google, ChatGPT, GitHub repositories, blog posts and mentor friends. Most of it led nowhere. The Algolia key found in the JavaScript belonged to the blog site and carried only recommendation and search permissions, so it was not exploitable. The other secrets led to publicly accessible data, such as the content of the target's blog hosted on contentful.com. That was the first dead end.

On the brink of abandoning the target for the second time, the researcher went through the target list in Burp Suite looking for something interesting, a tip picked up from another blog. One host stood out:

Text
https://(application_id).algolianet.com

Inspecting the requests made to that host revealed the useful detail: some requests used the same API key found in the JavaScript file, while others carried a different API key. That difference is what made the host worth a second look.

Exploitation

Step 1: Compare the keys used against the Algolia host

In Burp Suite, the requests to https://(application_id).algolianet.com were reviewed side by side. Two distinct API keys appeared: the one already recovered from the JavaScript, and a different one. The report does not show the individual requests or their headers.

Step 2: Read up on the class of bug

The researcher returned to a previously read article to understand what to do with the second key:

Text
https://www.secjuice.com/api-misconfiguration-data-breach/

Step 3: Check the permissions of the new key

Using that knowledge, the researcher explored the permissions attached to the newly discovered key. The result was the turning point: the key had permissions to add and delete objects. The report does not show the permission-check request or its response, only the conclusion drawn from it.

No add or delete operation was actually attempted, because the researcher feared breaking the site. The dangerous permissions were enough to justify a report, which was submitted.

Root cause

The report frames the issue as an API misconfiguration: an Algolia API key with write permissions (add and delete objects) was seen in requests the browser made to the Algolia host. The key found in the JavaScript was scoped to recommendation and search, while the second key seen in traffic had add and delete permissions.

Impact

The researcher describes the permissions as dangerous and states that this kind of bug can bring a whole blog site down. Because no write operation was performed, the impact is described rather than demonstrated.

Fix

The implied fix is to stop shipping a write-capable Algolia key to clients and to keep keys with add and delete permissions on the server, exposing only search and recommendation keys to the browser.

Variants to test

  1. Enumerate JavaScript with the same pipeline and read every bundle for third-party keys. A positive result is a key for a service the site actually uses, not a placeholder or a public demo key.
  2. Take each key found in JavaScript and check its scope against the service's own permission or ACL endpoint. A positive result is a key whose scope exceeds read-only search, for example one that can add, update or delete objects.
  3. Review Burp history for hosts belonging to those third-party services and compare the keys in their requests with the keys in the JavaScript. A positive result is a key in traffic that never appeared in any bundle, which suggests a separate and possibly more privileged credential.
  4. For each key, confirm whether the data it reaches is genuinely public before reporting. A positive result is access to non-public content or the ability to change state, not a read of the same blog content anyone can see.

Timeline

The report was submitted, triaged as high severity within a day, and updated to critical after a few days.

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

What happened, in plain words

A security researcher found secret keys inside the code that a shopping website sends to every visitor's browser. One of them, seen in the site's traffic, could be used to add or delete objects. The researcher reported it, and the website's security team first rated it high severity, then later raised it to critical. This article explains the whole story step by step, assuming you know nothing about security.

Background: what is an API and why keys matter

An API (Application Programming Interface) is a way for two pieces of software to talk to each other. Think of it like a waiter in a restaurant: you (the website) tell the waiter (the API) what you want, and the waiter brings it from the kitchen (the service). Many websites use third-party APIs for things like search or content management, so they don't have to build everything themselves.

To use an API, the website needs a key (sometimes called an API key or token). This is like a password that identifies the website to the API service. The key often comes with permissions that define what the website is allowed to do: for example, only read data, or also add and delete data.

The problem in this story is that a key with dangerous permissions (add and delete) was seen in the requests the browser made to the Algolia host. Anyone could find it and use it.

The target

The researcher was looking at an e-commerce website, which they call "example.com" in the write-up. The specific feature involved is the site's blog, which is built using two services: Contentful (a content management system) and Algolia (a search service). The Algolia service is accessed at a host like https://(application_id).algolianet.com, where (application_id) is a unique identifier for the site's Algolia account.

The tools used

The researcher used a few simple tools, all of which are free and commonly used by security testers:

  • gau: a command-line tool that collects known URLs for a domain from public sources.
  • grep: a standard command-line tool to search text; here it filters URLs containing ".js".
  • httpx: a tool that checks which URLs are alive (return HTTP status 200).
  • VS Code: a code editor, used to read the JavaScript files comfortably.
  • Burp Suite: a tool that records and lets you inspect the requests your browser makes to a website.

No special access or account was needed; everything was public.

Finding the JavaScript files

After trying some common attacks (like login bypass, XSS, and subdomain takeover) without success, the researcher read a blog post by another researcher who found sensitive data in JavaScript files. Inspired, they decided to look at the JavaScript files of their target.

The command they used was:

Bash
echo "example.com" | gau | grep .js | httpx -mc 200

Let's break this down line by line (it's a single line, but we'll explain each part):

  • echo "example.com": prints the domain name. This is just a way to feed the domain into the next command.
  • | (pipe): takes the output of the previous command and passes it as input to the next.
  • gau: takes the domain and returns a list of known URLs for that domain (from public sources like the Wayback Machine).
  • | grep .js: filters that list to only URLs that contain ".js" (JavaScript files).
  • | httpx -mc 200: checks each URL and keeps only those that respond with HTTP status code 200 (OK). This ensures the files are still accessible.

The result was a large number of JavaScript files. One of them looked suspicious, so the researcher copied its contents into VS Code to read it more easily.

What was inside the JavaScript file

Inside that file, the researcher found what they call "intriguing data": API keys for Algolia and Contentful, plus other sensitive data. The report does not show the actual file or the key values.

whit3ros3
whit3ros3 From the original on medium.com

As a beginner, the researcher didn't know how to use these keys, so they started researching: Googling, asking ChatGPT, looking at GitHub repositories, reading blogs, and consulting mentor friends. Most of this led nowhere. The Algolia key found in the JavaScript was for the blog site and only had permissions for recommendation and search, so it wasn't dangerous. The other secrets led to publicly accessible data, like the content of the blog hosted on contentful.com. That was a dead end.

The turning point: Burp Suite history

On the brink of giving up, the researcher looked through the target list in Burp Suite, searching for something interesting (a tip from another blog). One host stood out:

Text
https://(application_id).algolianet.com

This is the Algolia API host for the site. When inspecting the requests made to this host, the researcher noticed something: some requests used the same API key found in the JavaScript file, while others used a different API key. That difference was the key insight.

Understanding the bug class

The researcher went back to a previously read article to understand what to do with the second key:

Text
https://www.secjuice.com/api-misconfiguration-data-breach/

This article explains API misconfiguration, a type of vulnerability where an API is set up in an insecure way, for example by exposing too much data or allowing actions that shouldn't be allowed.

Checking the permissions of the new key

Using that knowledge, the researcher explored the permissions of the newly discovered key. The result was the "Eureka moment": the key had permissions to add and delete objects. The report does not show the permission-check request or its response, only the conclusion.

The researcher did not actually try to add or delete anything, fearing it might break the site. But the dangerous permissions were enough to justify a report, which was submitted.

Why this is a problem

The issue is an API misconfiguration: an Algolia API key with write permissions (add and delete objects) was seen in the requests the browser made to the Algolia host. The key found in the JavaScript was scoped to recommendation and search, while the second key seen in traffic had add and delete permissions.

Impact

The researcher describes the permissions as dangerous and states that this kind of bug can bring a whole blog site down. Because no write operation was performed, the impact is described rather than demonstrated.

Fix

The implied fix is to stop shipping a write-capable Algolia key to clients and to keep keys with add and delete permissions on the server, exposing only search and recommendation keys to the browser.

Variants to test

  1. Enumerate JavaScript with the same pipeline and read every bundle for third-party keys. A positive result is a key for a service the site actually uses, not a placeholder or a public demo key.
  2. Take each key found in JavaScript and check its scope against the service's own permission or ACL endpoint. A positive result is a key whose scope exceeds read-only search, for example one that can add, update or delete objects.
  3. Review Burp history for hosts belonging to those third-party services and compare the keys in their requests with the keys in the JavaScript. A positive result is a key in traffic that never appeared in any bundle, which suggests a separate and possibly more privileged credential.
  4. For each key, confirm whether the data it reaches is genuinely public before reporting. A positive result is access to non-public content or the ability to change state, not a read of the same blog content anyone can see.

Timeline

The report was submitted, triaged as high severity within a day, and updated to critical after a few days.

Glossary

  • API: Application Programming Interface; a way for software to communicate with other software.
  • API key: a secret token used to authenticate to an API.
  • Permissions: rules that define what an API key is allowed to do.
  • JavaScript: a programming language used to make web pages interactive; files with .js extension.
  • gau: a tool that fetches known URLs for a domain from public sources.
  • grep: a command-line tool for searching text.
  • httpx: a tool for checking HTTP responses.
  • Burp Suite: a tool for intercepting and inspecting web traffic.
  • Contentful: a content management system (CMS) for managing digital content.
  • Algolia: a search-as-a-service platform.
  • API misconfiguration: a security flaw where an API is set up insecurely, e.g. exposing sensitive data or allowing unintended actions.
  • XSS: Cross-Site Scripting, a type of vulnerability where attackers inject malicious scripts into web pages.
  • Subdomain takeover: a vulnerability where an attacker takes control of a subdomain.
  • Login bypass: a vulnerability that allows bypassing authentication.
  • Severity: a rating of how serious a vulnerability is (e.g. low, medium, high, critical).
  • Triaged: the process of reviewing and assigning a severity to a reported vulnerability.

More by whit3ros3

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.