1

Our team is trying to secure a native Android mobile app.

Amongst other things we are using Dexguard for some checks such as tamper, root and emulator detection.

Long story short: some of these checks fail in our debug builds - mainly because we want to keep the build times short for developers - and we need some way to skip them [1].

The suggestion by official Dexguard support was to use something like this:

if(!BuildConfig.DEBUG){
    // do actual check if app has been tampered with
}

Now I'm worrying:

Doesn't such a conditional make the tampering checks very easy to circumvent for an attacker?

My fear is that if an attacker tries to tamper with the app, he can easily do so if he is also able to somehow make it think that it is a DEBUG build. Thus with little effort all the (expensive) Dexguard tamper checks are circumvented...

Are my concerns justified? Does including a conditional such as above make tampering the app easier for attackers?


[1]: The background here is: Dexguard makes builds take a looong time. Such as 50 seconds instead of 5 seconds for a simple unit test re-run. Because of this we disable Dexguard for our debug build, which in turn makes certain of the checks (such as tamper detection) fail, as they rely on the APK being processed by Dexguard.

3

As your sample code shows if the attacker uses a debug version he can easily bypass the security checks. Actually you need compiler directives to do that.

Using compiler directives the portion of codes marked as DEBUG never compile to final application and because of that you are safe using that method.

  • Do you know of a way to achieve this in native Android development? I'd be interested in any resources. – fgysin Feb 4 at 10:50
  • @fgysin: Check this question. – Xaqron Feb 5 at 20:35
  • Yeah, thanks, but that is for C++... I'm looking for a way to achieve this natively in Android. I'm certainly not going through the hassle of NDK on Android just to avoid the above anti pattern. – fgysin Feb 6 at 6:49
  • @fgysin What do you mean by native? Whatever language you use for writing the code, if it supports compile directives you can use it. – Xaqron Feb 6 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.