OWASP Mobile Top 10 — M7: Insufficient Binary Protections
Welcome to the seventh article in our OWASP Mobile Top 10 2024 series! In previous articles we covered M1 through M6. Today: what an attacker can do with your app binary once they download it — and why React Native chang
Welcome to the seventh article in our OWASP Mobile Top 10 2024 series! In previous articles we covered M1 through M6. Today: what an attacker can do with your app binary once they download it — and why React Native changes the answer more than most developers expect.
Introduction
Your app binary is public. Anyone can download it from the store, or pull it off a device, and take it apart at their leisure. That's the premise of M7, and OWASP is refreshingly blunt about it:
Note that there are no fully reliable mechanisms to prevent binary attacks. Defending against them is an arms race between the developers investing in countermeasures and attackers who break these measures.
So M7 isn't about making your app unbreakable. It's about a cost equation. OWASP frames the goal as fending off attackers long enough that breaking the protection costs more than it gains them.
A caveat in OWASP's text worth reading carefully
In its discussion of M7, OWASP compares platforms: fully compiled apps like iOS apps are less susceptible to reverse engineering and code tampering than the higher-level bytecode found in Android apps. Then it adds a parenthetical — that this might not hold for apps developed with cross-platform technologies, naming PWA and Flutter as its examples.
React Native isn't in that list. But the reasoning behind the caveat applies to it directly, and you don't have to take my word for it — the rest of this section is just facts about where your code lives.
In a React Native app, most of your business logic isn't in compiled Swift or in Java bytecode. It's in a JavaScript bundle, built from the same codebase on both platforms. So the advantage OWASP attributes to "fully compiled apps like iOS apps" doesn't extend to the part of an RN app that matters most.
OWASP Assessment
| Metric | Value | Meaning |
|---|---|---|
| Exploitability | EASY | Binaries are downloadable from any store |
| Prevalence | COMMON | All apps are exposed to it |
| Detectability | EASY | Free tools, well documented |
| Technical Impact | MODERATE | Leaked secrets, manipulated behaviour |
| Business Impact | MODERATE | Abused API keys, piracy, IP theft |
⚠️ Three "easy/common" ratings in a row. OWASP's own words: app binaries can usually be downloaded from the app stores or copied from mobile devices, so binary attacks are easy to set up. There's no network position to win, no user to trick. The attacker just needs your public artifact.
Threat Agents
Attackers go after app binaries for different reasons:
- Secrets in the binary — commercial API keys or hardcoded cryptographic secrets that can be misused
- Valuable code — critical business logic or pre-trained AI models
- Reconnaissance — using the app to explore weaknesses in its backend before attacking that
- Free access — manipulating the binary to unlock paid features or bypass other checks
- Malicious redistribution — modifying a popular app to include malicious code and distributing it via third-party stores or under a new name
OWASP singles out one pattern: reconfiguring the payment identifiers in an app, repackaging it, and distributing it — so users who download the unauthorized copy pay the attacker instead of the original provider.
Attack Vectors
An app binary is subject to two types of attack:
Reverse engineering — the binary is decompiled and scanned for valuable information: secret keys, algorithms, or vulnerabilities.
Code tampering — the binary is manipulated, for example to remove license checks, circumvent paywalls, or obtain other benefits. Alternatively, it's modified to contain malicious code.
Both apply to React Native, and both look different from what you'd expect.
Where Your Code Actually Lives in a React Native App
This is the part most RN developers haven't thought about. An RN app has two layers of code, and they're protected very differently:
| Layer | What's in it | Format in the binary |
|---|---|---|
| Native layer | RN runtime, native modules, SDKs (Java/Kotlin, Obj-C/Swift) | Java bytecode (Android), compiled machine code (iOS) |
| JS layer | Your screens, business logic, API calls, validation, feature flags | A JS bundle — Hermes bytecode by default |
For most RN apps, the JS layer is the app. And on Android, it sits in a predictable place:
unzip app-release.apk -d extracted/
file extracted/assets/index.android.bundle
# extracted/assets/index.android.bundle: Hermes JavaScript bytecode, version 84
Hermes bytecode is not obfuscation
Hermes compiles your JS to bytecode ahead of time. That's a performance feature. It is not a security feature — and it's worth being direct about that, because you'll find articles online describing Hermes as a built-in obfuscator. It isn't one.
This applies to both platforms, which is the part people get wrong. Hermes ran on iOS as an opt-in from React Native 0.64, but since 0.70 the default for hermes_enabled on iOS and enableHermes on Android is true. If you haven't explicitly switched to JavaScriptCore, you're shipping Hermes bytecode on iOS too.
Open-source tooling reads Hermes bytecode directly. P1 Security's hermes-dec is the best known:
pipx install hermes-dec
# Decode the file headers
hbc-file-parser extracted/assets/index.android.bundle
# Disassemble to Hermes assembly
hbc-disassembler extracted/assets/index.android.bundle output.hasm
# Decompile to pseudo-code
hbc-decompiler extracted/assets/index.android.bundle output.js
Its own README is honest about the limits: the decompiled output is pseudo-code, not valid JavaScript yet, because it doesn't reconstruct loop and conditional structures. But that's a much smaller barrier than it sounds. Your string table — API endpoints, error messages, feature flag names, any key you embedded — is right there.
⚠️ Check the bytecode version before you trust any of these commands. Hermes bytecode has a version number (
hbc-file-parserprints it), and tools support specific ranges. P1 Security wrote hermes-dec targeting the public Hermes versions available at the end of 2022. React Native 0.84 then made Hermes V1 the default engine on both platforms, after an experimental opt-in in 0.82 — so a recent app may well be outside what a given tool was built for. I have not tested these tools against Hermes V1 output. Run them on your own bundle and see; "the tool errored out" is not the same as "my bundle is safe."
Tampering is possible too
Reading is one thing. Rewriting is another, and it's also possible. The hbctool family of tools disassembles a Hermes bundle into a readable representation, lets you modify metadata, strings, and instructions, and then assembles a valid Hermes bundle back from the edited output. (The PyPI listing I'm describing here is hbctool-cli, a continuation of the original project — check which variant and which bytecode versions you're dealing with.)
That's OWASP's code tampering vector, working directly against a Hermes bundle: find the license check, change it, reassemble, re-sign, redistribute.
And the tooling keeps getting better. Symbiotic Security’s open-source hermes-decomp, written in Rust, reconstructs control flow — so the pseudo-code limitation above isn’t the ceiling. This is exactly the arms race OWASP describes — the attacker side is actively investing.
OWASP Example Attack Scenarios
Scenario #1 — Hardcoded API keys
An app uses a commercial API that charges per call. The API key used for access and billing is hardcoded in the app's unprotected binary. An attacker reverse engineers the app with free tools and extracts the key. Since API access is protected only by the key, with no additional user authentication, the attacker can freely use the API or even sell the key. In the worst case, this causes substantial financial damage to the provider — or at least blocks legitimate users if the API is rate-limited.
Scenario #2 — Disabling payment and license checks
A mobile game publishes its first levels for free, with the rest unlocked by payment. All the resources for later levels ship with the app, protected only by a local license check. If the binary isn't sufficiently protected, the attacker locates the license check, replaces it with a static success statement, recompiles, and plays for free — or sells the app under another name.
Scenario #3 — Hardcoded AI models
A medical app bundles its specialized, quality-assured AI model for offline use. The model took many person-years to develop and is the app's most valuable asset. An insufficiently protected binary lets an attacker extract the model — and learn how it's used — and sell both to competitors.
💡 All three map directly to React Native. Scenario #1 is a key in
.env. Scenario #2 is anif (isPremium)in your JS bundle. Scenario #3 is a.tfliteor.onnxfile in your assets folder. We'll take each one in turn.
Technical and Business Impacts
Technical Impact — MODERATE
If secrets leak, they must be replaced quickly throughout the system — which is hard when they're hardcoded in an app that users have to update. Leaked information can also reveal vulnerabilities in the backend.
Manipulation has more impact still. Tampered binaries can change how the app behaves arbitrarily — to the attacker's benefit, or to disturb backends that aren't hardened against malicious requests.
Business Impact — MODERATE
- Abused API keys can cause significant costs at scale
- Removed license checks and cloned functionality hurt revenue — one individual cracking an app goes unnoticed, but systematic misuse gives malicious competitors a cost advantage
- Stolen IP — algorithms or AI models — can threaten the business model outright
- Reputational damage from malicious redistribution tends to land on the original provider, even though they couldn't prevent it
Am I Vulnerable?
OWASP's answer: all apps are vulnerable to binary attacks. What varies is how much damage a successful one would do. The more motivating the target and the greater the impact, the more effort protection deserves.
The practical test is to look at your own binary the way an attacker would. OWASP names MobSF, otool, apktool, and Ghidra as free or affordable, well-documented tools. For an RN app, add hermes-dec from the section above. Twenty minutes with your own release APK is the most honest security review you'll get.
Prevention Strategies
OWASP's approach starts with an assessment: does your binary contain anything critical, or is your app popular enough to warrant protection? If so, threat model it to find the highest risks and their financial impact.
Then, a principle that underpins everything else:
Apps always run in untrusted execution environments and should only get the least necessary information they need to work.
From there, OWASP gives countermeasures by attack type:
Against reverse engineering: make the binary incomprehensible with obfuscation tools. Compiling parts of the app natively, or using interpreters and nested virtual machines, makes it harder still. OWASP flags the trade-off: many libraries rely on specific strings or symbols and won't work under full obfuscation. Check your obfuscation's quality with the same tools attackers use.
Against breaking security mechanisms: obfuscation helps here too, because an attacker must understand the control flow to skip a check. But the critical point is this: local security checks should also be enforced by the backend. OWASP's example — a protected feature's resources should only be downloaded if a check succeeds both locally and on the backend.
Against redistribution: integrity checks (on startup, for example) can detect modification and repackaging, and report it so unauthorized copies can be found and removed from stores before they spread.
OWASP also notes that any integrity check running on the device can itself be found and deactivated, like any other local check. That's the thread running through the rest of this article.
React Native Specific Security
1. Secrets do not belong in the bundle
Start here, because it's the most common M7 failure in RN codebases — and because no amount of obfuscation fixes it.
Two widely used tools make this easy to get wrong. Both of their docs are explicit.
react-native-config's README states that the module doesn't obfuscate or encrypt secrets for packaging, and that you should not store sensitive keys in .env. It adds that it's basically impossible to prevent users from reverse engineering mobile app secrets, so design your app and APIs with that in mind.
Expo says never store sensitive secrets in EXPO_PUBLIC_ variables, because an end-user running your app has access to all the code and embedded environment variables. These are inlined into the bundle at build time.
// ❌ Both of these end up in the shipped bundle
import Config from 'react-native-config';
const key = Config.PAYMENTS_API_KEY;
const key2 = process.env.EXPO_PUBLIC_MAPS_SECRET;
What's fine to ship: things that are meant to be public — your API base URL, a publishable key designed for client use, a feature flag default. What isn't: anything that grants access by itself.
The fix for OWASP Scenario #1 is architectural. Move the secret to a server you control and have the app call that instead:
// ✅ The app never sees the third-party key
async function geocode(address) {
const res = await apiClient.post('/geocode', { address });
return res.data;
}
// Backend (Node/Express) — the key lives only here
app.post('/geocode', requireAuth, rateLimit, async (req, res) => {
const result = await thirdPartyGeocoder.lookup(req.body.address, {
apiKey: process.env.GEOCODER_KEY, // server-side env, never shipped
});
res.json(result);
});
Note the requireAuth and rateLimit. Without them you've just moved the open door — an attacker calls your proxy instead of the third-party API. The proxy has to be protected by user authentication, which the bare API key never was.
2. Enforce on the backend, not in the bundle
This is the fix for OWASP Scenario #2, and it's the single most important idea in this article.
// ❌ The entire protection is one condition in the JS bundle
function LevelScreen({ levelId }) {
const { isPremium } = useUser();
if (levelId > 3 && !isPremium) {
return <Paywall />;
}
// Level assets ship inside the app — they're already on the device
return <Level data={require(`./levels/${levelId}.json`)} />;
}
An attacker with hbctool finds that comparison, flips it, reassembles, and every level is free. The assets were already in the APK, so there's nothing left to stop them.
// ✅ The server decides, and the content isn't on the device until it does
function LevelScreen({ levelId }) {
const { data, error } = useLevel(levelId);
if (error?.status === 402) return <Paywall />;
if (!data) return <Loading />;
return <Level data={data} />;
}
// The client-side check is only UX. Flipping it gets the attacker nothing:
// the server returns 402 and no level data.
// Backend
app.get('/levels/:id', requireAuth, async (req, res) => {
const levelId = Number(req.params.id);
const user = await getUser(req.user.id);
if (levelId > 3 && !user.hasActiveEntitlement) {
return res.status(402).json({ error: 'Payment required' });
}
res.json(await loadLevel(levelId));
});
This is precisely OWASP's recommendation: required resources for a protected feature should only be delivered if the check succeeds locally and on the backend. The local check is for user experience. The backend check is the security boundary.
The same logic handles Scenario #3. If an AI model is your most valuable asset, the strongest protection is not shipping it — run inference on the server. If you must ship it for offline use, accept that it's extractable and weigh that honestly in your threat model.
3. App attestation: let the server ask "is this really my app?"
Backend enforcement answers what a request is allowed to do. App attestation answers a different question: is this request even coming from an unmodified copy of my app on a genuine device?
Both platforms provide a service for this — Play Integrity on Android and App Attest on iOS. Expo wraps both in @expo/app-integrity, which its docs describe as helping your server tell the difference between your real app on a real device and anything else: modified apps, scripts, emulators.
npx expo install @expo/app-integrity
# In a bare React Native app, install `expo` first
Android — Play Integrity
import * as AppIntegrity from '@expo/app-integrity';
// One-time preparation, e.g. at app launch
await AppIntegrity.prepareIntegrityTokenProviderAsync(CLOUD_PROJECT_NUMBER);
// Per sensitive request
async function purchaseWithIntegrity(payload) {
// hashRequest is your own helper: a SHA-256 over the request body,
// so the token is bound to this specific action
const requestHash = await hashRequest(payload);
const token = await AppIntegrity.requestIntegrityCheckAsync(requestHash);
return apiClient.post('/purchase', payload, {
headers: { 'X-Integrity-Token': token },
});
}
Expo's docs note that a token provider used for too long can expire, producing ERR_APP_INTEGRITY_PROVIDER_INVALID on the next request. Handle it by calling prepareIntegrityTokenProviderAsync again.
iOS — App Attest
The iOS flow has more steps, because it's built around a hardware-backed key:
import * as AppIntegrity from '@expo/app-integrity';
// isSupported is a property, not a function
if (AppIntegrity.isSupported) {
// 1. Generate a key in the Secure Enclave — once per user per device
const keyId = await AppIntegrity.generateKeyAsync();
// Persist keyId: there's no way to recover it later
// 2. Get a one-time challenge from your server (at least 16 bytes)
const { challenge } = await apiClient.post('/attest/challenge').then(r => r.data);
// 3. Ask Apple to attest the key, then send the result to your server
const attestationObject = await AppIntegrity.attestKeyAsync(keyId, challenge);
await apiClient.post('/attest/verify', { keyId, attestationObject });
}
// Later, for sensitive requests: sign them with the attested key
async function signedRequest(keyId, body) {
const { challenge } = await apiClient.post('/attest/challenge').then(r => r.data);
const clientData = JSON.stringify({ ...body, challenge });
const assertion = await AppIntegrity.generateAssertionAsync(keyId, clientData);
return apiClient.post('/sensitive', { clientData, assertion });
}
Details from Expo's docs that will bite you if you miss them:
- App Attest doesn't work on the iOS Simulator — test on real devices
- Keys survive app updates but not reinstallation, device migration, or restoring from backup — plan for re-attestation
- If
attestKeyAsyncfails withERR_APP_INTEGRITY_SERVER_UNAVAILABLE, retry later with the same key; for any other error, discard the key and generate a new one - Don't reuse one key across multiple users on the same device — it makes certain fraud harder to detect
The part the library doesn't do
Every attestation library says some version of this, and it's the whole point: the library only produces tokens. Your server has to verify them. Your backend is responsible for:
- Generating unpredictable, single-use challenges so tokens can't be replayed
- Verifying that each token genuinely comes from Google or Apple
- Verifying that the token is bound to the challenge (or request hash) your server issued
- Deciding what to do with the verdict
// Server flow — pseudocode, not a specific library
POST /attest/challenge
challenge = randomBytes(32)
store(challenge, userId, expiresIn: 60s)
return challenge
POST /purchase
token = header['X-Integrity-Token']
verdict = verifyWithGoogle(token) // Play Integrity decode
if not verdict.matchesRequestHash(body): reject
if not verdict.appRecognized: reject // repackaged / re-signed
if not verdict.deviceIntegrity: step-up or reject
proceed
Consult Google's Play Integrity verdict documentation and Apple's Validating apps that connect to your server for the real verification steps — they involve certificate chain validation that you should not hand-roll from a blog post.
One design decision you'll face: some devices simply don't support attestation. Expo's docs, following Apple, suggest gracefully bypassing the service when the compatibility check fails. Others argue for zero tolerance on unattested requests. The practical answer is usually tiered — allow unattested requests for low-risk actions, require attestation for payments and account changes.
4. JavaScript obfuscation: what it buys, and what it doesn't
In M2 we set up a protection stack of JS obfuscation, Hermes, and R8. Here's an honest accounting of what the obfuscation layer contributes.
obfuscator-io-metro-plugin runs javascript-obfuscator over your bundle during the Metro build. This is the configuration from the plugin's README:
// metro.config.js
const jsoMetroPlugin = require('obfuscator-io-metro-plugin')(
{
// javascript-obfuscator options
compact: false,
sourceMap: false,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
numbersToExpressions: true,
simplify: true,
stringArrayShuffle: true,
splitStrings: true,
stringArrayThreshold: 1,
},
{
runInDev: false,
logObfuscatedFiles: true, // writes obfuscated files to ./.jso for inspection
}
);
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
...jsoMetroPlugin,
};
Merge this with your existing Metro configuration rather than replacing it wholesale.
One note on the option names: these are javascript-obfuscator options, and some were renamed across its major versions — you'll find READMEs in the wild using shuffleStringArray where this one uses stringArrayShuffle. Check the option list for the javascript-obfuscator version your plugin actually pulls in; an option name that no longer exists is silently ignored, so you can end up with less obfuscation than you think.
Now the caveats, which matter more than the config:
It only obfuscates your code, not node_modules. The plugin's README says so directly. Any logic living in a dependency stays readable.
Source maps and crash reporting get harder. The README says the source map generated after obfuscation isn't useful right now. There's also an open issue on Sentry's React Native repo about line numbers not mapping correctly when this plugin and Sentry are combined. Decide in advance how you'll debug production crashes.
It raises cost; it doesn't create a boundary. OWASP's own trade-off applies: obfuscation makes the control flow harder to follow, which slows down someone looking for your license check. It does not make that check trustworthy. Section 2 is still what actually protects Scenario #2.
Test that your app still works. Aggressive settings like controlFlowFlattening can break code that relies on specific names or structure, and cost performance. OWASP flags exactly this: libraries relying on certain strings or symbols may not work under full obfuscation.
5. R8 / ProGuard: covers less of an RN app than you'd think
Every RN Android template ships with this in android/app/build.gradle:
/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
*/
def enableProguardInReleaseBuilds = false
android {
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}
Two things to notice:
- It's off by default. If you've never changed it, your Java/Kotlin layer ships unshrunk and unobfuscated.
-
The template's own comment says what it covers: Java bytecode. R8 operates on the native layer — the RN runtime, native modules, and SDKs. It doesn't touch
index.android.bundle, which is where your screens and business logic live.
Turning it on is still worthwhile: it shrinks the APK and obfuscates native module code, including any custom native code you wrote. Expect to add -keep rules for libraries that rely on reflection, and test the release build thoroughly before shipping.
Just don't mistake it for protecting your app logic. In an RN app, R8 protects the minority of your code.
6. Runtime detection: useful signals, bypassable by design
On-device detection checks for environments where tampering is likely: rooted or jailbroken devices, debuggers, hooking frameworks. Two libraries cover most RN use.
jail-monkey
Lightweight and focused on root/jailbreak signals:
import JailMonkey from 'jail-monkey';
import { Platform } from 'react-native';
export async function getDeviceRiskSignals() {
return {
jailbroken: JailMonkey.isJailBroken(),
mockLocation: JailMonkey.canMockLocation(),
// ⚠️ isDebuggedMode returns a Promise — it must be awaited.
// Without await, the Promise object is always truthy and
// every device reports as being debugged.
debugged: await JailMonkey.isDebuggedMode(),
// Android only — returns false on iOS
suspiciousApps: Platform.OS === 'android' && JailMonkey.hookDetected(),
adbEnabled: Platform.OS === 'android' && JailMonkey.AdbEnabled(),
};
}
Note what hookDetected() actually does according to its README: it detects suspicious installed applications. That's a useful signal, but it isn't the same as detecting an active Frida session.
The README also warns that emulators are usually rooted, so you may want to bypass these checks during development.
freeRASP
Broader runtime protection from Talsec, with a callback per threat type. The threat most relevant to M7 is appIntegrity — it fires when the app has been repackaged or re-signed, which is OWASP's redistribution vector:
import { useFreeRasp } from 'freerasp-react-native';
const config = {
androidConfig: {
packageName: 'com.yourapp',
// Your RELEASE signing certificate hash(es), base64-encoded
certificateHashes: ['YOUR_RELEASE_CERT_HASH_BASE64='],
supportedAlternativeStores: [],
},
iosConfig: {
appBundleId: 'com.yourapp',
appTeamId: 'YOUR_TEAM_ID',
},
watcherMail: '[email protected]',
isProd: !__DEV__,
killOnBypass: true,
};
const actions = {
appIntegrity: () => reportThreat('repackaged_or_resigned'),
hooks: () => reportThreat('hooking_framework'),
privilegedAccess: () => reportThreat('root_or_jailbreak'),
debug: () => reportThreat('debugger'),
unofficialStore: () => reportThreat('unofficial_store'),
simulator: () => reportThreat('simulator'),
};
export default function App() {
// Must be called at the top level of the component — not inside useEffect
useFreeRasp(config, actions);
return <RootNavigator />;
}
Use the exact action names from the official docs. You'll find tutorials online using names like rootDetected or hookDetected — those aren't the library's names, and callbacks with the wrong names will silently never fire.
How to use these signals honestly
Here's the thing OWASP says plainly: an integrity check on the device can itself be found and deactivated, like any other local security check. Everything in this section runs inside the environment the attacker controls.
So treat detection as signal, not enforcement:
// ❌ Local verdict as the security boundary — patch this one `if` and it's gone
if (!JailMonkey.isJailBroken()) {
unlockPremiumFeatures();
}
// ✅ Report the signal; let the server weigh it with everything else it knows
async function reportThreat(type) {
try {
await apiClient.post('/security/signals', { type, at: Date.now() });
} catch (e) {
// Don't let a reporting failure crash the app, but don't hide it either
console.error('Failed to report security signal', e);
}
}
The server can combine device signals with attestation verdicts, account history, and request patterns, and decide whether to step up authentication, restrict an action, or flag the account. An attacker can suppress the report — but then the server sees an app that never reports anything, which is a signal of its own when combined with attestation.
And be careful about false positives. Root detection heuristics misfire on some legitimate devices, which is why jail-monkey exposes a granular breakdown of its Android detection methods. Blocking paying customers because of a heuristic is its own business impact.
7. How the layers fit together
No single layer here is sufficient. Each one addresses a different part of the problem:
| Layer | What it protects against | What it doesn't |
|---|---|---|
| No secrets in the bundle | Scenario #1 entirely | — |
| Backend enforcement | Scenario #2; any local check being patched | Needs the server to be authoritative |
| App attestation | Repackaged/modified apps and scripts reaching your API | Needs correct server-side verification |
| JS obfuscation | Casual reading of your logic | A determined attacker; node_modules
|
| R8/ProGuard | Reading the native layer | Your JS bundle |
| Runtime detection | Provides signals about risky environments | Being disabled on the device |
Notice that the two strongest layers — no secrets and backend enforcement — cost nothing in tooling. They're design decisions. The rest raise the cost of an attack, which is what OWASP means by making breaking the protection more expensive than the gain.
Testing Strategies
The best test for M7 is the one OWASP recommends: attack your own binary.
Inspect your own release build
# 1. Extract your release APK
unzip app-release.apk -d extracted/
# 2. Confirm the bundle format
file extracted/assets/index.android.bundle
# 3. Look for secrets in the bundle's strings.
# Add the prefixes your own providers use — check their docs for the
# format of a live key rather than relying on a generic pattern list.
strings extracted/assets/index.android.bundle | grep -iE "api[_-]?key|secret|token"
# 4. Decompile the JS layer
pipx install hermes-dec
hbc-decompiler extracted/assets/index.android.bundle decompiled.js
# 5. Search the decompiled output for your license/premium checks
grep -n -iE "premium|entitlement|isPaid|license" decompiled.js
If step 3 finds a live secret, stop and rotate it — the key is already compromised the moment it shipped. If step 5 finds a single condition gating paid content that's already in the APK, that's OWASP Scenario #2 in your own code.
Verify your protections actually engaged
# Did obfuscation actually run? logObfuscatedFiles writes output here:
ls ./.jso/
For R8, check whether a mapping file was produced — it only exists if minification actually ran. The Android Gradle plugin writes it under your module's build/outputs/ directory, organised by build variant; find the exact path for your setup with:
find android/app/build/outputs -name "mapping.txt"
Automated static analysis
MobSF runs static analysis on APK and IPA files and reports hardcoded secrets, insecure configuration, and more. Running it in CI against every release build catches regressions — like someone adding a key to .env six months from now.
Manual test scenarios
| Test | Method | Expected |
|---|---|---|
| Secrets in bundle |
strings + grep on release bundle |
No live keys |
| Premium bypass | Patch the client-side check, request premium content | Server returns 402 |
| Repackaged app | Re-sign the APK with a different key, run it | Attestation fails server-side; appIntegrity fires |
| Unattested request | Call your API with curl, no integrity token | Rejected for sensitive endpoints |
| Obfuscation quality | Run hbc-decompiler, try to find a known function |
Noticeably harder than before |
| Release build works | Full QA pass on the obfuscated, minified build | No crashes from obfuscation/R8 |
Tools and Resources
Analysis tools (for testing your own app)
| Tool | Use |
|---|---|
| hermes-dec | Disassemble and decompile Hermes bytecode |
| apktool | Decode Android APK resources and manifest |
| MobSF | Automated static and dynamic analysis |
| Ghidra | Native binary reverse engineering |
| otool | Inspect iOS Mach-O binaries |
React Native libraries
| Library | Purpose | Note |
|---|---|---|
@expo/app-integrity |
Play Integrity + App Attest | iOS: no Simulator support |
obfuscator-io-metro-plugin |
JS obfuscation in Metro | Excludes node_modules
|
freerasp-react-native |
Runtime threat detection | Includes repackaging detection |
jail-monkey |
Root/jailbreak signals |
isDebuggedMode is async |
Useful resources
| Resource | URL |
|---|---|
| OWASP M7 | owasp.org/www-project-mobile-top-10 |
| MASTG — Tampering and Reverse Engineering | mas.owasp.org |
| Play Integrity API | developer.android.com/google/play/integrity |
| App Attest | developer.apple.com/documentation/devicecheck |
| hermes-dec | github.com/P1sec/hermes-dec |
Conclusion
M7 is the item where React Native changes the picture most. OWASP notes that fully compiled apps like iOS apps are harder to reverse than Android bytecode, with a caveat for cross-platform technologies. In RN, your logic lives in a Hermes bundle built from one codebase and shipped on both platforms, and open-source tools read it.
That sounds bleak, but the conclusion OWASP draws is practical: you can't make a binary unbreakable, so stop relying on the binary to keep secrets or enforce rules.
🎯 Security Roadmap
1. Beginner level
- Move every secret out of
.env/EXPO_PUBLIC_and behind your own authenticated API - Enforce all paid features and permissions on the backend
- Run
stringsandhbc-decompileron your own release build - Enable R8 (
enableProguardInReleaseBuilds = true) and QA the release build
2. Intermediate level
- Add app attestation (Play Integrity / App Attest) with proper server-side verification
- Add JS obfuscation and decide on a production debugging strategy
- Add runtime detection that reports signals to the server
- Run MobSF against every release build in CI
3. Enterprise level
- Tiered policy: attestation required for high-risk actions
- Server-side risk scoring combining attestation, device signals, and behaviour
- Monitoring for repackaged copies in third-party stores
- Commercial obfuscation / RASP where your threat model justifies the cost
- Penetration testing of the binary
Key Takeaways
Your binary is public. Exploitability, prevalence, and detectability are all rated EASY or COMMON. Assume it's already been downloaded and opened.
Hermes bytecode is not obfuscation. It's a performance feature, and since RN 0.70 it's the default on iOS as well as Android. Open-source tools decompile it, and others can reassemble a modified bundle — though which tool works depends on your bytecode version, so test on your own build.
R8 protects your native layer, not your JS. In an RN app, that's the minority of your code — and it's off by default.
A secret in the bundle is not a secret. Both
react-native-configand Expo say so in their own docs. The fix is architectural: a server-side proxy with authentication.Local checks are UX; server checks are security. A client-side
if (isPremium)protects nothing once someone patches it. The server has to be the authority.Attestation lets the server verify the app itself — but only if the server actually verifies the token. The library just produces it.
Obfuscation and runtime detection raise the cost of an attack. That's genuinely valuable, and it's what OWASP recommends. It's just not a boundary, and it shouldn't be treated as one.
Next Steps
In our next article, we'll examine M8: Security Misconfiguration — insecure defaults, debug flags left on in production, exported components, and misconfigured permissions.
References
- OWASP Mobile Top 10 2024 — M7
- MASTG — Tampering and Reverse Engineering
- hermes-dec (P1 Security)
- Expo — AppIntegrity
- Expo — Environment variables
- react-native-config
- obfuscator-io-metro-plugin
- freeRASP for React Native
- jail-monkey
- Play Integrity API
- Apple — Validating apps that connect to your server
This article is the seventh in the OWASP Mobile Top 10 2024 series. Previous articles covered M1 through M6. Follow along for the rest of the series!
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.