Skip to content
Leaked secrets Write-up Beginner

Android apk leaks access token to takeover the whole infrastructure

The Android APK contained a hardcoded base64-encoded access token for production and staging environments. An attacker who decompiled the APK could decode the token and log into the production application, gaining access to the infrastructure.

Santosh Kumar Sha Follow

Published on notifybugme.medium.com

{{media:0}}

Santosh Kumar Sha (@killmongar1996), on notifybugme.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

This is a short account of a hardcoded credential found in an Android application published by a company running a public bug bounty programme. The researcher does not name the company or the application, and does not describe what the application does. What he does say is that the leaked value was an access token for both the production and staging environments, and that using it let him log into the production application and reach the infrastructure behind it.

The write-up is therefore about a class of bug rather than a single endpoint: secrets shipped inside a mobile package, recoverable by anyone who downloads the APK.

Setup

The researcher, Santosh Kumar Sha (@killmongar1996), was hunting on a public bug bounty programme. No account, role or special access is described; the only precondition was the ability to download the application, which he did by searching for it publicly.

Tools he lists as required:

  1. gf by tomnomnom, from https://github.com/tomnomnom/gf
  2. grep
  3. apktool
Santosh Kumar Sha (@killmongar1996)
Santosh Kumar Sha (@killmongar1996) From the original on notifybugme.medium.com

The image is the author's profile card from the post header.

Finding it

His stated method for locating a downloadable application is simply to search for it:

Suppose "example" the company to look for android application

Just search on Google like these "example android application downloadable"

Once he had the APK, he decompiled it and started looking around the decompiled files for hardcoded secrets. The signal he searched for was a base64-encoded string, using the prefix eyJ as the search pattern. That prefix is what made the result stand out: a match on eyJ inside an application package suggests an embedded token rather than ordinary application data.

Exploitation

Step 1: decompile the APK

Bash
apktool d exaple.apk.

This unpacks the package into a directory of decoded resources and smali, which is where he then searched. The command is reproduced exactly as it appears in the post, including the spelling of the file name and the trailing full stop.

Step 2: grep the decompiled tree for a token prefix

He navigated to the directory produced by apktool and ran:

Bash
grep -Hnri "eyJ" * — color

The flags are recursive (-r), case-insensitive (-i), with file names and line numbers (-Hn). The — color at the end is as written in the post; the working form of that option is --color.

Step 3: read the output

The match came back inside a binary-looking blob, with the token visible next to a configuration name:

Text
r�5.6.4p3
 m��%�I�$4���v�A�global.assets-Production_accessssConfig0eyJUa………….

The interesting part is the string global.assets-Production_accessssConfig0eyJUa…, which contains the token prefix. The surrounding bytes are binary noise from the file the string was embedded in. The post truncates the token itself, so the full value is not shown.

Step 4: decode and use the token

He base64-decoded the string and used the resulting token to log into the production application. From there, in his words, he was "finally able to access the infrastrucure down". The post does not show the login request, the endpoint, the headers used, or the response, and it does not describe which parts of the infrastructure were reachable or what permissions the token carried.

Root cause

The mistake is that a production and staging access token was compiled into the application package as a static string. Because the value sits in the APK, anyone who downloads the package can extract it with apktool and grep; there is no server-side check that the caller is the legitimate application.

The post does not explain how the token was meant to be protected, whether it was scoped, or how long it lived.

Impact

With the leaked token the researcher logged into the production application and reached the infrastructure behind it. The title frames this as taking over "the whole infrastructure", and the introduction says the token covered both production and staging. The post gives no detail on the scope of the token, the number of systems affected, or what an unauthorised party could read or change, so the practical blast radius beyond the author's own access is not documented here.

The condition for exploitation was simply that the APK could be downloaded.

Fix

The post does not describe any remediation or say what the programme changed. The post does not describe any remediation.

Variants to test

  1. Search decompiled packages for other token prefixes and key formats, not just eyJ: cloud provider key prefixes, AKIA-style identifiers, and private key headers. A positive result is a string in a decoded resource or smali file that decodes to a usable credential.
  2. Run the same grep over the raw APK and over any bundled assets, configuration files and native libraries, since strings can live outside the smali. A hit in an assets or config file is the same class of bug.
  3. Check whether the extracted token is accepted by the production host and what it is scoped to, using only the programme's permitted testing. A positive result is an authenticated session or API response that the token should not grant to an unauthenticated party.
  4. Repeat on staging builds, which are often shipped with the same configuration and weaker monitoring. A token that works against staging confirms the pattern extends beyond production.
  5. Look for the same configuration name pattern (...Production_...Config) in other builds of the same vendor, since a naming convention that embeds environment and purpose in the key often repeats. A match in a second package shows the leak is systemic rather than a one-off.

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

What happened, in plain words

A security researcher downloaded an Android app that a company had published, opened the app's package file on his computer, and searched inside it for secrets. He found one: a long string that turned out to be an access token for the company's production and staging environments. He decoded it, used it to log into the production application, and from there reached the infrastructure behind it.

The company is not named in the write-up, and neither is the app or what it does. The point of the article is the pattern, not the specific target: secrets that are baked into a mobile app can be pulled out by anyone who can download that app.

Before going further, a few ideas from zero:

  • APK: the file format of an Android app. It is a single file, like a .zip, that you download from the Play Store or a company website. Inside it are the app's code, images, text and configuration.
  • Decompiling: unpacking that file back into readable pieces. An APK is compiled, meaning the code has been translated into a form machines run; decompiling turns it back into something a person can read and search.
  • Hardcoded credential: a password, key or token written directly into the app's code or files, instead of being fetched securely at the moment it is needed. Think of hiding a spare house key under the doormat: it works, but anyone who knows to look under the mat has the key.
  • Token: a long string of characters that acts like a temporary password. You show it to a server and the server lets you in, without asking for a username and password again. Whoever holds the token is treated as you.
  • Production and staging: production is the real, live system that customers use. Staging is a copy used for testing before changes go live. A token that works on both is especially valuable to an attacker.
  • Base64: a way of writing any data using only ordinary letters, digits and a couple of symbols. It is not encryption; anyone can turn it back into the original with a single command. It is used because some systems can only carry text safely.
  • JWT (JSON Web Token): a common kind of token. It is a piece of text that encodes information about who you are and what you may do. When a JWT is base64-encoded, it almost always starts with the three characters eyJ, because those are the encoded form of {", the opening of the token's data.

Context

This is a short account of a hardcoded credential found in an Android application published by a company running a public bug bounty programme. A bug bounty programme is a scheme where a company invites outside researchers to look for security flaws and report them, often for a reward. The researcher does not name the company or the application, and does not describe what the application does. What he does say is that the leaked value was an access token for both the production and staging environments, and that using it let him log into the production application and reach the infrastructure behind it.

The write-up is therefore about a class of bug rather than a single endpoint. An endpoint is one specific address on a server that an app or browser talks to, for example the address that handles logging in. The bug here is not in one endpoint; it is in the app package itself.

Setup

The researcher, Santosh Kumar Sha (@killmongar1996), was hunting on a public bug bounty programme. No account, role or special access is described; the only precondition was the ability to download the application, which he did by searching for it publicly.

Tools he lists as required:

  1. gf by tomnomnom, from https://github.com/tomnomnom/gf
  2. grep
  3. apktool

What each of these is, for a complete beginner:

  • gf is a small helper program that searches text for patterns that security researchers commonly care about, such as tokens and keys. It saves you from typing long search patterns by hand.
  • grep is a standard command-line tool, present on almost every Linux and macOS computer, that searches through files for a piece of text and prints the lines where it appears. Think of it as the search box of your computer, but for folders full of files.
  • apktool is a program that unpacks an APK into its parts, so you can read the code and resources inside.

A command line is a text window where you type instructions instead of clicking buttons. The commands below are typed there.

Santosh Kumar Sha (@killmongar1996)
Santosh Kumar Sha (@killmongar1996) From the original on notifybugme.medium.com

The image is the author's profile card from the post header.

Finding it

His stated method for locating a downloadable application is simply to search for it:

Suppose "example" the company to look for android application

Just search on Google like these "example android application downloadable"

Why this works: many companies publish their Android app as a plain file on their own website, not only through an app store. A web search for the company name plus "android application downloadable" often surfaces that file. Once you have the file, you have everything the app contains, because the file is the app.

Once he had the APK, he decompiled it and started looking around the decompiled files for hardcoded secrets. The signal he searched for was a base64-encoded string, using the prefix eyJ as the search pattern. That prefix is what made the result stand out: a match on eyJ inside an application package suggests an embedded token rather than ordinary application data.

Why search for eyJ specifically? Because it is a very short, very distinctive string. Ordinary app text rarely contains those three letters in that order, so a hit is a strong hint that a token is sitting in the files. It is like searching a library for a book whose title starts with an unusual three-letter combination: you get few false results.

Exploitation

Step 1: decompile the APK

Bash
apktool d exaple.apk.

Line by line:

  • apktool is the program being run.
  • d is short for "decode". It tells the tool to unpack the file rather than pack one.
  • exaple.apk. is the name of the file to unpack. The command is reproduced exactly as it appears in the post, including the spelling of the file name and the trailing full stop. In practice you would type the real name of the file you downloaded.

This unpacks the package into a directory of decoded resources and smali. The unpacked directory is where he then searched.

Step 2: grep the decompiled tree for a token prefix

He navigated to the directory produced by apktool and ran:

Bash
grep -Hnri "eyJ" * — color

Line by line:

  • grep is the search tool.
  • -H tells it to print the name of the file where each match was found.
  • -n tells it to print the line number of each match.
  • -r means recursive: search inside every subfolder, not just the current one.
  • -i means case-insensitive: treat uppercase and lowercase letters as the same.
  • "eyJ" is the text being searched for, in quotes so the command line treats it as one piece.
  • * means "all files in the current folder".
  • — color at the end is as written in the post; the working form of that option is --color, which makes the matching text stand out in colour in the terminal.

In other words, he is not searching for a particular token; he is searching for the fingerprint that any base64-encoded JWT leaves behind.

Step 3: read the output

The match came back inside a binary-looking blob, with the token visible next to a configuration name:

Text
r�5.6.4p3
 m��%�I�$4���v�A�global.assets-Production_accessssConfig0eyJUa………….

What you are looking at:

  • The odd symbols and question-mark-like characters are binary data: bytes that are not meant to be read as text. The token was embedded in a file that also contains machine data, so the search prints the surrounding noise along with the match.
  • The interesting part is the string global.assets-Production_accessssConfig0eyJUa…, which contains the token prefix.
  • The post truncates the token itself, so the full value is not shown.

Why this output mattered: the researcher was not looking at a login screen or an API response. He was looking at the inside of the app, and the app was carrying a live credential around with it.

Step 4: decode and use the token

He base64-decoded the string and used the resulting token to log into the production application. From there, in his words, he was "finally able to access the infrastrucure down".

Why decoding was needed: base64 is just a wrapping. The token inside the app was stored in base64 form, and the server expects the decoded value. Decoding is a mechanical step, not a secret one; any base64 decoder, including ones built into browsers and command-line tools, will do it.

The post does not show the login request, the endpoint, the headers used, or the response, and it does not describe which parts of the infrastructure were reachable or what permissions the token carried.

Root cause

The mistake is that a production and staging access token was compiled into the application package as a static string. In plain terms: the app was built with the key already inside it, instead of asking the server for a key after the user logs in.

Because the value sits in the APK, anyone who downloads the package can extract it with apktool and grep; there is no server-side check that the caller is the legitimate application. A server-side check means the server itself verifies who is asking, rather than trusting the app to behave. Here, the server saw a valid token and let the request through, because the token was valid.

The post does not explain how the token was meant to be protected, whether it was scoped, or how long it lived. Scoped means limited to certain actions or certain systems; a token that can only read one thing is less dangerous than one that can change everything. Obfuscation means making code harder to read, for example by renaming things; it slows a researcher down but does not stop them, because the app still has to use the secret at runtime.

Impact

With the leaked token the researcher logged into the production application and reached the infrastructure behind it. The title frames this as taking over "the whole infrastructure", and the introduction says the token covered both production and staging. The post gives no detail on the scope of the token, the number of systems affected, or what an unauthorised party could read or change, so the practical blast radius beyond the author's own access is not documented here.

The condition for exploitation was simply that the APK could be downloaded. No phishing, no tricking an employee, no special network position: just a download and a search.

Fix

The post does not describe any remediation or say what the programme changed. The post does not describe any remediation. Rotating a credential means replacing it with a new one and invalidating the old, so that anyone who already copied it can no longer use it.

Variants to test

These are the same checks a researcher would run next, written so a beginner can follow the reasoning:

  1. Search decompiled packages for other token prefixes and key formats, not just eyJ: cloud provider key prefixes, AKIA-style identifiers, and private key headers. A positive result is a string in a decoded resource or smali file that decodes to a usable credential. Why: different services use different fingerprints, and eyJ only catches one family of tokens.
  2. Run the same grep over the raw APK and over any bundled assets, configuration files and native libraries, since strings can live outside the smali. A hit in an assets or config file is the same class of bug. Why: decompiling does not always expose every file, and a secret in a bundled configuration file is just as usable.
  3. Check whether the extracted token is accepted by the production host and what it is scoped to, using only the programme's permitted testing. A positive result is an authenticated session or API response that the token should not grant to an unauthenticated party. Why: finding a string is only half the story; the question that matters is what the string unlocks.
  4. Repeat on staging builds, which are often shipped with the same configuration and weaker monitoring. A token that works against staging confirms the pattern extends beyond production. Why: staging is built by the same people with the same habits, and problems there are often noticed later.
  5. Look for the same configuration name pattern (...Production_...Config) in other builds of the same vendor, since a naming convention that embeds environment and purpose in the key often repeats. A match in a second package shows the leak is systemic rather than a one-off. Why: if one app was built this way, the team's other apps probably were too.

Glossary

  • APK: the file format of an Android app; a single downloadable file containing the app's code, resources and configuration.
  • Access token: a string that proves to a server that the holder is allowed in, without needing a username and password each time.
  • Base64: a way of representing any data using ordinary text characters; reversible by anyone, not a form of encryption.
  • Bearer credential: a secret where simply possessing it is enough to use it, with no further proof of identity.
  • Binary data: bytes that are not meant to be read as text, which is why they appear as odd symbols in a terminal.
  • Bug bounty programme: a scheme where a company invites outside researchers to find and report security flaws, often for a reward.
  • Command line: a text window where you type instructions to the computer instead of clicking.
  • Decompiling: turning a compiled app file back into a form a person can read and search.
  • Endpoint: one specific address on a server that an app or browser communicates with.
  • Environment: a separate copy of a system, such as production (live) or staging (for testing).
  • gf: a helper tool that searches text for patterns security researchers commonly look for.
  • grep: a standard command-line search tool that finds text inside files.
  • Hardcoded credential: a password, key or token written directly into an app's code or files instead of being fetched securely at runtime.
  • Header: extra information sent alongside a request or response, such as which format is expected or which token is being presented.
  • Infrastructure: the collection of servers and services behind an application that make it work.
  • JWT (JSON Web Token): a common token format whose base64-encoded form usually starts with eyJ.
  • Obfuscation: making code harder for a person to read, which slows analysis but does not stop it.
  • Production: the real, live system that customers use.
  • Rotating a credential: replacing a secret with a new one and invalidating the old, so copied versions stop working.
  • Scoped: limited to certain actions or certain systems.
  • Server-side check: verification performed by the server itself, rather than trusting the app to behave correctly.
  • Smali: the readable form of Android app code after decompiling.
  • Staging: a test copy of a system, used before changes go live.
  • Token: a string that acts like a temporary password, letting its holder access a system.
  • apktool: a program that unpacks an APK into its readable parts.

More by Santosh Kumar Sha

View all

16 more disclosed reports, best first.

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.