TL;DR
Yes, a signed mobile application can be altered, although it’s not simple and breaks the chain of trust. Attackers typically repackage the app with malicious code after compromising the signing key or exploiting vulnerabilities in the build process. Regular security checks, protecting your signing keys, and using robust build systems are vital.
How App Signatures Work
When you publish an app (Android APK or iOS IPA), it’s digitally signed with a unique certificate. This signature verifies:
- Authenticity: The app genuinely comes from you, the developer.
- Integrity: The app hasn’t been tampered with since signing.
If even one byte of the app changes after signing, the signature becomes invalid.
Ways an App Can Be Altered After Signing
- Compromised Signing Key: This is the worst-case scenario. If an attacker gains access to your private key, they can sign their own malicious versions of your app.
- Prevention: Store signing keys securely (Hardware Security Modules – HSMs are best). Limit access strictly. Rotate keys periodically.
- Repackaging (Android): Android apps (APKs) are essentially ZIP files. Attackers can:
- Decompile the APK using tools like
apktool.apktool d your_app.apk - Modify the decompiled resources and code.
- Rebuild the APK.
apktool b your_app -o new_app.apk - Sign the repackaged APK with their own key (or, if they’ve compromised yours, your key).
- Decompile the APK using tools like
- Binary Patching: Attackers can directly modify the app’s executable code.
- This requires advanced skills and knowledge of the app’s architecture.
- Tools like disassemblers (e.g., IDA Pro) are used to find and change instructions.
- Exploiting Build System Vulnerabilities: If your build process has weaknesses, attackers might inject malicious code during the build.
- Ensure secure CI/CD pipelines.
- Use tamper-proof build environments.
- Dynamic Instrumentation (Runtime Manipulation): Tools like Frida allow attackers to modify app behaviour at runtime without altering the APK file itself. This is often used for testing but can be abused.
- This doesn’t change the signature, but it alters how the app functions.
Detecting Alterations
- App Store Checks: Both Google Play and Apple App Store perform checks to verify signatures.
- However, these aren’t foolproof; they primarily detect obvious signature mismatches.
- Root/Jailbreak Detection: Implement code in your app to detect if the device is rooted (Android) or jailbroken (iOS). Altered apps are more likely on compromised devices.
- Be aware that root/jailbreak detection can be bypassed.
- Integrity Checks: Include checksums or hashes of critical app components and verify them at runtime.
- If the hash doesn’t match, it indicates tampering.
- Code Obfuscation & Tamper Detection Libraries: Use tools to make your code harder to reverse engineer and detect modifications.
- Examples include ProGuard (Android) and DexGuard.
- Regular Security Audits: Have security professionals review your app’s code and build process for vulnerabilities.
Protecting Your App
- Secure Key Storage: Use HSMs or secure key management services.
- Robust Build System: Implement strong access controls and tamper detection in your CI/CD pipeline.
- Code Obfuscation: Make it harder for attackers to understand and modify your code.
- Regular Updates: Patch vulnerabilities promptly.
- Monitor App Reputation: Watch for reports of suspicious app versions or behaviour.