Android
AuraScore 81/100

Play Integrity and Root Environment Attestation Script

Create a Kotlin device posture and Play Integrity attestation script to defend banking apps against rooted runtimes.

Use this template when setting up anti-tamper, debugger detection, and Google Play Integrity API verification workflows for high-risk financial applications. It outputs automated Kotlin attestation scripts.

Template

Role: Staff FinTech Mobile Anti-Fraud Engineer with deep specialization in native runtime protection, app attestation, and anti-tamper defense.

Context

  • GCP Cloud Project Number: {{cloud_project_number}}
  • Android Application ID: {{package_id}}
  • Minimum Integrity Verdict: {{risk_tolerance_threshold}}
  • Security Gateway Endpoint: {{reporting_endpoint_url}}
  • Threat Response Policy: {{tamper_action_protocol}}

Task

Develop an end-to-end Kotlin runtime protection and Google Play Integrity verification script that assesses device authenticity, detects rooting or hooks, requests server-side token validation, and executes configured countermeasures.

Method

  1. Initialize Google Play Integrity Standard Integrity Manager utilizing {{cloud_project_number}}.
  2. Build a native check routine scanning for common rooting artifacts (su binaries, Magisk, KernelSU, busybox) and known hooking frameworks (Frida, Xposed).
  3. Check SELinux enforcement status and verify system property flags indicating test-keys or modified builds.
  4. Generate a cryptographically secure nonce tying the user session to the Play Integrity request.
  5. Warm up the integrity token provider and request an attestation token for {{package_id}}.
  6. Transmit the attestation token and local risk indicators to {{reporting_endpoint_url}} via secure coroutine channel.
  7. Parse server-validated verdicts against {{risk_tolerance_threshold}} (MEETS_DEVICE_INTEGRITY, MEETS_STRONG_INTEGRITY).
  8. Trigger {{tamper_action_protocol}} immediately upon verdict mismatch, debugger attachment, or runtime hook detection.

Constraints

  • Code MUST be modularized into a production-grade Kotlin singleton or dependency-injected service.
  • The script MUST NOT perform server-side token decryption locally on the client device.
  • Root checks MUST run asynchronously without degrading cold-start performance by more than 50 milliseconds.
  • The countermeasure execution MUST securely terminate the application process when fatal compromise is detected.

Output format

  • Section 1: Attestation Architecture & Nonce Generation Logic
  • Section 2: Complete Integrity & Anti-Root Script (Kotlin with Play Integrity SDK integration)
  • Section 3: Telemetry Reporting & Action Protocol Handler
  • Section 4: Backend Token Decryption & Verification Spec (JSON format expected by {{reporting_endpoint_url}})

Self-review

  • Ensure {{cloud_project_number}} and {{package_id}} are referenced correctly in the token provider setup.
  • Verify that native binary scanning includes stealth paths used by KernelSU and APatch.
  • Check that the nonce generation incorporates a cryptographic timestamp to prevent replay attacks.
AuraScore breakdown
81/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-android
financial-services
android
play-integrity
anti-fraud