Back to Blog
App DevelopmentPublished on October 24, 2026

Hardware Attestation Beyond Google: How Modern Banking Apps Architect Verification for Hardened OSs

Financial institutions are moving beyond Google Play Integrity to support security-hardened operating systems like GrapheneOS. Here is how modern mobile architectures implement hardware-backed KeyMint attestation to verify untampered client environments.

The Mobile Attestation Monoculture and the Play Integrity Trap

For nearly a decade, mobile financial applications have relied on a centralized security model governed by platform vendors. If an Android application needs to verify that the host environment is free from root kits, debuggers, or malicious system hooks, it almost universally defers to Google's SafetyNet—and more recently, the Play Integrity API.

Under standard Play Integrity enforcement, the client app requests an attestation token, Google's servers evaluate client integrity against proprietary telemetry, and an encrypted JSON Web Signature (JWS) is returned containing evaluation verdicts such as MEETS_BASIC_INTEGRITY, MEETS_DEVICE_INTEGRITY, and MEETS_STRONG_INTEGRITY.

For developers building zero-trust banking applications, this pipeline introduces a major architectural flaw: it conflates genuine device security with vendor certification. A device running a five-year-old, end-of-life stock Android ROM with unpatched local privilege escalation vulnerabilities can easily pass MEETS_DEVICE_INTEGRITY if the bootloader is locked with the original OEM keys. Conversely, a security-hardened operating system like GrapheneOS—which incorporates hardened memory allocators, aggressive sandboxing, and up-to-the-minute AOSP security patches—fails basic Play Integrity checks because its bootloader is locked with a custom verified boot key rather than an OEM/Google production key.

Recently, forward-thinking European and global financial platforms have broken this monoculture. Rather than blanket-blocking non-stock operating systems, engineering teams at modern banks are directly querying the underlying hardware security modules (TEE and StrongBox) to cryptographically attest device integrity. By verifying hardware-backed KeyMint certificates directly, apps can reliably accept security-hardened distributions without compromising threat models.


Under the Hood: Hardware-Backed Keystore Attestation

Android devices running Android 8.0 (API 26) and newer support hardware-backed key attestation via the Keymaster (and subsequently KeyMint) Hardware Abstraction Layer (HAL). This architecture bypasses high-level OS user-space checks and establishes a hardware root of trust.

When a client application requests a new cryptographic asymmetric key pair using the Android Keystore system, it can provide an attestation challenge (a cryptographically random nonce generated by the server). The hardware security environment—either a Trusted Execution Environment (ARM TrustZone) or a dedicated discrete Secure Element (such as Titan M2 or discrete StrongBox chips)—generates the key pair internally.

Crucially, the private key never leaves the secure silicon. Along with the generated public key, the secure module constructs an X.509 certificate chain. The root of this chain is a known public key certificate provisioned by Google during hardware manufacturing, while the leaf certificate contains an ASN.1 extension holding critical telemetry about the device's boot state, verified boot keys, operating system version, and security patch levels.


Deconstructing the Android Key Description ASN.1 Schema

To understand how an app can explicitly permit an OS like GrapheneOS without trusting arbitrary custom ROMs, we must examine the leaf certificate's attestation extension. This extension is mapped to the Object Identifier (OID) 1.3.6.1.4.1.11129.2.1.17.

The ASN.1 structure defined by the Android Open Source Project looks like this:

KeyDescription ::= SEQUENCE {
    attestationVersion         INTEGER,
    attestationSecurityLevel   SecurityLevel,
    keymasterVersion           INTEGER,
    keymasterSecurityLevel     SecurityLevel,
    attestationChallenge       OCTET_STRING,
    uniqueId                   OCTET_STRING,
    softwareEnforced           AuthorizationList,
    hardwareEnforced           AuthorizationList,
}

AuthorizationList ::= SEQUENCE {
    purpose                    [1] EXPLICIT SET OF INTEGER OPTIONAL,
    algorithm                  [2] EXPLICIT INTEGER OPTIONAL,
    keySize                    [3] EXPLICIT INTEGER OPTIONAL,
    digest                     [5] EXPLICIT SET OF INTEGER OPTIONAL,
    ...
    osVersion                  [705] EXPLICIT INTEGER OPTIONAL,
    osPatchLevel               [706] EXPLICIT INTEGER OPTIONAL,
    rootOfTrust                [704] EXPLICIT RootOfTrust OPTIONAL,
}

RootOfTrust ::= SEQUENCE {
    verifiedBootKey            OCTET_STRING,
    deviceLocked               BOOLEAN,
    verifiedBootState          VerifiedBootState,
    verifiedBootHash           OCTET_STRING,
}

VerifiedBootState ::= ENUMERATED {
    Verified                   (0),
    SelfSigned                 (1),
    Unverified                 (2),
    Failed                     (3),
}

The values populated inside the hardwareEnforced record cannot be spoofed by an adversary, even if the Android Linux kernel has been compromised, because the certificate is signed exclusively within the isolated TEE or StrongBox enclave.

Within RootOfTrust:

  • verifiedBootKey: The SHA-256 digest of the public key used to verify the operating system's boot partitions.
  • deviceLocked: A boolean indicating whether the bootloader is locked.
  • verifiedBootState: Indicates if the verified boot flow passed. When a user installs GrapheneOS, they flash a custom AVB (Android Verified Boot) key into the hardware storage (avb_custom_key) and lock the bootloader. Under standard AVB rules, this sets verifiedBootState to SelfSigned (or Verified depending on platform implementation) and ensures deviceLocked is true.

Engineering the Client-Side Verification Flow

To implement this pattern, the mobile banking app must generate an asymmetric key pair bound to hardware, passing an unpredictable challenge generated by the bank's backend authentication service.

Here is how the key generation is initiated in Kotlin:

import android.security.keystore.KeyGenParameterSpec
import android.security.keystore.KeyProperties
import java.security.KeyPairGenerator
import java.security.KeyStore
import java.security.cert.Certificate

class HardwareAttestationClient {

    fun generateAttestedKeyPair(challenge: ByteArray): Array<Certificate> {
        val alias = "banking_auth_hardware_key"
        val keyStore = KeyStore.getInstance("AndroidKeyStore").apply { load(null) }

        // Remove any previously stored key
        if (keyStore.containsAlias(alias)) {
            keyStore.deleteEntry(alias)
        }

        val keyPairGenerator = KeyPairGenerator.getInstance(
            KeyProperties.KEY_ALGORITHM_EC,
            "AndroidKeyStore"
        )

        val parameterSpec = KeyGenParameterSpec.Builder(
            alias,
            KeyProperties.PURPOSE_SIGN or KeyProperties.PURPOSE_VERIFY
        )
            .setDigests(KeyProperties.DIGEST_SHA256)
            .setAttestationChallenge(challenge)
            .setUserAuthenticationRequired(false) // Set to true if binding to Biometrics
            .build()

        keyPairGenerator.initialize(parameterSpec)
        keyPairGenerator.generateKeyPair()

        // Extract the full X.509 certificate chain
        val certChain = keyStore.getCertificateChain(alias)
            ?: throw IllegalStateException("Failed to retrieve hardware certificate chain")

        return certChain
    }
}

The array of Certificate objects is base64-encoded and transmitted over TLS to the banking backend along with the original session nonce.


Server-Side Validation: Validating the Hardware Certificate Chain

Validating attestation on the mobile device itself is fundamentally flawed; an attacker with a dynamic binary instrumentation framework (like Frida) could easily hook the client-side validation logic. The certificate chain must be sent to the backend authentication gateway.

The server performs four distinct operations:

  1. Verify the Certificate Chain: Validate the chain from the leaf certificate up to the well-known Google Attestation Root CA certificate (whose public key is permanently embedded in Android devices). Ensure no certificates in the chain are expired or revoked via CRL/OCSP.
  2. Verify Challenge Freshness: Extract the attestationChallenge from the ASN.1 extension and verify that it matches the single-use cryptographic nonce issued to this client session, mitigating replay attacks.
  3. Inspect the Security Level: Ensure that attestationSecurityLevel and keymasterSecurityLevel are set to TrustedEnvironment or StrongBox.
  4. Evaluate Root of Trust & Verified Boot Key: Inspect the rootOfTrust structure.

Below is an illustrative implementation in Go demonstrating how to extract and evaluate the RootOfTrust:

package main

import (
	"bytes"
	"crypto/sha256"
	"crypto/x509"
	"encoding/asn1"
	"errors"
	"fmt"
)

// GrapheneOS official AVB public key SHA-256 fingerprint (Pixel devices)
var GrapheneOSBootKeyHash = []byte{
	0x9e, 0x1f, 0x6e, 0x56, 0x93, 0x3d, 0x10, 0x22,
	0x73, 0x47, 0x98, 0x6e, 0x05, 0x92, 0x96, 0xcd,
	0x53, 0x3d, 0x9a, 0x9f, 0x18, 0x49, 0xb6, 0x12,
	0x70, 0xa3, 0x12, 0x4e, 0xd0, 0x48, 0x6d, 0x47,
}

type RootOfTrust struct {
	VerifiedBootKey   []byte
	DeviceLocked      bool
	VerifiedBootState asn1.Enumerated
	VerifiedBootHash  []byte
}

func ValidateDeviceTrust(leafCert *x509.Certificate, expectedChallenge []byte) error {
	// Android Attestation OID
	attestationOID := asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 11129, 2, 1, 17}

	var attestationExt []byte
	for _, ext := range leafCert.Extensions {
		if ext.Id.Equal(attestationOID) {
			attestationExt = ext.Value
			break
		}
	}
	if attestationExt == nil {
		return errors.New("missing Android hardware attestation extension")
	}

	// Parse KeyDescription sequence
	var keyDesc struct {
		AttestationVersion       int
		AttestationSecurityLevel asn1.Enumerated
		KeymasterVersion         int
		KeymasterSecurityLevel   asn1.Enumerated
		AttestationChallenge     []byte
		UniqueID                 []byte
		SoftwareEnforced         asn1.RawValue
		HardwareEnforced         asn1.RawValue
	}

	if _, err := asn1.Unmarshal(attestationExt, &keyDesc); err != nil {
		return fmt.Errorf("asn1 unmarshal failed: %w", err)
	}

	// Check challenge to prevent replay attacks
	if !bytes.Equal(keyDesc.AttestationChallenge, expectedChallenge) {
		return errors.New("attestation challenge mismatch")
	}

	// Parse HardwareEnforced AuthorizationList
	var authList struct {
		RootOfTrust RootOfTrust `asn1:"optional,tag:704"`
	}
	if _, err := asn1.Unmarshal(keyDesc.HardwareEnforced.Bytes, &authList); err != nil {
		return fmt.Errorf("failed to parse hardwareEnforced list: %w", err)
	}

	// Ensure bootloader is physically locked
	if !authList.RootOfTrust.DeviceLocked {
		return errors.New("unacceptable risk: bootloader is unlocked")
	}

	// Accept Google Stock OEM Keys OR explicitly whitelisted GrapheneOS Root Key
	isGrapheneOS := bytes.Equal(authList.RootOfTrust.VerifiedBootKey, GrapheneOSBootKeyHash)
	isOEMCertified := authList.RootOfTrust.VerifiedBootState == 0 // Verified

	if !isOEMCertified && !isGrapheneOS {
		return errors.New("untrusted operating system signature")
	}

	return nil
}

The Strategic Shift: Zero-Trust Over Vendor Lock-In

When a mobile app blindly delegates its security decisions to a third-party black-box API like Play Integrity, it adopts an incomplete threat model. Play Integrity is fundamentally an anti-abuse signal for Google's ecosystem; it was never designed as an enterprise-grade attestation protocol for zero-trust computing environments.

By moving attestation checks directly to the hardware layer:

  1. Security Posture Increases: Security-conscious users running hardened operating systems maintain active exploit mitigations (such as hardened malloc, exec-spawning memory protections, and per-app network permissions) that standard consumer ROMs lack entirely.
  2. Resilience to Single Points of Failure: If Google Play Services experiences outages or changes its attestation heuristics arbitrarily, bank authentication flows remain completely operational through independent TEE evaluation.
  3. Granular Policy Enforcement: Financial security teams can enforce precise minimum patch levels (osPatchLevel tag 706 in ASN.1) directly in their backend API rules rather than relying on abstract integrity buckets.

Supporting alternative secure environments is no longer an edge-case hobby for developers—it is the signature of a mature, defense-in-depth mobile security architecture.

#Android Security#Mobile Development#App Security#Cryptography