Skip to content
Info disclosure Write-up Advanced

Breaking Down Mobile RASP: How I Analyzed Four Different Protection Systems and What They Taught Me About Runtime Security

The write-up analyses four Android RASP/packer products and shows how their runtime checks can be bypassed: memory is carved from outside the process with process_vm_readv to avoid the TracerPid anti-debug, and libc functions such as fopen, kill and the property getters are interposed with an LD_PRELOAD shim so the detectors see forged data and their kill switch is swallowed. The author also recovers a decrypted native module that was unlinked after dlopen by copying it through /proc/<pid>/map_files.

Motasem Hamdan Follow

Published on motasemhamdan.medium.com

I’ve been meaning to write this up for a while. A few days ago I came across a particular sample during research and figured it was finally the excuse I needed to document these techniques properly.

Motasem Hamdan, on motasemhamdan.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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the protection logic performs its detection and enforcement through hookable libc calls (fopen, kill, abort, property getters) rather than raw syscalls, and relies on TracerPid, which a non-attaching bulk memory read never sets.

Impact

On an emulator or rooted device the protections could be bypassed so that Frida stayed attached and the hidden bytecode was recovered, but the technique depends on controlling the device and does not stop an out-of-process SIGKILL.

What the attacker needed

Rooted device or emulator; ability to set the wrap property; attacker controls the device

The fix

Protection should perform its detection and enforcement through raw syscalls or in-kernel/out-of-process mechanisms that cannot be interposed, and should not rely on TracerPid alone.

How it was found

  1. Install the split APK and observe that attaching Frida normally kills the process immediately.
  2. Move frida-server off the default port and confirm the process still dies, then identify the port-27042 check as a secondary kill.
  3. List the native libraries and note which read /proc through libc and which use raw syscalls.
  4. Carve decrypted DEX files from the live process with process_vm_readv, scanning every offset for the DEX magic and using the header file_size.
  5. Decompile the carved DEX to recover the emulator-gate logic that was stripped from the on-disk APK.
  6. Build an LD_PRELOAD shim that filters /proc/self/maps and forges TracerPid, inject it via the wrap property, and confirm Frida stays attached.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Apps can ship their own protection code that watches for tools like Frida (a debugging/instrumentation framework) and kills the app when it spots one. This article shows that if those checks read files or send signals through the standard C library, an attacker who can preload their own version of that library can feed the checks fake answers and block the kill. It also shows that code decrypted into memory can be read from outside the process without triggering the anti-debugging tripwire.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by Motasem Hamdan

View all

4 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.