13 min read

Mobile Testing

Android Pentesting

Android testing combines static review, dynamic instrumentation, traffic analysis, local storage inspection, and platform control validation. Use a dedicated lab device or emulator, test accounts, and a signed scope before handling client application data.

Use a Dedicated Lab Device

Do not test client applications from a personal phone. Use a resettable emulator or enrolled test device, isolate proxy certificates and tooling, and avoid capturing production user data unless the RoE explicitly authorizes it.

MASVS is OWASP's mobile application security verification standard: a set of requirements an app is verified against, grouped by control area such as storage, cryptography, authentication, network communication and platform interaction, with assurance levels that set how much of the set applies to a given app. It is a different document from the Mobile Top 10 — the Top 10 names risk categories, MASVS states what to verify in each area — so the alignment claimed here is that these checkpoints are drawn from the MASVS control areas, not that an app tested with them has passed a MASVS assessment at any level.

MASVS Control Areas

A verification standard is read differently from a risk list. The Mobile Top 10 names the ways mobile apps fail; MASVS states, area by area, a condition that either holds in a build or does not, so that two testers looking at the same binary reach the same verdict. Its areas are storage, cryptography, authentication and authorization, network communication, platform interaction, code quality and build settings, resilience, and privacy. The page names areas rather than requirement identifiers, because an identifier belongs to a revision of the standard; what travels between engagements is the area, the condition and the artefact that shows the condition held.

The levels are the other half of the mechanism. The baseline level asks whether a control exists and is configured as claimed; the higher level asks the same question of controls that only matter once someone holds the binary; the resilience level applies only where the threat model includes an attacker willing to read, patch and rebuild the app. Nothing here states which level an app is held to — that is fixed in scope — but the table records the area each checkpoint exercises, because a finding filed against the wrong area is a finding the remediation will miss.

Checkpoint Control Area Evidence
Manifest permissions, exported components, deep linksPlatform interactionManifest entry, component name, platform response to another uid.
Backup flag and backup rulesStorageFlag value, rules resource, archive an adb backup produced.
Secrets, endpoints, debug togglesCode quality and build settingsDecompiled excerpt, the pattern used, the APK hash.
Preferences, SQLite, files, cache, logcatStorageAbsolute path, reading uid, artefact hash, redacted snippet.
Keystore use and cryptographic callsCryptographyCall site, key alias, hardware-backed or not.
TLS, cleartext policy, pinningNetwork communicationConfig excerpt, proxy history, failure once the proxy CA is removed.
Token lifetime, logout, step-upAuthentication and authorizationRequest pairs before, after and post-logout, plus a token replay.
Root, debug and tamper detectionResilienceDevice-state matrix against observed behaviour, and hook output.
Data collected by embedded SDKsPrivacySDK package name, directory, permissions the SDK pulled in.

The middle column is a filing instruction rather than a score: one observation can exercise two areas, and the note names the area the remediation belongs to. The right column fixes the artefact a reviewer has to see before the condition can be called met or unmet.

Assessment Flow

Static Review

  • Manifest permissions, exported components, deep links, backup flags.
  • Hardcoded secrets, API URLs, keys, debug code, and environment toggles.
  • Cryptography, certificate pinning configuration, and storage APIs.
  • Third-party SDKs and dependency risk.

Dynamic Review

  • Authenticated workflows through an intercepting proxy.
  • Runtime control behavior on rooted and non-rooted test profiles.
  • Local storage changes before and after sensitive actions.
  • Session timeout, token refresh, and offline behavior.

APK Collection and Static Analysis

android-static-analysis.sh
# Identify and pull an APK from a test device
adb shell pm list packages | grep target
adb shell pm path com.example.target
adb pull /data/app/<PACKAGE_PATH>/base.apk ./evidence/base.apk
sha256sum ./evidence/base.apk > ./evidence/base.apk.sha256

# Decode resources and inspect source-like output
apktool d ./evidence/base.apk -o ./work/app_decoded
jadx -d ./work/app_source ./evidence/base.apk

# Common static checks
rg -n "android:exported|allowBackup|debuggable|usesCleartextTraffic" ./work/app_decoded
rg -n "api[_-]?key|secret|token|password|client[_-]?secret|http://" ./work/app_source

The hash recorded against the pulled APK is what makes the rest of the note checkable. A package name and a version string do not identify a build, and an observation quoted against the current release stops being reproducible as soon as the client ships again.

Dynamic Testing Checkpoints

Every check below changes character with the state of the test device. A file that is readable only because the device is rooted is a device-compromise finding, unless the same data is reachable through a backup or a world-readable path; an app that exits or shows an error on a rooted device is enforcing a control, not failing one; and behaviour seen only on an emulator without Play services, or on one with writable system partitions, may never occur on a real handset. A debug or QA build also behaves differently on purpose, so confirm the release build was the one tested before any of this becomes a finding.

Area What to Validate Evidence
TransportTLS, certificate validation, proxy behavior, no cleartext fallback.Proxy history, network security config, screenshots.
AuthenticationToken lifetime, logout invalidation, MFA/step-up behavior.Request IDs, token metadata, server responses.
Local StorageSecrets in SharedPreferences, SQLite, files, logs, clipboard, backups.Redacted file paths, hashes, sanitized snippets.
Runtime ControlsRoot/debug/instrumentation detection and fail-safe behavior.Control matrix and user-visible behavior.

Hooking a check proves the check is client-side. It does not prove the server accepts the result, and those are two different findings. The same caution applies to what was read: a short-lived token, or an opaque reference the server can revoke, is not the exposure that a credential usable offline is. Data written by an advertising or analytics SDK into its own directory is that SDK's finding as much as the app's, and remediation for it may sit outside the app owner's control.

Where Levels Change the Job

Under the baseline level a documented control is evidence. A manifest excerpt showing allowBackup disabled, or a network security config that names its anchors and refuses cleartext, answers the condition as written: the configuration is the artefact, checked against platform defaults and against the app's own code paths. It is also the cheapest claim to reproduce, because the same file ships in every copy of the release.

Under the higher level the declaration is the hypothesis. The control has to hold on a build the client did not sign: a repackaged APK, one returned with the debuggable flag set, or a process with an instrumented runtime attached. The evidence becomes a pair — the same test on the unmodified build and on the hostile one — with the modification, a hash of both binaries and the observed difference. Attribution and reproducibility carry the weight, and so does the negative case: an app that refuses to start under instrumentation has shown a control working, and the note records the user-visible behaviour, because a refusal is also what a broken build looks like.

Evidence Notes Template

The template is not a form to fill in; it is the smallest set of facts that lets someone else reproduce the observation, and two of them are easy to drop. Record the uid that read a file alongside its absolute path, because without it the client cannot tell whether root was required, and a sandbox read and a device compromise land in different risk categories. For anything about storage or session state, capture the artefact before the action, after it and again after logout: that sequence is what attributes the change to the app rather than to the test account, and it is the only thing separating a cache from a retained credential.

android-evidence-note.yaml
finding_area: local-storage
app_id: com.example.target
app_version: 4.2.1
test_account: mobile-test-user-01
device_profile: android-14-emulator-rooted
artifact:
  type: sqlite-database
  path: /data/data/com.example.target/databases/session.db
  hash_sha256: <SHA256>
observation: access token persisted after logout
risk: token replay if device backup or local compromise occurs
recommended_fix: clear tokens on logout, store secrets in Android Keystore, enforce server-side token revocation
retest: repeat logout flow and confirm token is removed and rejected by API

Android Verification Depth

Five platform mechanisms decide what the evidence above is worth.

The debuggable flag

The android:debuggable attribute on the application element is a build property, not an app feature. Where it is set, the package's own uid can read its data directory through run-as, a debugger attaches without a rooted device, and any path gated on a debug check executes. A finding that depends on those conditions is a finding about the build, so the note names the binary and how it was obtained.

allowBackup and what a backup yields

android:allowBackup decides whether the platform's backup machinery copies app data; the backup rules resource decides which paths are eligible. An adb backup returns that selection, not the sandbox: preferences and databases appear where the rules permit them. Whether the device honours the command depends on its configuration, so the observation belongs to the test device, and the finding is what the archive contained.

Exported components and intent filters

android:exported and an intent filter answer different questions. The attribute says whether another app may start the component; the filter says which intents it accepts. A component can be exported, match a filter and carry no permission, which makes it reachable from any installed app; a filter does not prove reachability, because an intent that fails to match is refused. The evidence is the platform's response to a specific intent, with the calling uid recorded.

Network security config and where pinning is enforced

The network_security_config resource sets trust anchors per domain and whether cleartext is permitted, and the platform's network stack enforces it for connections that pass through that stack. A pin declared there covers those connections; a pin declared in the app's own HTTP client is enforced by that client; traffic from a bundled native library or a WebView with its own configuration sits outside both. The distinction decides the bypass, so the note records where the pin lives.

Root and tamper detection as a client-side assertion

Root, emulator and tamper checks run in the app's own process and read values an attacker controls: build properties, package lists, file paths, signature hashes. They are assertions, and the assertion is what gets tested — whether the app renders differently, refuses a sensitive action, or reports its state. Bypassing one shows the check is local; whether the server acts on the signal is a second test against the API. A detection is a speed bump, never a control that protects the data by itself.

Android Tools

MobSF

Analysis
Docs

Automated mobile static and dynamic analysis platform for Android and iOS.

Installation

docker run -it --rm -p 8000:8000 opensecurity/mobile-security-framework-mobsf:latest

apktool

Reverse Engineering
Docs

Decode Android resources and rebuild test APKs in lab environments.

Installation

brew install apktool

jadx

Decompiler
Docs

Dex to Java/Kotlin-like decompiler for source review.

Installation

brew install jadx

Frida

Instrumentation
Docs

Dynamic instrumentation toolkit for authorized runtime testing.

Installation

pip install frida-tools

Practice Lab

Write the app yourself, then proxy it from an emulator or a reset handset and install the interception CA so the request appears in your proxy — done when you can name the network-security-config decision that let it through, or the one that stopped it.

Proxy Your Own App Custom Lab easy
Proxy an emulator or a reset handset you control through mitmproxy or Burp SuiteInstall the interception CA on the device, not only on the hostRead network_security_config for the user-CA trust decisionKeep the proxy history, so the request is evidenced rather than described

Evidence to Capture

Device and OS: Model, Android version, security patch level and build fingerprint, plus whether the device was rooted, emulated or a physical handset.

Application identity: Package name, versionName and versionCode, with the SHA-256 of the APK that was tested.

File path: The absolute path inside the app sandbox and the uid that read it.

Hook output: The Frida or Objection command and its full console output, including the class or method that was hooked.

Request pair: The proxy history entry, with the app version and account captured alongside it, when the evidence is network-side.

Before and after: The same artefact captured before the action, after it and after logout.

Likely False Positives

  • Root-only access: A file readable only because the device is rooted.
  • Debuggable build: A debug or QA build tested instead of the release build.
  • Server-issued value read as a client secret: A token the server can revoke, graded as a stored credential.
  • Control bypassed by instrumentation: A hook that proves the check is client-side, not that the server trusts it.
  • App refuses to run: An exit or error on a rooted device, which is a control working.
  • Emulator-only behaviour: Behaviour seen only on an emulator.
  • Third-party SDK storage: Data written into a directory an SDK owns.

Testing Checklist

Device and build

  • ☐ Device, OS version and patch level recorded
  • ☐ Root state recorded, and whether it was required for the finding
  • ☐ App version and APK hash recorded
  • ☐ Release build confirmed rather than a debug or QA build

Storage

  • ☐ SharedPreferences, SQLite, files, cache and external directories reviewed
  • ☐ Keystore usage checked for actual keys rather than obfuscation
  • ☐ Logcat and clipboard scanned for tokens and personal data
  • ☐ Backup behaviour and the allowBackup flag tested
  • ☐ Data persistence after logout verified

Transport

  • ☐ Proxy interception attempted with and without a bypass
  • ☐ Network security config reviewed for cleartext and user CA trust
  • ☐ Pinning implementation identified before it is bypassed
  • ☐ Intercepted requests inspected for token and personal-data exposure

Platform interaction

  • ☐ Exported components and deep links enumerated
  • ☐ Runtime root and tamper detection behaviour recorded
  • ☐ Screenshot, task-switcher and overlay protections checked where required
  • ☐ Evidence captured in a form the client can reproduce without the lab device

Remediation & Defense

Client

  • • Store secrets, tokens and personal data in a Keystore-backed store rather than SharedPreferences or plain files
  • • Restrict or disable backup for sensitive files with explicit backup rules
  • • Clear tokens and cached personal data on logout and on account switch
  • • Remove hardcoded keys and endpoints, and fetch configuration from the server
  • • Keep runtime integrity checks as defence in depth, never as the only control

Transport

  • • Reject cleartext in the network security config
  • • Pin a public key with a backup pin and a documented rotation plan
  • • Validate the token audience and binding server-side rather than trusting the client

Server

  • • Bind tokens to the device or to a proof-of-possession key
  • • Shorten token lifetime and support server-side revocation per device
  • • Re-authenticate for sensitive operations regardless of the client check

Process

  • • Move root and tamper decisions server-side, or treat the client signal as advisory
  • • Include the release build in the retest scope
  • • Set an obfuscation and integrity-check baseline in the build pipeline