Documentation

Go to Portal Website

Dead Code Injection

PlanPlatformsMASVS
TeamAndroidMASVS-RESILIENCE-3

Overview

DeadCodeInjection inflates the reverse-engineering surface area of Android applications by injecting fake methods, decoy fields, and unreachable instruction blocks into the compiled smali bytecode. This control significantly increases the amount of code an attacker must analyze while producing zero runtime overhead, as all injected code is provably dead and never executed.

How It Works

Android

DeadCodeInjection operates on decompiled smali files after APK disassembly and before final reassembly. It performs three distinct injection strategies:

1. Fake Private Static Methods

Generates realistic-looking private static methods with plausible names (validateSession, encryptPayload, computeChecksum, etc.) containing:

These methods are never invoked from any real code path but appear legitimate to static analysis tools like jadx, Ghidra, and apktool.

Density: Up to 2 methods per class, maximum 200 methods app-wide

2. Decoy Static/Instance Fields

Injects field declarations with security-adjacent names suggesting crypto keys, API endpoints, or session state:

These fields are never initialized or referenced, but static tools cannot easily distinguish them from legitimate sensitive data.

Density: Up to 3 fields per class, maximum 500 fields app-wide

3. Unreachable Instruction Blocks

Inserts bogus instruction sequences (nops, arithmetic operations) after unconditional goto statements within existing method bodies:

goto :label_xyz
:dead_label
const/16 v0, 0x42
xor-int/2addr v0, v0
nop

These blocks are dead by construction but inflate method size and confuse control-flow analysis.

Density: 20% probability after each goto, maximum 300 blocks app-wide

iOS

Not supported. iOS binaries are compiled to native machine code without an intermediate representation suitable for smali-level injection.

Threats Mitigated

How to Enable the Control

Navigate to Code Obfuscation from the AppTego portal, and expand the Control Flow Obfuscation section. Under this section you will find the Dead Code Injection control. Click Enable to apply it to the next protected build.

API Configuration Example

{
  "DeadCodeInjection": {
    "protection": true
  }
}
FieldPurpose
protectionEnables dead code injection for protected builds.

Configuration & Defaults

SettingDefaultDescription
enabledfalseEnable or disable dead code injection

Dead code injection is applied automatically to all customer smali classes when enabled. System classes (Android framework, Google libraries, Kotlin stdlib) are excluded.

Recommended Configuration:

Caveats & Limitations

Android

iOS

Platform Support

PlatformSupported VersionsNotes
AndroidAll (API 26+)Operates on smali files post-R8
iOSNot supportedNo smali equivalent for native code

Integration Example

Android (Build Configuration)

Dead code injection is applied automatically during the build pipeline when the control is enabled. No code changes are required in the application.

Example Configuration (JSON):

{
  "obfuscation": {
    "DeadCodeInjection": true
  }
}

The AppTego protected build system will:

  1. Decompile the R8-minified APK to smali
  2. Inject fake methods, decoy fields, and unreachable blocks
  3. Reassemble and sign the protected APK

iOS

Not applicable.


Last Updated: 2026-04-22