Anti-Tamper
Protection ID: antiTamper
Anti-Tamper verifies your application's integrity at runtime by computing checksums of critical code sections. If the bytecode has been modified after Shield processing (by repackaging, patching, or injection) the verification fails and the application throws a SecurityException.
Configuration
shield {
protections {
antiTamper = true
}
}shield {
protections {
antiTamper = true
}
}How It Works
Anti-tamper protection ensures that your application has not been modified since it was built. During the build process, Shield computes integrity checksums of critical code sections and embeds them in the application. At runtime, the same sections are re-verified and compared against the stored values.
If any mismatch is detected, the application terminates. This protects against APK repackaging (attackers who unpack, modify, and repack the APK), bytecode patching (tools like Lucky Patcher that patch specific instructions), code injection (malicious code inserted into existing methods), and license bypass (modifications to license check or payment validation code).
Combining with Anti-Debug
Anti-Tamper and Anti-Debug protect against different attack phases:
| Attack Phase | Anti-Debug | Anti-Tamper |
|---|---|---|
| Analysis (understanding the code) | Blocks debuggers and Frida | |
| Modification (patching the code) | Detects changes | |
| Distribution (repackaging) | Detects repackaging |
Using both together creates a more complete defense:
protections {
antiDebug = true
antiTamper = true
}protections {
antiDebug = true
antiTamper = true
}When to Use
Anti-tamper is recommended for applications that implement in-app purchases or payment processing, contain license validation or subscription logic, handle sensitive user data, or distribute through channels where repackaging is common. It is one of the strongest protections against piracy and unauthorized modification.
Related
- Anti-Debug - Detect debuggers and analysis tools
- Protections Overview - All available protections