Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Going Beyond Obfuscation: Advanced Techniques f...

Going Beyond Obfuscation: Advanced Techniques for Protecting Android Apps

Protecting intellectual property and preventing app manipulation is a significant concern for many businesses, and sometimes obfuscation just won't cut it. In this talk, we'll discuss how mobile devs can go beyond basic code obfuscation by exploring techniques like anti-tampering, anti-debugging, root detection, and other runtime application self-protection (RASP) methods to protect an app's code and data from reverse engineering and exploitation.

This talk was given at Droidcon London 2025

Avatar for Ed Holloway-George

Ed Holloway-George

October 31, 2025
Tweet

More Decks by Ed Holloway-George

Other Decks in Technology

Transcript

  1. @sp4ghetticode / spght.dev Going Beyond Obfuscation Advanced Techniques for Protecting

    Android Apps Ed Holloway-George | Droidcon London 2025 |
  2. @sp4ghetticode / spght.dev Who am I? • Mobile Lead @

    Kraken 💚🌍 Go see John O’Reilly’s KMP/CMP talk tomorrow @ 14:55! • Android Google Dev Expert • I like to talk about mobile security a lot • Available on social media platforms (dog pics available) • Thanks for coming along & I hope you learn something new Introduction
  3. @sp4ghetticode / spght.dev (So you don’t get in trouble) •

    This content is educational • Test your own apps only • Always speak to your cyber security team and/or expert beforehand • Be a good developer 💚 • Don’t do anything illegal! A quick reminder…
  4. @sp4ghetticode / spght.dev “The practice of creating code that is

    intentionally difficult for humans or computers to understand” Obfuscation What is it?
  5. @sp4ghetticode / spght.dev ProGuard In the beginning… Eric Lafortune @

    Droidcon London 2014 • Initially released in 2002 for Java obfuscation / minification • Became a key part of the early Android ecosystem • Optimised and obfuscated Java bytecode before the step of converting to Dalvik bytecode • Configured via ‘rules’ • ’DexGuard’ is an enterprise solution with many enhanced features offered by GuardSquare (Go say hello!) / Image Source: Flickr
  6. @sp4ghetticode / spght.dev R8 Present Day • D8 and R8

    arrived as standard tooling in 2018 - Android Studio 3.0 • D8 replaced the old DX compiler for dexing • R8 is just D8 ‘on steroids’ • R8 provides additional shrinking, minification and obfuscation • Uses ProGuard’s configuration syntax It’s me! / Image Source: Androidify
  7. @sp4ghetticode / spght.dev android { buildTypes { release { isMinifyEnabled

    = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) } } } app/build.gradle.kts
  8. @sp4ghetticode / spght.dev # Example File (Do not use!) -verbose

    -allowaccessmodification -repackageclasses -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; } app/proguard-rules.pro
  9. @sp4ghetticode / spght.dev Yay or nay? Standard Android Obfuscation Tooling

    ✅ Tooling integrated into ecosystem ✅ Simple to enable ✅ Provides basic protection against primitive reverse engineering ✅ Provide other benefits such as minification ✅ Arguably ‘good enough’ for some apps 😅 Rules often written poorly and hard to test quickly 😅 Fundamentally, does not make reverse engineering impossible 😅 R8/ProGuard aren’t security tools! 😅 Don’t obfuscate code’s control- flow 😅 They don’t prevent or detect dynamic attacks when your app runs
  10. @sp4ghetticode / spght.dev What else can we do and why

    should we? Going Beyond Obfuscation ✅ Move any secrets / business logic out of the app! ✅ Threat Monitoring ✅ Implement a ‘know your customer’ style flow ✅ Protect ourselves against dynamic attacks with RASP 🤔 What are the risks to your app/business? 💡 Your IP 💡 Financial 💡 Reputational 💡 Customer Data
  11. @sp4ghetticode / spght.dev “Runtime Application Self-Protection is code that provides

    multiple defences against dynamic attacks, at runtime” RASP What is it?
  12. @sp4ghetticode / spght.dev “Runtime Application Self-Protection is code that provides

    multiple defences against dynamic attacks, at runtime” RASP What is it?
  13. @sp4ghetticode / spght.dev Dynamic Attacks Like what? • Binary Tampering

    • Code modification / injection • Repackaged with a new certificate • Exploiting a debuggable app • Running on virtual environments / emulators • Using root to do ‘funky things’™ • Using hooking frameworks
  14. @sp4ghetticode / spght.dev Dynamic Attacks Like what? • Binary Tampering

    • Code modification / injection • Repackaged with a new certificate • Exploiting a debuggable app • Running on virtual environments / emulators • Using root to do ‘funky things’™ • Using hooking frameworks
  15. @sp4ghetticode / spght.dev Dynamic Attacks Like what? • Binary Tampering

    • Code modification / injection • Repackaged with a new certificate • Exploiting a debuggable app • Running on virtual environments / emulators • Using root to do ‘funky things’™ • Using hooking frameworks RASP✨
  16. @sp4ghetticode / spght.dev 😈 An Attackers Cheatsheet 🤔 Remove license

    checks 🤔 Bypass paywalls 🤔 Modify behaviour 🤔 Add malware 🤔 ??? 🤔 Do bad things. Binary Tampering Smali Modification
  17. @sp4ghetticode / spght.dev Binary Tampering Defence #1 - Integrity Checks

    • We need to be confident our app hasn’t been modified • Check CRC hashes of critical files against known values
  18. @sp4ghetticode / spght.dev Binary Tampering Defence #1 - Integrity Checks

    ✅ 1529977198 ❌ 1836748125 Tampering detected? Resolution: Block app launch!
  19. @sp4ghetticode / spght.dev Binary Tampering Defence #2 - Certificate Verification

    An attacker will sign their clone with a different key How can we detect this?
  20. @sp4ghetticode / spght.dev Binary Tampering ✅ AB:CD:EF… ❌ BA:DE:D0… Tampering

    detected? Resolution: Block app launch (again)! Defence #2 - Certificate Verification
  21. @sp4ghetticode / spght.dev Binary Tampering Defence #3 - Embedded Dex

    (Android 10+) • As of Android 4.4 / 5.0 ART used pre- processing and ahead-of-time (AOT) compilation • Flag tells ART to go revert to old approach • No pre-processing • JIT compilation • Only use the DEX files packaged in the APK • ⚠ Performance Penalty!
  22. @sp4ghetticode / spght.dev Untrusted Environments Untrusted devices increases exposure to:

    • Tampering • Traffic interception • Etc. How can we detect this?
  23. @sp4ghetticode / spght.dev • Attestation • “An official verification of

    something as true or authentic” • Play Integrity API / Firebase App Check • Ensures legitimate device access • No EMUs / etc. • Blocks malicious requests / Source: Safeguarding user security on Android (IO/24) youtu.be/RccJYep2v5I Untrusted Environments Defence #1 - Device Attestation
  24. @sp4ghetticode / spght.dev • Detect if a user has a

    rooted device • But, root detection is difficult • Not always as simple as checking for specific files/ folders • Cat & Mouse game 😼🐭 Untrusted Environments Defence #2 - Root Detection
  25. @sp4ghetticode / spght.dev Root Detection in a nutshell • Look

    for specific known files • See if specific root apps are on-device • Check for disabled security settings • Attempt to run a command as root • ??? • Hope you are ahead of the game! Untrusted Environments Defence #2 - Root Detection
  26. @sp4ghetticode / spght.dev • TL;DR - Don’t run your own

    solution • Great enterprise solutions exist ✨💸 • Go meet them at their booths! • Free solutions too! • Play Integrity API • github.com/scottyab/rootbeer (old!) • github.com/talsec/Free-RASP-Community (new-er!) Untrusted Environments Defence #2 - Root Detection
  27. @sp4ghetticode / spght.dev • Modify app execution during runtime •

    Frida is the defacto framework used • Can be used to: • Read/Write variables • Run custom code • e.g. Root Detection Bypass, Modify Networking Endpoints, etc… Anti-Debugging / Hooking Hooking
  28. @sp4ghetticode / spght.dev Defence #1 - Detect Hooking Anti-Debugging /

    Hooking • Detect if a user has a hooking frameworks running • Again this is difficult • Check for common file(s) / processes • Iterate over TCP ports and check if they respond • Check for code modifications in memory • Easy(ish) for Native Libs • Very hard for Java/Kotlin code
  29. @sp4ghetticode / spght.dev • Trivial to patch manifest with android:debuggable

    • Then enabling ro.debuggable system property to allow debugging for all apps • Allows attackers to: • Analyse control flow • Set breakpoints • Inspect variables • Modify memory Anti-Debugging / Hooking Debugging
  30. @sp4ghetticode / spght.dev • Easy Mode: • Programatically check the

    manifest android:debuggable flag • Use Android’s own Debug class methods Anti-Debugging / Hooking Defence #2 - Detect Debugging
  31. @sp4ghetticode / spght.dev • Expert Mode: • Attempt to detect

    debug thread activity • Crash debuggers via modifying JDWP native data structures • Check for tracer process ids Anti-Debugging / Hooking Defence #2 - Detect Debugging Read more via OWASP MASTG
  32. @sp4ghetticode / spght.dev More RASP ideas! i.e. The stuff I

    just don’t have time for today • Detect sensor spoofing (e.g. location) • Detect app install location (e.g. Play Store) • Detect screen-sharing / screenshot capture • Certificate Pinning / Transparency • Listening for VPN usage
  33. @sp4ghetticode / spght.dev / Image Source: Wikipedia CC BY-SA 4.0

    The Swiss Cheese Model Tamper Detection Obfuscation Anti-Hooking
  34. @sp4ghetticode / spght.dev / Image Source: Wikipedia CC BY-SA 4.0

    The Swiss Cheese Model More cheese; Less problems Tamper Detection Obfuscation Anti-Hooking
  35. @sp4ghetticode / spght.dev What’s next? Your plan to go beyond

    obfuscation! • Remember default obfuscation isn’t foolproof • Look to go beyond obfuscation ✨ • Use device attestation • Detect rooted devices and hooking frameworks • Check your signing certificate(s) • Look for changes in critical file’s hashes
  36. @sp4ghetticode / spght.dev • OWASP MSVS-RESILIENCE • HackTricks - Mobile

    Pentesting • Talsec’s freeRASP • GuardSquare / Promon / Zimperium / etc - blogs • Checkout the other (maybe better?!) security talks at Droidcon today/tomorrow! Want to learn more?