The OAuth2 Secret That Was Never Supposed to Leave the Server —
A live OAuth2 client secret was hardcoded in a public client-side JavaScript bundle and was wired to the organisation's AWS Cognito identity provider. An attacker who found it could authenticate against Cognito's token endpoint and obtain a valid token, though the text does not say what that token allowed beyond the secret's scopes.
Cybersecurity
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.
Context
This is a write-up about a hardcoded OAuth2 client_secret found in plain text inside a large organisation's public-facing client-side code, wired into their AWS Cognito identity infrastructure. The organisation is not named, and the value, the file path and the discovery technique are deliberately withheld. The author describes the target only as infrastructure serving a large user base, built by teams that presumably run security reviews and CI/CD scanning.
The feature involved is OAuth2 client authentication. A client secret exists to answer one question: is this request really coming from an application I trust? That trust model only works if the secret stays where only the trusted party can see it, never shipped to a browser or a mobile binary. Once it crosses that line it stops being a secret and becomes a public value with a misleading name.

Setup
There is no special setup described. The researcher was doing routine recon through public client-side bundles, the kind of review anyone doing web recon or frontend review can perform with a browser's network tab or a basic app-unpacking tool. No accounts, roles, tool versions or preconditions are given.
Finding it
The starting point was scrolling through a minified JavaScript bundle and noticing a string that did not look like the rest: not a variable name, not a class hash, but a value, long and opaque, shaped exactly like something that is supposed to be secret. There was no obfuscation and no environment-variable indirection.

Top: the secret never leaves the backend. Bottom: it rode along in a client-accessible bundle, reachable by anyone with a browser's network tab or a basic app-unpacking tool.
The string's shape and entropy read like a real credential, and the surrounding context pointed at Cognito's token endpoint. At that stage it was only a candidate: plenty of credential-shaped strings turn out to be stale test values or documentation placeholders.

Exploitation
Step 1: Identify the candidate
Routine recon through public client-side bundles surfaced a long, opaque string in a minified bundle, with context pointing at Cognito's token endpoint. Nothing was sent at this point; the value was treated as a candidate only.
Step 2: Verify the credential is live
The real work was verification: confirming the value could successfully authenticate against Cognito's token endpoint, proving it was live, trusted infrastructure rather than a rotated or dead credential. The response came back with a valid token, proof that the secret was not dead weight from an old deployment but an active credential the identity provider still trusted.
Step 3: Map the scopes
From there the researcher mapped exactly what the secret's scopes allowed, without exercising anything beyond what was needed to confirm impact, and reported it through the program's disclosure process.
The report does not include the request, the response body, the endpoint URL or the scope list.
Root cause
Nobody sits down and decides to expose a secret. It happens gradually: a quick prototype wires it in "just for now", a build script bundles a config file that was never meant to leave the repo, or a mobile app embeds a credential to skip a round trip. The code works, the tests pass, nothing looks broken, and it ships.
The report gives three reasons the pattern persists at scale:
- Secrets do not announce themselves in a diff the way a logic bug does.
- Automated scanners catch known formats far more reliably than custom ones, and often only run against source repos, not shipped build artifacts.
- "Temporary" code has a way of becoming permanent because nobody owns removing it before release.
The author frames this as a systems problem rather than a competence problem, and notes that the organisation was not a small product: it was infrastructure serving a large user base, built by teams that presumably run security reviews and CI/CD scanning, and the secret still shipped client-accessible. The report does not say which specific control failed.
Impact
Because the secret authenticated successfully against Cognito's token endpoint, it was an active credential the identity provider still trusted. The researcher mapped what the secret's scopes allowed, without exercising anything beyond what was needed to confirm impact. The report does not state the scopes, the affected users or any concrete abuse performed; the researcher deliberately exercised nothing beyond what was needed to confirm impact. The value, the file path and the organisation are withheld.
Fix
It states that the fix is not a smarter WAF rule or a better scanner, but treating "what does the client actually receive" as a first-class security question every time something ships.

Variants to test
- Minified frontend bundles. Look through shipped JavaScript for long, high-entropy strings whose surrounding context points at an identity provider's token endpoint. A positive result is a value whose surrounding context points at an identity provider's token endpoint.
- Mobile binaries. Unpack the app and look for embedded credentials added to skip a round trip. A positive result is a credential that authenticates against the provider.
A positive result is a live token rather than an error for a rotated or dead credential.
Anyone can grep a bundle for suspicious strings. Separating a real, exploitable secret from noise, without touching anything beyond what is needed to prove the point, is what separates a useful report from a false-positive ticket.
What happened, in plain words
A security researcher was looking through the code that a large organisation sends to every visitor's web browser. This code is called a JavaScript bundle: it is the program that makes a website interactive, and your browser downloads it automatically when you open the site. Anyone can read it, because it has to arrive on your computer to run.
Inside that code, the researcher found a long, random-looking string of characters. It was not a label or a name. It was a password-like value called an OAuth2 client_secret, and it was sitting there in plain text, with no attempt to hide it. That secret was connected to the organisation's login system, which is built on a service called AWS Cognito.
A secret like this is meant to stay on the organisation's own servers, where visitors can never see it. Instead it was shipped out to every browser that loaded the site. The researcher then checked whether the secret still worked. It did: the login system accepted it and handed back a valid token. The researcher reported the problem through the organisation's disclosure process. The organisation is not named, and the secret value, the file path and the exact discovery method are deliberately left out.

The background: what OAuth2 and a client secret are
Before the details, a few ideas from zero.
An API is a way for one piece of software to talk to another. Think of a restaurant: you do not walk into the kitchen, you tell the waiter what you want and the waiter brings it. An API is the waiter. Your browser asks a server for something, and the server answers.
OAuth2 is a standard way for applications to prove who they are and to get permission to use an API. It is the system behind many "Log in with..." buttons. In OAuth2 there are two sides: a client (the application asking for access) and an authorisation server (the service that decides whether to grant it).
A client secret is a password that the client application uses to prove to the authorisation server that it really is that application. The secret exists to answer one question: is this request really coming from an application I trust?
That question only has a useful answer if the secret stays where only the trusted party can see it. The trusted party here is the organisation's own backend, the servers it controls. A secret must never be shipped to a browser or packed inside a mobile app, because anything that reaches a browser or a phone can be read by the person using it.
The moment a secret crosses that line, it stops being a secret. It becomes a public value with a misleading name.

The image contrasts two situations. On top, the secret stays on the backend and never leaves. On the bottom, it travelled inside a bundle that any client can access, so anyone with a browser's network tab or a basic app-unpacking tool can reach it.
AWS Cognito is Amazon's identity service: a ready-made system that organisations use to handle sign-ups, logins and tokens. It has a token endpoint, which is a specific address on the server where an application sends its credentials and, if they are correct, receives a token back.
A token is a temporary pass. Once the login system is satisfied that you are who you say you are, it gives you a token, and you show that token on later requests instead of your password. It is like a wristband at an event: you show it at the door once you are inside, and you do not have to prove your identity again each time.
Why this is so easy to miss
Nobody sits down and decides to expose a secret. It happens gradually. A quick prototype wires it in "just for now". A build script bundles a configuration file that was never meant to leave the repository. A mobile app embeds a credential to skip a round trip to the server. The code works, the tests pass, nothing looks broken, and it ships.
That is the core of this bug class. It does not look like a vulnerability. It looks like configuration.
How the finding came together
Bug hunting does not feel like discovery in the moment. It feels like elimination. Most leads turn out to be false positives, and the real work is verification, not the first spot.

The researcher was doing routine reconnaissance, which simply means looking around a target's public material to see what is exposed. The material here was public client-side bundles: the JavaScript files that any visitor's browser downloads. No special setup is described, no accounts, no particular tools or versions. The same review can be done with a browser's network tab, which shows every file a page loads, or with a basic tool that unpacks an app.
While scrolling through a minified bundle, the researcher noticed a string that did not look like the rest. Minified means the code has been squashed to save space: variable names are shortened, whitespace is removed, and the result is hard for a human to read. In that wall of compact text, this string stood out. It was not a variable name and not a class hash. It was a value, long and opaque, shaped exactly like something that is supposed to be secret. There was no obfuscation, meaning no deliberate attempt to disguise it, and no environment-variable indirection, meaning it was not fetched from a separate settings file at runtime. It was just there.
Its shape and randomness, its entropy, read like a real credential. Entropy here means how unpredictable a string looks: a real secret is generated randomly, so it has no pattern, while a placeholder like changeme or example123 looks like words. The surrounding code pointed at Cognito's token endpoint. At that stage it was only a candidate. Plenty of credential-shaped strings turn out to be stale test values or documentation placeholders.
Exploitation, step by step
Step 1: Identify the candidate
Routine reconnaissance through public client-side bundles surfaced a long, opaque string in a minified bundle, with context pointing at Cognito's token endpoint. Nothing was sent at this point. The value was treated as a candidate only.
Why this step matters: finding a suspicious string is cheap. Anyone can search a bundle for words like secret or client_secret. What you have at the end of this step is a guess, not a finding. Sending nothing yet is deliberate: you do not want to poke a live system until you understand what you are holding.
Step 2: Verify the credential is live
The real work was verification: confirming the value could successfully authenticate against Cognito's token endpoint. That would prove it was live, trusted infrastructure, rather than a rotated or dead credential. Rotated means the organisation has replaced an old secret with a new one, so the old value no longer works. Dead means it was never valid or has been switched off.
The response came back with a valid token. That was proof the secret was not dead weight from an old deployment, but an active credential the identity provider still trusted.
Why this step matters: a string that looks like a secret and a string that works as a secret are two different things. Verification is what turns a candidate into a real finding. It is also the step where care is needed: you send only what is necessary to confirm the value is accepted, and nothing more.
The report does not include the request, the response body, the endpoint URL or the scope list.
Step 3: Map the scopes
From there the researcher mapped exactly what the secret's scopes allowed. Scopes are the permissions attached to a credential: the list of things it is allowed to do. Think of a hotel key card: it may open your room, or it may also open the gym, the pool and the staff door. The scopes tell you how far the key reaches.
Mapping them shows what the secret is permitted to do. The researcher did this without exercising anything beyond what was needed to confirm impact, and then reported it through the program's disclosure process. Disclosure is the agreed route for telling an organisation about a security problem, usually set out by a bug bounty programme.
Why this step matters: knowing a secret works tells you there is a problem. Knowing what it can do tells you how serious the problem is. Doing it without going further than necessary keeps the test safe and keeps the report credible.
Why this keeps happening at scale
This was not a small product. It was infrastructure serving a large user base, built by teams that presumably run security reviews and CI/CD scanning, and the secret still shipped, client-accessible.
CI/CD stands for continuous integration and continuous delivery: the automated pipeline that builds, tests and releases software. Scanning inside that pipeline means checking the code automatically for problems before it goes out.
The report gives three reasons the pattern persists:
- Secrets do not announce themselves in a diff the way a logic bug does. A diff is the list of changes in a code review. A logic bug changes behaviour, so it shows up as something that works differently. A secret is just a value, and a value can slip in quietly.
- Automated scanners catch known formats far more reliably than custom ones, and often only run against source repositories, not shipped build artifacts. In other words, the scanner checks the code the team edits, not necessarily the files that actually get deployed to users.
- "Temporary" code has a way of becoming permanent, because nobody owns removing it before release.
The author frames this as a systems problem rather than a competence problem. The report does not say which specific control failed.
A secret doesn't stop being a secret because nobody's looked yet.
What actually fixes this

The report does not describe a specific remediation that was applied. It states that the fix is not a smarter WAF rule or a better scanner. A WAF, a web application firewall, is a filter that inspects incoming web traffic and blocks requests that look malicious. The point is that no filter on incoming traffic helps here, because the secret was already handed out to every visitor.
The fix is to treat "what does the client actually receive" as a first-class security question every time something ships. In plain terms: before releasing anything, ask what files and values end up on the user's machine, and make sure no secret is among them.
The broader lesson
The most dangerous vulnerabilities are not always the flashiest ones. A hardcoded secret is not a clever exploit chain. It is a value that was never supposed to leave the building, sitting in a place anyone could find with nothing more than developer tools and patience.
Anyone can search a bundle for suspicious strings. Separating a real, exploitable secret from noise, without touching anything beyond what is needed to prove the point, is what separates a useful report from a false-positive ticket.
Variants to test
These are the places the same mistake tends to appear, and what counts as a positive result in each.
- Minified frontend bundles. Look through shipped JavaScript for long, high-entropy strings whose surrounding context points at an identity provider's token endpoint. A positive result is a value whose surrounding context points at an identity provider's token endpoint.
- Mobile binaries. Unpack the app and look for embedded credentials added to skip a round trip. A positive result is a credential that authenticates against the provider.
A positive result is a live token rather than an error for a rotated or dead credential.
Glossary
- API: a way for one piece of software to ask another for something and get an answer, like a waiter carrying orders between you and the kitchen.
- AWS Cognito: Amazon's identity service, used by organisations to handle sign-ups, logins and tokens.
- Build artifact: a file produced by the build process and actually deployed to users, as opposed to the source code the team edits.
- CI/CD: continuous integration and continuous delivery, the automated pipeline that builds, tests and releases software.
- Client: in OAuth2, the application that asks for access to a service.
- Client secret: a password an application uses to prove to an authorisation server that it really is that application; it must stay on the backend.
- Client-side bundle: the JavaScript files a website sends to the visitor's browser, which anyone can download and read.
- Credential: any value that proves identity or grants access, such as a password, key or secret.
- Diff: the list of changes shown in a code review.
- Disclosure process: the agreed route for reporting a security problem to an organisation.
- Entropy: in this context, how random and unpredictable a string looks; real secrets have high entropy, placeholders do not.
- Environment-variable indirection: fetching a value from a separate settings source at runtime instead of writing it directly into the code.
- False positive: a suspected problem that turns out not to be real.
- Hardcoded: written directly into the code as a fixed value, rather than loaded from configuration.
- Identity provider: a service that manages identities and issues tokens, such as AWS Cognito.
- JavaScript: the programming language that makes web pages interactive; browsers download and run it.
- Minified: code squashed to save space, with short names and no whitespace, making it hard for a human to read.
- Mobile binary: the packaged file of a mobile app that is installed on a phone and can be unpacked and inspected.
- OAuth2: a standard way for applications to prove who they are and obtain permission to use an API.
- Obfuscation: deliberately disguising code or values to make them harder to understand.
- Reconnaissance: looking around a target's public material to see what is exposed.
- Remediation: the fix applied to remove a security problem.
- Rotated: replaced with a new value, so the old one no longer works.
- Scope: a permission attached to a credential, defining what it is allowed to do.
- Token: a temporary pass issued after a successful login, shown on later requests instead of a password.
- Token endpoint: the specific server address where an application sends its credentials and receives a token in return.
- WAF: web application firewall, a filter that inspects incoming web traffic and blocks requests that look malicious.