# Modern Android AppSec: Bypassing System CA Locks & Uncovering Hardcoded AWS Keys (3-Min Guide)
An Android app shipped hardcoded AWS access keys and a bucket name inside its compiled code, so anyone who downloaded the APK could recover them. The author claims this gave read and write access to production cloud backups containing customer data.
Published on medium.com
Reverse Engineering
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 short, practical walk-through of two techniques that come up constantly in Android application security testing: getting a proxy to see HTTPS traffic from an app on a modern Android device, and pulling secrets out of the compiled application itself. The author opens by attacking a common developer belief: that compiling an app into an .apk turns its secrets into an impenetrable black box. The article sets out to show that it does not, by decompiling an APK, injecting a system-level CA certificate without the root-remount crashes that modern Android versions cause, and extracting live cloud credentials from the decompiled code.
The write-up does not name a specific target application, program or bounty. It refers to target_app.apk and a class called CloudServicesActivity.kt, and labels the issue CWE-798 (Hard-coded Credentials).
Setup
The tools and preconditions the article relies on are:
- A device where
adb rootis available, since the certificate step writes into/system. openssl, to convert the Burp CA certificate and compute its subject hash.adb, for pushing files and running shell commands on the device.- Burp Suite, as the interception proxy.
- Jadx-GUI, to decompile the APK's
.dexfiles into Java/Kotlin. - The AWS CLI, to test the recovered credentials.
- The APK itself, which the author notes can simply be downloaded from the internet; no physical access to a device is needed for the credential extraction.
The article states that from Android 7 onwards apps ignore user-installed certificates, and that the traditional adb remount fails on Android 10+ with Read-only file system. Those two facts are the reason for the workaround in the first section.
Finding it
The finding comes from static analysis rather than from watching traffic. After decompiling the APK, the author searches the decompiled sources for patterns matching AWS access key IDs, AKIA[0-9A-Z]{16}, and the search inside CloudServicesActivity.kt immediately surfaces hard-coded credentials. The class declares the access key ID, the secret access key and an S3 bucket name as private properties, which is exactly the shape of CWE-798: a secret that ships inside the client binary and is therefore available to anyone who downloads it.
Exploitation
Step 1: Install a system-trusted CA certificate with tmpfs
First the Burp CA certificate is converted from DER to PEM and its old-style subject hash is computed, because Android names system certificates after that hash:
openssl x509 -inform DER -in cacert.der -out cacert.pem
HASH=$(openssl x509 -inform PEM -subject_hash_old -in cacert.pem | head -1)
The -subject_hash_old output is the filename Android expects, with a .0 suffix added later. The author notes that adb remount fails on Android 10+ with Read-only file system, so instead of modifying the physical partition, an in-memory tmpfs is mounted over the system certificate directory:

adb root
adb shell "mkdir -m 700 /data/local/tmp/ca-copy"
adb shell "cp /system/etc/security/cacerts/* /data/local/tmp/ca-copy/"
adb shell "mount -t tmpfs tmpfs /system/etc/security/cacerts"
adb shell "cp /data/local/tmp/ca-copy/* /system/etc/security/cacerts/"
adb push ${HASH}.0 /system/etc/security/cacerts/
adb shell "chmod 644 /system/etc/security/cacerts/${HASH}.0"
The sequence backs up the existing system certificates into /data/local/tmp/ca-copy, mounts a writable tmpfs over /system/etc/security/cacerts, restores the originals into it, then pushes the Burp certificate under its hash name and sets the permissions to 644. The author reports the result as fully transparent HTTPS interception in Burp Suite without bootloops.
Step 2: Decompile the APK and read the secrets
The APK is opened in Jadx-GUI, which turns the Dalvik bytecode back into readable Java/Kotlin:
jadx-gui target_app.apk
Searching the decompiled code for the AWS key pattern leads to CloudServicesActivity.kt, which contains the following:
class CloudServicesActivity : AppCompatActivity() {
private val AWS_ACCESS_KEY_ID = "[redacted]"
private val AWS_SECRET_ACCESS_KEY = "[redacted]"
private val S3_BUCKET_NAME = "production-user-data-backup-internal"
}
The three values are compiled into the app, so anyone holding the APK holds the credentials.
Step 3: Use the credentials against S3
The author stresses that no physical access to the device is required. With the APK downloaded from the internet, the credentials are configured in the AWS CLI and used to list the bucket:
aws configure set aws_access_key_id [redacted]
aws configure set aws_secret_access_key [redacted]
aws s3 ls s3://production-user-data-backup-internal/

The author rates the impact as CVSS 8.6 (High) and states that the result is direct read/write access to production cloud backups, database dumps and internal customer PII. The article does not show the command output or the bucket listing itself.
Root cause
The mistake is architectural: static IAM credentials are embedded in client-side code. Anything compiled into an APK is distributed to every user of that APK, and decompilation with a tool like Jadx recovers it in seconds. Obfuscation does not change this, because the value still has to be present at runtime for the app to use it. The article does not describe any additional defence in the app that failed; the implication is that the secret was simply shipped in the binary.
Impact
An attacker who downloads the APK can recover the key pair and use it directly against the cloud account. According to the author, this gives read and write access to production cloud backups, database dumps and internal customer PII. The severity depends on the permissions attached to the leaked IAM principal, which the article does not enumerate; it states the claimed access and the CVSS score of 8.6. No device compromise, root or physical access is needed for this part.
Fix
The author lists three developer-side fixes:
- Zero hardcoded secrets. Never put static API keys or IAM credentials in client code.
- Ephemeral tokens. Delegate authentication to backend APIs using OAuth 2.0 or AWS Cognito Identity Pools, so the client holds short-lived, scoped credentials rather than long-lived keys.
- R8 / ProGuard obfuscation. Strip debug logs and obfuscate class and variable names in release builds.
The article does not say whether any of these were applied; it presents them as how mobile developers must fix this class of issue. Note that obfuscation alone does not remove an embedded secret, so the first two points carry the real weight.
Variants to test
- Other cloud providers. Search decompiled code for Azure, GCP and other provider credential patterns. A positive result is a key that authenticates against the provider's API and returns data.
- Other secret formats. Grep for Firebase URLs and keys, Stripe keys, JWTs, private key blocks and generic
api_key/secretassignments. A positive result is a value that grants access to a live service or data set. - Native libraries and resources. Secrets can also sit in
strings.xml,BuildConfig, assets or.sofiles. A positive result is a credential recovered from any of those locations that works against the backend. - Certificate pinning. If interception fails after installing the CA, the app likely pins. A positive result for the tester is identifying the pinning implementation in the decompiled code and confirming that traffic can be intercepted once it is bypassed.
- Backend authorisation. Even with ephemeral tokens, check whether the backend enforces per-user authorisation on the bucket or API. A positive result is one user's token reading another user's objects.
What happened, in plain words
A security researcher opened up an Android app on a computer and found the username and password for the company's cloud storage sitting inside it in plain text. According to the author, those credentials gave access to production backups, database dumps and customer personal data. The article is a short walk-through of how that is done, plus a second technique that lets the researcher watch the app's encrypted traffic while it runs.
Two ideas sit behind the whole piece. The first is that many developers believe turning their code into an installable app file (an .apk) hides the secrets inside it. It does not. The second is that modern Android makes it awkward to watch an app's encrypted traffic, and the article shows a workaround.
The author is Sandeep Yadav, who writes as Sandeep_Hacker. The write-up does not name a real company, app or bug bounty programme. It refers to an app called target_app.apk and a code file called CloudServicesActivity.kt to show the kind of mistake that turns up in real apps. The mistake has a formal label, CWE-798, which simply means "hard-coded credentials": a password or key written directly into the code instead of being kept somewhere safe.

Some background before we start
A few terms come up constantly below, so here they are from zero.
APK. An Android app is distributed as a single file ending in .apk. Think of it as a sealed cardboard box containing everything the app needs: its code, its images, its settings. You install the box on your phone and the phone runs what is inside. Crucially, anyone can download that box and open it on a computer. There is no lock on the lid.
Compiled code and decompiling. Developers write apps in human-readable languages such as Java or Kotlin. Before shipping, a tool turns that into a more machine-friendly form called Dalvik bytecode, stored in files ending in .dex. Decompiling is the reverse trip: taking the bytecode and turning it back into something close to the original readable code. It is like receiving a flat-pack wardrobe and working out, from the parts and the holes, what the assembly instructions must have said.
HTTPS and interception. When an app talks to a server, the conversation is normally encrypted with HTTPS, so anyone listening on the network sees gibberish. A security tester wants to read that conversation to check what is being sent. To do that they put a proxy in the middle: a piece of software, here Burp Suite, that the phone sends all its traffic through. The proxy decrypts, shows the tester the request and response, then re-encrypts and forwards it. It is like a mail room that opens every letter, photocopies it for the auditor, and seals it again before delivery.
Certificates and certificate authorities (CAs). Encryption alone does not tell you who is on the other end. That is what certificates do: a server presents one to prove it is really the server you meant to talk to. A certificate is only trusted if it was signed by a certificate authority the device already trusts. Phones ship with a built-in list of trusted authorities, kept in a folder on the device. For the proxy trick to work, the phone has to trust the proxy's own certificate, which means adding it to that list.
Root. On a phone, root means the highest level of administrator access, able to change protected parts of the system. The certificate trick below needs that level of access.
adb. Android Debug Bridge, a command-line tool that lets a computer send commands to a phone or an emulator (a phone simulated in software on the computer).
AWS, IAM, S3 and buckets. AWS is Amazon's cloud platform. IAM is its system for managing who is allowed to do what. S3 is its file storage service, and a "bucket" is a named container of files inside S3, like a folder in the cloud. An access key ID and a secret access key are the pair of strings that act as a username and password for AWS. Anyone holding a working pair can act as that user.
PII. Personally identifiable information: data that identifies a real person, such as names, addresses or account details.
CVSS. A standard scoring system for how serious a security flaw is. Scores run from 0 to 10, and higher is worse.
The belief the article sets out to break
The article opens with a claim many developers hold: that compiling an app into an .apk turns its secrets into an impenetrable black box. The author's answer is blunt: it does not. The rest of the piece is the demonstration, in three parts. First, get the proxy able to read the app's HTTPS traffic on a modern Android device. Second, decompile the app and find the secrets. Third, use those secrets against the cloud account.
Step 1: Making the phone trust the proxy
Why this is awkward
Two facts about modern Android create the problem.
- From Android 7 onwards, apps ignore certificates that a user installs themselves. Only certificates in the system's own trusted list count. So the easy route, installing the proxy's certificate through the phone's settings, no longer works for app traffic.
- The traditional way to write into the system area, a command called
adb remount, fails on Android 10 and later with the errorRead-only file system. The system area is deliberately locked so that malware cannot tamper with it.
The author's workaround avoids fighting the locked storage. Instead of changing what is on the disk, the technique places a temporary, memory-only filesystem, called tmpfs, on top of the system certificate folder. Anything written there lives in memory and disappears on reboot, but while it is in place the system reads certificates from it. It is like putting a removable shelf in front of a sealed cupboard: you cannot open the cupboard, but you can put things on the shelf and everyone will look there first.
Preparing the certificate
First the proxy's certificate has to be converted into the format Android expects, and given the right name. Android names each system certificate after a short fingerprint of the certificate itself, called its subject hash.
openssl x509 -inform DER -in cacert.der -out cacert.pem
HASH=$(openssl x509 -inform PEM -subject_hash_old -in cacert.pem | head -1)
Line by line:
openssl x509 -inform DER -in cacert.der -out cacert.pemtakes the certificate filecacert.der, which is in a binary format called DER, and rewrites it ascacert.pem, a text-based format.opensslis a widely used tool for working with certificates. The conversion is needed because the next command reads the text format.HASH=$(...)runs the command inside the brackets and stores its output in a variable calledHASH, so it can be reused later without retyping it.openssl x509 -inform PEM -subject_hash_old -in cacert.pemasks openssl to compute the certificate's old-style subject hash, a short string derived from the certificate's contents.head -1keeps only the first line of the output, in case there is more than one.
That hash becomes the filename Android will look for, with .0 added on the end later.
Installing it

adb root
adb shell "mkdir -m 700 /data/local/tmp/ca-copy"
adb shell "cp /system/etc/security/cacerts/* /data/local/tmp/ca-copy/"
adb shell "mount -t tmpfs tmpfs /system/etc/security/cacerts"
adb shell "cp /data/local/tmp/ca-copy/* /system/etc/security/cacerts/"
adb push ${HASH}.0 /system/etc/security/cacerts/
adb shell "chmod 644 /system/etc/security/cacerts/${HASH}.0"
Line by line:
adb rootrestarts the debugging service on the device with administrator (root) privileges, which the following commands need.adb shell "mkdir -m 700 /data/local/tmp/ca-copy"creates a working folder in a temporary area of the device. The-m 700sets its permissions so that only the owner can read, write or enter it.adb shell "cp /system/etc/security/cacerts/* /data/local/tmp/ca-copy/"copies every existing system certificate out of/system/etc/security/cacertsinto that working folder. This is a backup: the next step is about to hide the original folder, and the phone still needs all its normal certificates to trust ordinary websites.adb shell "mount -t tmpfs tmpfs /system/etc/security/cacerts"places the in-memorytmpfson top of the system certificate folder. From now on, reads and writes to that path go to memory, not to the locked disk.adb shell "cp /data/local/tmp/ca-copy/* /system/etc/security/cacerts/"copies the backed-up certificates from step 3 into the new in-memory folder, so the phone keeps trusting everything it trusted before.adb push ${HASH}.0 /system/etc/security/cacerts/sends the proxy's certificate from the computer to the device, naming it after the hash computed earlier with.0appended. That is the name Android expects for a system certificate.adb shell "chmod 644 /system/etc/security/cacerts/${HASH}.0"sets the file's permissions to644, meaning the owner can read and write it and everyone else can read it. Certificates have to be readable by the system to be used.
The author reports the result as fully transparent HTTPS interception in Burp Suite, with no bootloops (the phone failing to start up, a common hazard when tampering with system files).
Step 2: Opening the app and reading the secrets
With traffic visible, the second half of the work is reading the app itself. The tool used is Jadx-GUI, which takes the .dex bytecode inside an APK and turns it back into readable Java or Kotlin.
jadx-gui target_app.apk
This opens the APK in a graphical window. On the left you browse the app's files and classes; on the right you read the decompiled code. The author then searches the decompiled sources for the pattern AKIA[0-9A-Z]{16}, which is the shape of an AWS access key ID: the letters AKIA followed by sixteen characters that are digits or capital letters. Searching for a pattern like this is like scanning a printed address book for every entry that starts with a particular prefix; you do not need to know the name in advance, only its shape.
The search lands in a file called CloudServicesActivity.kt, which contains this:
class CloudServicesActivity : AppCompatActivity() {
private val AWS_ACCESS_KEY_ID = "[redacted]"
private val AWS_SECRET_ACCESS_KEY = "[redacted]"
private val S3_BUCKET_NAME = "production-user-data-backup-internal"
}
Line by line:
class CloudServicesActivity : AppCompatActivity() {starts the definition of a screen in the app. In Android, an "activity" is roughly one screen or one unit of user interface, andAppCompatActivityis the standard building block for one.private val AWS_ACCESS_KEY_ID = "[redacted]"declares a value holding the AWS access key ID, the username half of the credential pair.privatemeans other code in the app cannot reach it directly, but that has no effect on someone reading the decompiled file: the text is right there.private val AWS_SECRET_ACCESS_KEY = "[redacted]"declares the secret access key, the password half of the pair.private val S3_BUCKET_NAME = "production-user-data-backup-internal"declares the name of the cloud storage bucket the app talks to.- The closing
}ends the class.
The point is simple. These three values are compiled into the app, so anyone who holds the APK holds the credentials. The word private protects the value from other code inside the app; it does nothing against a person reading the file.
Step 3: Using the credentials
The author stresses that no physical access to a phone is needed for this part. The APK can be downloaded from the internet like any other app, and the credentials taken from it. They are then loaded into the AWS command-line tool and used to list the bucket:
aws configure set aws_access_key_id [redacted]
aws configure set aws_secret_access_key [redacted]
aws s3 ls s3://production-user-data-backup-internal/
Line by line:
aws configure set aws_access_key_id [redacted]stores the access key ID in the AWS command-line tool's configuration, so later commands use it automatically.aws configure set aws_secret_access_key [redacted]stores the matching secret key the same way.aws s3 ls s3://production-user-data-backup-internal/asks S3 to list the contents of the named bucket.lsis the familiar "list" command, ands3://marks the address as a bucket rather than a web page.

The author rates the impact as CVSS 8.6, which is High on the 0 to 10 scale, and states that the result is direct read and write access to production cloud backups, database dumps and internal customer PII. The article does not show the output of the listing command.
Why this happens
The root cause is a design mistake rather than a coding slip: long-lived cloud credentials were placed inside code that ships to every user. Anything compiled into an APK is handed out with the APK, and a decompiler recovers it in seconds. Obfuscation, which renames classes and variables to make code harder to read, does not change this, because the value still has to be present when the app runs. The article does not describe any other protection in the app that failed; the secret was simply shipped in the binary.
How bad it is
Anyone who downloads the APK can recover the key pair and use it directly against the cloud account. According to the author, that gives read and write access to production cloud backups, database dumps and internal customer PII. How bad it really is depends on what permissions the leaked key carries, which the article does not list; it states the claimed access and the CVSS score of 8.6. No device compromise, root or physical access is needed for this part.
How developers should fix it
The author gives three fixes:
- No hard-coded secrets. Never put static API keys or cloud credentials in client code. If it ships to users, treat it as public.
- Short-lived tokens. Let a backend service handle authentication, using OAuth 2.0 or AWS Cognito Identity Pools, so the app holds temporary, narrowly scoped credentials instead of long-lived keys. A useful comparison is a hotel key card that stops working after checkout, rather than a master key that works forever.
- R8 / ProGuard obfuscation. Strip debug logs and rename classes and variables in release builds. This makes code harder to read, but as noted above it does not remove a secret that is genuinely present.
The article does not say whether any of these were applied; it presents them as how mobile developers must fix this class of issue. Obfuscation alone does not remove an embedded secret, so the first two points carry the real weight.
Other things worth testing
Once you know the shape of the problem, the same approach applies more widely.
- Other cloud providers. Search decompiled code for Azure, GCP and other providers' credential patterns. A positive result is a key that authenticates against the provider's API and returns data.
- Other secret formats. Search for Firebase URLs and keys, Stripe keys, JWTs (signed tokens often used for login sessions), private key blocks, and generic
api_keyorsecretassignments. A positive result is a value that grants access to a live service or data set. - Native libraries and resources. Secrets can also sit in
strings.xml,BuildConfig, asset files or.sofiles (compiled native code). A positive result is a credential recovered from any of those places that works against the backend. - Certificate pinning. If interception still fails after installing the certificate, the app probably pins: it checks for one specific certificate and refuses anything else. A positive result for the tester is finding the pinning code in the decompiled app and confirming that traffic can be intercepted once it is bypassed.
- Backend authorisation. Even with short-lived tokens, check whether the backend enforces per-user permissions on the bucket or API. A positive result is one user's token reading another user's files.
Final thought
The author's closing line is the whole lesson in one sentence: if a secret is inside an APK, it is public. Real mobile security lives in strong backend authorisation and short-lived credentials.
Glossary
- APK: the single installable file that contains an Android app, including its code, images and settings.
- Dalvik bytecode: the machine-friendly form Android app code is compiled into, stored in
.dexfiles. - Decompiling: turning compiled code back into something close to the original readable source.
- Jadx-GUI: a graphical tool that decompiles an APK's
.dexfiles into Java or Kotlin. - HTTPS: the encrypted version of the protocol browsers and apps use to talk to servers.
- Proxy: software placed between a device and the internet that can read, inspect and forward traffic; Burp Suite is one.
- Interception: capturing and reading traffic between an app and a server, usually through a proxy.
- Certificate: a digital document a server presents to prove its identity.
- Certificate authority (CA): an organisation whose signature on a certificate makes devices trust it.
- DER and PEM: two file formats for certificates; DER is binary, PEM is text-based.
- Subject hash: a short fingerprint derived from a certificate, used by Android as the certificate's filename.
- Root: the highest administrator level on an Android device, able to change protected system areas.
- adb: Android Debug Bridge, a command-line tool for sending commands from a computer to a phone or emulator.
- Emulator: software that simulates a phone on a computer.
adb remount: the traditional command for making the system area writable; it fails on Android 10 and later withRead-only file system.tmpfs: a filesystem that lives in memory rather than on disk, so its contents vanish on reboot./system/etc/security/cacerts: the folder on Android holding the system's trusted certificates.chmod 644: a permission setting meaning the owner can read and write a file and everyone else can read it.- Bootloop: a phone repeatedly failing to start up.
- AWS: Amazon Web Services, Amazon's cloud platform.
- IAM: AWS's system for managing who is allowed to do what.
- S3: AWS's file storage service.
- Bucket: a named container of files in S3, like a folder in the cloud.
- Access key ID and secret access key: the username-and-password pair used to authenticate to AWS.
- AWS CLI: the command-line tool for working with AWS.
- CWE-798: the standard label for hard-coded credentials, meaning a secret written directly into code.
- Hard-coded credentials: a password or key written into source code instead of stored safely elsewhere.
- Obfuscation: renaming classes and variables to make code harder for a person to read; it does not remove embedded secrets.
- R8 / ProGuard: tools that shrink and obfuscate Android code in release builds.
- OAuth 2.0: a standard way for apps to obtain temporary, scoped access tokens instead of holding long-lived passwords.
- AWS Cognito Identity Pools: an AWS service that issues temporary, limited credentials to app users.
- Token: a piece of data, often short-lived, that proves who you are or what you may do.
- JWT: a signed token commonly used to carry login sessions.
- Certificate pinning: an app checking for one specific certificate and refusing any other, which blocks proxy interception.
- PII: personally identifiable information, data that identifies a real person.
- CVSS: a standard 0 to 10 score for the severity of a security flaw.
- Backend authorisation: server-side checks that each user may only reach their own data.