Frida is a dynamic instrumentation toolkit that lets you inspect and modify a running application. In authorized Android assessments it is the standard way to understand runtime behaviour, trace functions, and work around client-side protections such as certificate pinning and root detection. This guide sets up a test environment and shows reusable patterns, all within the OWASP Mobile Application Security Testing Guide (MASTG).
Instrumentation and pinning bypass are legitimate techniques in authorized mobile assessments. Doing this against an app or service without permission may breach terms of service or law. Test only apps you build or are explicitly scoped to assess, on a device you control.

Setting up the environment
You need frida-tools on your workstation and frida-server on a rooted test device or emulator.
# Workstation
pip install frida-tools
frida --version
# Download the matching frida-server for the device architecture from the
# Frida releases page, push it and run it (versions must match frida-tools)
adb push frida-server /data/local/tmp/
adb shell "chmod 755 /data/local/tmp/frida-server"
adb shell "su -c /data/local/tmp/frida-server &"
On a non-rooted device you can instead embed the Frida Gadget into a repackaged build of an app you are authorized to test. The version of frida-tools and frida-server/Gadget must match exactly, or hooks silently fail.
Finding and attaching to the app
# List running processes / installed apps
frida-ps -Uai
# Spawn the app under instrumentation (recommended, so you hook early)
frida -U -f com.example.app -l hooks.js --no-pause
# Attach to an already running process
frida -U -n "Example" -l hooks.js
Spawning with -f is important: many checks run during startup, so attaching afterwards misses them.
Tracing functions
# Trace Java methods matching a pattern
frida-trace -U -f com.example.app -j '*!*login*'
# Trace native (libc) functions
frida-trace -U -n Example -i "open" -i "strcmp"
Hooking Java methods
A Frida script runs inside the app and can read arguments, change return values and call original implementations.
Java.perform(function () {
// Observe arguments and return value of a method
var Login = Java.use('com.example.app.AuthManager');
Login.verify.implementation = function (user, pass) {
console.log('[hook] verify(' + user + ', ' + pass.length + ' chars)');
var result = this.verify(user, pass); // call the real method
console.log('[hook] verify returned ' + result);
return result;
};
});
Bypassing certificate pinning (for traffic analysis)
To inspect an app’s API traffic through your proxy during an authorized test, you often need to relax pinning. Rather than paste a brittle script, use a maintained one such as the community “universal” Android pinning-bypass scripts from the Frida CodeShare repository, and load it alongside your proxy CA:
# Load a maintained CodeShare pinning-bypass script by handle
frida -U -f com.example.app --codeshare pcipolloni/universal-android-ssl-pinning-bypass-with-frida --no-pause
With pinning relaxed and your proxy’s CA trusted by the test device, the app’s HTTPS requests appear in your intercepting proxy for review. Document exactly what you changed; the finding is “the app can be made to trust an attacker-controlled CA via X”, and the fix is stronger, defence-in-depth pinning plus server-side controls.
Root and tamper detection
Apps frequently check for root or for being run under a debugger. During an assessment you hook the detection method to understand and document it:
Java.perform(function () {
var Checks = Java.use('com.example.app.security.RootCheck');
Checks.isDeviceRooted.implementation = function () {
console.log('[hook] root check called — reporting result for the write-up');
return this.isDeviceRooted(); // observe first; override only if scoped to
};
});
Report what the protection does and how robust it is. Client-side checks raise the bar but can always be bypassed on a device the user fully controls — so the real recommendation is to never rely on them as the only control and to enforce security server-side.
Troubleshooting
- Nothing hooks: version mismatch between frida-tools and frida-server, or you attached too late — use
-fto spawn. - Class not found: names are obfuscated; enumerate with
Java.enumerateLoadedClasses()or map names from the decompiled APK. - Logic is in native code: switch to
Interceptor.attachon exported symbols or offsets.
Key takeaways
- Spawn with
-fso you hook startup checks before they run. - frida-tools and frida-server versions must match exactly.
- Pinning bypass is for inspecting traffic in authorized tests — use maintained CodeShare scripts and document the change.
- Client-side root/tamper checks raise the bar but can’t be the only control; enforce security server-side.
Frequently asked questions
Does Frida require a rooted device?
Running frida-server requires root. On non-rooted devices you can embed the Frida Gadget library into a repackaged APK of an app you are authorized to test.
Why does my Frida script not hook anything?
Common causes are a version mismatch between frida-tools and frida-server, attaching after the code already ran (use spawn with -f), obfuscated class names or methods implemented in native code.
Is bypassing SSL pinning legal?
It is a standard technique in authorized mobile assessments (OWASP MASTG). Doing it against apps or services without permission may breach terms of service or law. Test only within an agreed scope.
