RASP Explained: Protecting Android Apps at Runtime
Runtime Application Self-Protection in plain terms — the detect, decide, respond loop, how policies turn signals into actions, and where RASP fits alongside server-side security.
- #rasp
- #runtime protection
- #mobile security
- #policy engine
Table of contents
Traditional application security happens before release: code review, static analysis, penetration tests. Runtime Application Self-Protection (RASP) adds a layer that ships inside the app and keeps working after release — on devices you'll never see.
The core loop: detect → decide → respond
Rendering diagram…
- Detect — modules collect signals: root, hooking frameworks, debuggers, emulators, repackaging, insecure networks.
- Decide — a policy engine weighs signals and context (which screen, which user action).
- Respond — log, warn, degrade a feature, require step-up auth, or block.
Signals are not decisions
A common mistake is wiring detection directly to exitProcess(). That makes every false positive a crash and gives attackers a clear signal of exactly which check fired.
Separating detection from policy lets you tune responses without shipping new detection code:
enum class Threat { ROOT, HOOK, DEBUGGER, TAMPER, EMULATOR }
enum class Action { ALLOW, LOG, STEP_UP, BLOCK }
data class Context(val screen: String, val sensitive: Boolean)
fun interface Policy {
fun decide(threats: Set<Threat>, ctx: Context): Action
}
val defaultPolicy = Policy { threats, ctx ->
when {
Threat.TAMPER in threats || Threat.HOOK in threats -> Action.BLOCK
ctx.sensitive && threats.isNotEmpty() -> Action.STEP_UP
threats.isNotEmpty() -> Action.LOG
else -> Action.ALLOW
}
}Continuous, not one-shot
Attackers frequently attach tools after launch. Effective RASP re-evaluates periodically and around sensitive actions, not just in Application.onCreate().
Telemetry closes the loop
Signals sent to a backend let security teams see attack trends, tune policies and correlate with fraud data. Keep telemetry privacy-conscious: collect what you need to make decisions, nothing more.
What RASP is not
- Not a replacement for secure code. It raises the cost of attacks; it doesn't fix vulnerabilities.
- Not a replacement for server-side validation. Anything the server can verify, it should.
- Not invisible. Determined attackers will study it — which is why layering and diversity matter.
Where it fits
| Layer | Examples |
|---|---|
| Build time | R8 obfuscation, SAST, dependency scanning |
| Runtime (client) | RASP detection and response |
| Network | TLS, certificate pinning |
| Server | Attestation verification, fraud rules, rate limiting |
RASP is strongest as part of this stack: the part that keeps watch on the device while everything else protects the edges.