Back to Blog
Red Team18 min read2024-12-28

Google Play Integrity API: How It Works & How to Bypass It

Deep dive into Google Play Integrity API, understanding app attestation mechanisms, device integrity verdicts, and practical techniques to bypass MEETS_DEVICE_INTEGRITY and MEETS_STRONG_INTEGRITY checks during Android security testing.

A

Asfaleia Team

Security Consultant

Google Play Integrity API: How It Works & How to Bypass It
Sections

Introduction to App Attestation

Any application that uses APIs and transfers sensitive data needs to verify the integrity of the environment it is running in. Specifically, it must continuously ensure that:

The API requests are coming from a legitimate device
The device is not rooted
The application APK has not been modified or tampered with

To achieve this, the concept of App Attestation was introduced. Some developers use it as an additional security layer with traditional root detection mechanisms.

For example, even if you successfully bypass root detection using tools like Magisk modules, the application may still refuse to work. In most cases, this behavior is caused by app attestation checks failing.

To standardize and strengthen this mechanism, Google introduced Play Integrity as an official solution for app attestation.

What is Play Integrity API?

Before the Play Integrity API existed, Google provided a set of APIs known as SafetyNet. It was used to perform app attestation, but it had several limitations and was not always reliable or accurate.

As a result, Google decided to replace SafetyNet with a more robust and modern solution: Play Integrity API.

According to the official documentation:

> The Play Integrity API helps you check that user actions and server requests are coming from your genuine app, installed by Google Play, running on a genuine and certified Android device. By detecting risky interactions — like those from tampered app versions, untrustworthy devices, or emulated environments — your backend server can respond with appropriate actions to prevent abuse and unauthorized access, fight fraud, combat cheating, and protect users from attacks.

How Play Integrity API Works

The Play Integrity API operates through a sophisticated verification process:

![Play Integrity API Flow](https://m4kr0.vercel.app/_astro/2.1.DvAL905G_1tsygN.webp)

Step-by-Step Flow

1Request Initiation: The application requests Play Integrity API to perform an integrity check on the device.
2Signal Collection: Google collects various signals from the device, including software and, in some cases, hardware-based data. This information is sent in encrypted form to `googleapis.com`.

![Signal Collection](https://m4kr0.vercel.app/_astro/2.2.B1LoUaQw_tiUoN.webp)

3Verdict Generation: Based on these collected signals, Google generates a verdict. The response is returned as a payload containing a JWT token, which includes all relevant information and is signed and encrypted by Google.
4Token Forwarding: The application receives this token and forwards it as-is to its backend server.
5Server Verification: The backend server verifies the token using Google's public key to ensure it was issued by Google. After verification, the server decrypts and parses the token to extract the verdict.

![Server Verification](https://m4kr0.vercel.app/_astro/2.3.D0WtBUcr_1PPh4A.webp)

Deep Dive: Key Attestation Mechanics

To understand how to bypass Play Integrity, we must first understand the underlying mechanism it relies on: Android Key Attestation.

The Chain of Trust

At its core, Android Key Attestation is a cryptographic protocol that allows a server to verify that a cryptographic key pair is stored in a device's hardware-backed keystore (Trusted Execution Environment - TEE, or StrongBox).

When an app requests attestation, the device produces an X.509 certificate chain:

1 Root Certificate: Signed by the Google Hardware Attestation Root key. This public key is embedded in the Android OS and known to Google's servers.
2 Intermediate Certificates: Signed by the Root or other Intermediates. These represent the batch of keys provisioned to a specific device model or factory line.
3 Leaf Certificate: The certificate for the specific key pair generated by the app. This certificate contains an Attestation Extension (OID `1.3.6.1.4.1.11129.2.1.17`).

The Role of keybox.xml

During the manufacturing process, a file (often referred to as `keybox.xml` in the custom ROM/rooting community) is provisioned to the device's TEE. This file contains a batch of private keys and their corresponding certificate chains. The TEE uses these private keys to sign the attestation certificates generated by apps.

Crucial Detail: The private keys in the keybox never leave the secure hardware (in a stock, locked device).

Hardware vs. Software Attestation

Hardware-Backed: The `attestationSecurityLevel` in the extension is set to `TrustedEnvironment` (1) or `StrongBox` (2). This means the key generation and signing happened inside the secure hardware, which is isolated from the Android OS (and thus isolated from root).
Software-Backed: If the TEE is unavailable or the device fails integrity checks (unlocked bootloader), the system falls back to software implementation. The `attestationSecurityLevel` is set to `Software` (0). The root of this chain is a software key, not the Google Hardware Root, and servers will reject it for high-security requirements.

Play Integrity Verdict Mechanisms

The verdict returned by the Play Integrity API is based on three main integrity mechanisms:

App Integrity

Verifies that the application has not been modified or tampered with
Returns the `appIntegrity` verdict

Device Integrity

Ensures that the device is genuine, certified, and not compromised (not rooted)
Returns the `deviceIntegrity` verdict

Account Integrity

Indicates whether the application was installed through the official Google Play Store
Returns the `accountDetails` verdict

Understanding the Verdicts

MEETS_BASIC_INTEGRITY

This ensures that the Attestation Token is generated by genuine Google Play Services and cannot be easily forged or tampered with by external modifications.

MEETS_DEVICE_INTEGRITY

The app is running on a genuine and certified Android device. This specifically verifies the absence of root access, unlocked bootloaders, and system-level tampering.

MEETS_STRONG_INTEGRITY

This requires `MEETS_DEVICE_INTEGRITY` and security updates in the last year for all partitions of the device, including an Android OS partition patch and a vendor partition patch.

Server Decision Making

Based on the verdict, the server decides how to handle the request:

One application may trust `MEETS_BASIC_INTEGRITY`
Another may require `MEETS_DEVICE_INTEGRITY`
A third may enforce `MEETS_STRONG_INTEGRITY`
Note: Most applications typically consider `MEETS_BASIC_INTEGRITY` and `MEETS_DEVICE_INTEGRITY` to be sufficient.

How Play Integrity Can Be Bypassed

Most Play Integrity bypass techniques rely on spoofing. Instead of sending the real device (rooted) properties or hardware fingerprint to the Play Integrity API, the application environment is manipulated to send the profile of a different, legitimate, and certified device.

TrickyStore Internals: The "Leaf Hack"

TrickyStore is a Zygisk module that spoofs the certificate chain to make a compromised (rooted) device appear as a valid, hardware-backed device.

1 Hooking the Keystore Service: TrickyStore uses Zygisk to inject code into the `system_server` or the `keystore` daemon processes. It hooks the functions responsible for generating the attestation certificate chain.
2 The Spoofing Mechanism: When an app requests attestation, TrickyStore intercepts the request and modifies the returned certificate chain. It performs a cryptographic surgery known as the "Leaf Hack".
3 The Stolen Keybox: The user provides a valid, unrevoked `keybox.xml` (dumped from a legitimate device) to TrickyStore.
4 Certificate Replacement: TrickyStore replaces the device's actual broken/software chain with the valid chain from the `keybox.xml`.
5 Signing the Lie: TrickyStore generates a *new* leaf certificate with the correct app details (Package Name: `com.example.app`) but claims it is `TrustedEnvironment`. It then signs this new leaf certificate using the private key from the stolen `keybox.xml`.

Result: The server sees a chain that traces back to Google's Root, is signed by a valid Intermediate, and has a Leaf that matches the app and claims hardware security.

Initial State - Before Bypass

This is the initial Play Integrity check result on a rooted device:

![Initial Play Integrity Check - Failed](https://m4kr0.vercel.app/_astro/2.4.B2RNbief_Z1huT6x.webp)

After installing Magisk modules without proper configuration:

![After Magisk Modules - Still Failing](https://m4kr0.vercel.app/_astro/2.5.DnyUlZKb_6J0Bw.webp)

Prerequisites for Bypass

Required Tools

ReZygisk: A Zygisk implementation module for Magisk
TrickyStore: Used for spoofing and modifying the certificate chain generated for Android key attestation
Tricky Addon: Used to add packages to `target.txt`
KSU Web UI: Makes configuration and editing easier from UI
Play Integrity API Checker APK: Verifies Play Integrity status
Key Attestation APK: Checks attestation status

![Tricky Addon Module](https://m4kr0.vercel.app/_astro/2.6.A8xVEhov_1iaNy3.webp)

Step 1: Hiding Root Detection

Before anything else, we need to hide root from the device:

1From Magisk settings, make sure that Zygisk is disabled
2Ensure that Magisk Hide is enabled
3Import the ReZygisk module to Magisk and reboot the device

Step 2: Bypass MEETS_DEVICE_INTEGRITY and MEETS_BASIC_INTEGRITY

`MEETS_DEVICE_INTEGRITY` specifically verifies the absence of root access, unlocked bootloaders, and system-level tampering. To bypass it, we need to spoof the device profile using a legitimate device.

`MEETS_BASIC_INTEGRITY` is expected to pass normally as long as there are no modifications by modules because its primary check is to verify that you are not using an emulator and that the Attestation Token sent to Google was not directly intercepted or tampered with.

However, once you start installing modules and making changes, it will no longer pass unless the modifications are done correctly.

Steps to Bypass

1Download the required modules (TrickyStore, Tricky Addon), import them into Magisk, and reboot the device
2From KSU Web UI, select `TrickyStore`

![TrickyStore in KSU Web UI](https://m4kr0.vercel.app/_astro/2.7.C39409Nr_26GrkA.webp)

3From the menu, choose Select All icon, then select "Deselect Unnecessary", and click Save

![TrickyStore Configuration](https://m4kr0.vercel.app/_astro/2.8.D98YqIxc_1Fp7V8.webp)

4From the "Keybox" option, choose "Valid" to download a new `keybox.xml`

![Download Valid Keybox](https://m4kr0.vercel.app/_astro/2.9.tKWCHdQ-_1O2Yd.webp)

Understanding keybox.xml

`keybox.xml` is a file storing vendor security credentials used in the Key Attestation process. The modules use a spoofed or replaced copy of this file (taken from a genuine device) to trick integrity checks into believing the device is certified and has a locked bootloader, thus achieving `MEETS_DEVICE_INTEGRITY`.

After completing these steps, check Play Integrity API Checker. Now `MEETS_DEVICE_INTEGRITY` and `MEETS_BASIC_INTEGRITY` should be successfully bypassed.

![MEETS_DEVICE_INTEGRITY Bypassed](https://m4kr0.vercel.app/_astro/2.10.DP1m5E-R_JP819.webp)

Step 3: Bypass MEETS_STRONG_INTEGRITY

This verdict checks the security update level. To bypass it, we need to spoof a modern date for security patch. The module tricks Google's integrity checks into believing the device is running the latest updates.

This manipulation is often necessary to successfully pass the strict `MEETS_STRONG_INTEGRITY` verdict, as Google may reject devices running significantly outdated patch levels.

Steps

1From the same TrickyStore menu, select "Set Security Patch"
2Tap "Get Security Patch Date"
3Click Save

![Set Security Patch Date](https://m4kr0.vercel.app/_astro/2.11.DbcE5ug4_Z1taLLp.webp)

After this, check Play Integrity API Checker. You will find that all checks have been successfully bypassed.

![All Checks Bypassed](https://m4kr0.vercel.app/_astro/2.12.C4wqXpVi_ZFvPCm.webp)

When checking Key Attestation APK, you will find that the bootloader appears as locked.

![Key Attestation - Bootloader Locked](https://m4kr0.vercel.app/_astro/2.13.D0CGyMw__Zb42gP.webp)

Server-Side Verification Logic

To understand what we are bypassing, it helps to look at how a backend server verifies the token. This is the logic that TrickyStore aims to fool.

Node.js Example (using googleapis):
const { google } = require('googleapis');
// Initialize the Play Integrity API client
const playIntegrity = google.playintegrity('v1');
async function verifyIntegrityToken(integrityToken, packageName) {
  try {
    // 1. Decrypt and verify the token with Google's servers
    const res = await playIntegrity.v1.decodeIntegrityToken({
      packageName: packageName,
      resource: {
        integrityToken: integrityToken,
      },
    });
    const verdict = res.data.tokenPayloadExternal;
    // 2. Check Device Integrity
    // TrickyStore aims to ensure 'MEETS_DEVICE_INTEGRITY' is present here.
    const deviceVerdict = verdict.deviceIntegrity.deviceRecognitionVerdict;
    if (!deviceVerdict.includes('MEETS_DEVICE_INTEGRITY')) {
      throw new Error('Device integrity check failed: ' + deviceVerdict);
    }
    // 3. Check App Integrity (Package Name & Certificate)
    // This ensures the token wasn't generated by a spoofed app on a valid device.
    if (verdict.appIntegrity.appRecognitionVerdict !== 'PLAY_RECOGNIZED') {
       throw new Error('App not recognized by Play Store');
    }
    return { valid: true, payload: verdict };
  } catch (error) {
    console.error('Verification failed:', error.message);
    return { valid: false, error: error.message };
  }
}

Advanced Detection Methods

Since Play Integrity can be bypassed with a valid keybox, high-security apps (banking, games) use "Defense in Depth" strategies to detect the environment itself.

Zygisk/Injection Detection: Scanning for suspicious shared libraries or memory regions that shouldn't be there (e.g., `libmemtrack_real.so` or randomized names used by Zygisk).
Timing Checks (Side-Channel Analysis): Hooking functions adds overhead. Security modules measure the execution time of simple system calls (like `getpid()` or `open()`). If it takes significantly longer than the statistical average, a hook is likely present.
File System & Mount Checks: Checking for `MS_NOSUID` or `MS_NODEV` flags on partitions where they shouldn't exist, or looking for "magic" files used by Magisk or KernelSU.

Troubleshooting Common Failures

Even with TrickyStore, the bypass is not 100% reliable.

1 Revoked Keyboxes (The #1 Cause): Google actively hunts for leaked `keybox.xml` files. When they find one public on GitHub or Telegram, they add its Certificate Serial Number to a Certificate Revocation List (CRL). If your keybox is on this list, the API will return a failure or a "Basic Integrity" verdict.
2 Broken TEE: If the device's actual TEE is malfunctioning or the partition holding the keybox is corrupted, TrickyStore's "Leaf Hack" mode cannot work because it relies on the hardware to do *some* signing.
3 Incompatible Security Patch Levels: The attestation certificate includes the `osPatchLevel`. If the spoofed keybox is from an old device (e.g., Android 8) but the device claims to be running Android 14, the mismatch can trigger heuristic flags on Google's side.

Important Warnings

Rate Limiting: Do not run Play Integrity API Checker too frequently, as Google may become suspicious of the keybox and block it. In that case, you will be forced to set a new valid `keybox.xml`.

Keybox Rotation: Keyboxes can be revoked by Google. Always have backup valid keyboxes available.

Legal Considerations: This information is for security research and authorized penetration testing only. Bypassing Play Integrity on apps without authorization may violate terms of service.

Security Implications for Developers

Why Bypass Matters for Testing

Understanding Play Integrity bypass is crucial for:

Mobile Security Assessments: Testing if apps properly handle integrity failures
Business Logic Testing: Verifying server-side validation
Root Detection Testing: Evaluating defense-in-depth strategies

Recommendations for Developers

1Don't rely solely on Play Integrity: Implement multiple layers of security
2Server-side validation: Always validate critical operations server-side
3Response handling: Gracefully handle integrity check failures
4Monitoring: Log and monitor for suspicious integrity patterns
5Risk-based decisions: Use appropriate verdict levels for your use case

Tools Reference

TrickyStore

GitHub: https://github.com/5ec1cff/TrickyStore
Purpose: Spoofing certificate chains for key attestation

Tricky Addon

GitHub: https://github.com/KOWX712/Tricky-Addon-Update-Target-List
Purpose: Managing target package lists

ReZygisk

GitHub: https://github.com/PerformanC/ReZygisk
Purpose: Zygisk implementation without built-in Magisk Zygisk

KSU Web UI

GitHub: https://github.com/adivenxnataly/KsuWebUI
Purpose: Web-based configuration interface

Conclusion

Play Integrity API is Google's modern solution for app attestation, replacing the older SafetyNet. While it provides strong protection against tampering and root detection, security researchers can bypass these checks using device profile spoofing and keybox replacement techniques.

For penetration testers and security researchers, understanding these bypass techniques is essential for comprehensive mobile security assessments. For developers, this knowledge highlights the importance of defense-in-depth strategies that don't rely solely on client-side attestation.

Disclaimer: This guide is for educational and authorized security testing purposes only. Always obtain proper authorization before testing applications.

Original Article Credit: This article is based on research by [Adham A. Makroum (M4KR0)](https://m4kr0.vercel.app/posts/android-pentest/play-integrity-api-how-it-works--how-to-bypass-it/).

Tags

#Android Security#Play Integrity#Mobile Pentesting#Root Detection Bypass#App Attestation#SafetyNet#Magisk

Downloadable-style takeaway

Use this as a working assessment checklist.

Pull the headings into your next security review, assign owners, and mark each section as ready, partial, or missing.

A

Written by

Asfaleia Team

Security Consultant

Written by the Asfaleia Tech Security Team, combining field experience across offensive testing, detection engineering, incident readiness, and compliance evidence.

Ready to Strengthen Your Security?

Let's discuss how Asfaleia-Tech can help protect your organization.