---
title: "Hardware Key Attestation"
description: "Verify device and app integrity with Android's hardware-backed Key Attestation, and let your server check a signed attestation token on the API requests you choose to protect."
---
> For the complete documentation index, see [llms.txt](https://docs.doverunner.com/llms.txt).

**Add-on feature:** 
Hardware Key Attestation is an add-on that requires a separate plan or contract. To use it, contact the [Help Center](https://support.doverunner.com).


**Hardware Key Attestation** checks the device's bootloader and boot state and your app's signing certificate through Android's hardware-backed Key Attestation. The check is evaluated on the DoveRunner attestation server, not inside the app, and the result reaches your server as a signed token on the API requests you choose to protect. Your server can then trust the result without trusting the device that sent the request.

## Quick Start

The shortest path to a working integration:


1. **Choose a setup and set the detection mode.** Pick the setup that matches your goal in [Choose a Setup](#choose-a-setup), then set its detection mode in **App Configuration → Hardware Key Attestation**.
2. **Seal with attestation enabled.** On Step 5 of the sealing wizard, enable **Hardware Key Attestation** and add the API URLs you want to protect as [Target URLs](#target-urls).
3. **Get your public key.** After that sealing, request your account's [public key](#public-key) through the Help Center.
4. **Verify the token on your server.** Add the [sample code](#sample-code) to the endpoints you registered. It checks the `X-DoveRunner-Attestation-Token` header and gives you the verdict.
5. **Roll out in phases.** Start by allowing requests that carry no token, then move to restricting or rejecting them. Until you do, a request that leaves the header out is not stopped. See [Requests Without a Token](#requests-without-a-token).


Where to read next:

| If you | Read |
| :----- | :--- |
| Configure the console and seal the app | [Detection Mode in App Configurations](#detection-mode-in-app-configurations), [Enabling It When Sealing](#enabling-it-when-sealing) |
| Develop the server | [Verifying the Token on Your Server](#verifying-the-token-on-your-server), [Troubleshooting](#troubleshooting) |
| Decide the security policy | [Choose a Setup](#choose-a-setup), [Recommended Setups](#recommended-setups), [Before You Go Live](#before-you-go-live) |

## How It Works

```mermaid
sequenceDiagram
    box End User
    participant A as Sealed app
    end
    box DoveRunner
    participant B as Attestation server
    end
    box Your Service
    participant C as Your API server
    end
    A ->> B: Hardware attestation certificate chain
    B -->> B: Evaluate the detection cases
    B ->> A: Verdict and signed token
    A ->> C: Request to a Target URL, with the token header
    C -->> C: Verify the signature, read the verdict
    C ->> A: Allow, restrict, or reject
```


1. When the sealed app starts, it asks the device's hardware-backed keystore for an attestation certificate chain and sends it to the DoveRunner attestation server.
2. The attestation server evaluates the [detection cases](#detection-cases) you enabled for the app and returns a verdict: `ALLOW`, `LIMIT`, or `DENY`.
3. On `DENY`, the app shows the threat alert and closes. On `ALLOW` or `LIMIT`, the app keeps a signed token in memory and renews it before it expires.
4. When the app sends a request to one of your **Target URLs**, it adds the token in the `X-DoveRunner-Attestation-Token` header.
5. Your server verifies the token's signature with your DoveRunner public key, then allows, restricts, or rejects the request.


| Verdict | Meaning | What the app does | What your server receives |
| :------ | :------ | :---------------- | :------------------------ |
| `ALLOW` | The device proved, through hardware-backed attestation, that its bootloader is locked and its boot is verified, and no enabled case was detected. | Keeps running. | A token with `verdict` `ALLOW`. |
| `LIMIT` | The device could not be proven intact: a case with the **Limit** action was detected, or the device could not provide hardware-backed proof. It is not proven to be compromised either. | Keeps running. | A token with `verdict` `LIMIT`. Your server decides what to restrict. |
| `DENY` | A case with the **Deny** action was detected. | Shows the threat alert and closes. | **No token.** The app is closed before it can send one. |

## Choose a Setup

Decide first what you want Hardware Key Attestation to do for your service. A setup is a detection mode in the console combined with a rule on your server.

| Goal | Detection mode | On your server | Effect on users |
| :--- | :------------- | :------------- | :-------------- |
| [Observe first](#observe-first) | **Custom**: the four Limit cases | Verify and record. Restrict nothing. | None. |
| [Restrict on the server, never close the app](#restrict-on-the-server-without-closing-the-app) | **Custom**: the four Limit cases | Restrict `LIMIT`. | The app never closes. Unproven devices are restricted on protected requests. |
| [Block rooted and tampered devices](#block-rooted-and-tampered-devices) | **Basic** | Restrict `LIMIT`, and reject revoked certificates. | The app closes on devices with a Definitive case. |
| [Accept requests only from your app](#accept-requests-only-from-your-app) | Any | Require a valid token. | Older app versions are affected until the policy is phased in. |
| [App integrity only](#app-integrity-only) | **Custom**: App signature mismatch and Revoked certificate | Compare the app's signing certificate reported in the token. | The app closes only for re-signed copies. |

The first two setups use the same console setting and differ only in what your server does, so you can move from one to the other without sealing again. If you are not sure where to start, begin with **Observe first**: it never closes the app and shows you how your users' devices are classified.

The cases and their Deny and Limit actions are listed in [Detection Cases](#detection-cases), and the steps for each setup are in [Recommended Setups](#recommended-setups).

## Requirements

- Sealing version **3.3.0.0 or higher**. Android only; iOS is not supported at this time.
- Hardware Key Attestation is enabled for your account. Until it is, the option is not shown in the sealing wizard or in presets, and App Configurations shows that the feature is not enabled.
- Your app sends the requests you want to protect through a [supported HTTP client](#supported-http-clients).
- You can change the server that receives those requests, so that it can verify the token.

## Detection Mode in App Configurations

Open **Android Mobile App Security → App Configuration**, select the app, and go to the **Hardware Key Attestation** section. There is no on/off switch here — attestation is turned on or off per sealing.

| Detection mode | Behavior |
| :------------- | :------- |
| **Basic** | The three **Definitive** cases are detected with the **Deny** action. The other four cases are detected with the **Limit** action. |
| **Custom** | You turn each case on individually. A case you check is detected with the action listed below. A case you leave unchecked is not detected: it never causes `DENY`, and it is not reported in the token. |

Click **Save** to store the detection mode. The detection mode is evaluated on the attestation server, so a change applies within a few minutes to every build that has attestation enabled, including builds your users already have.

### Detection Cases

Each case has a fixed action:

- **Deny** — the verdict is `DENY`. The app shows the threat alert and closes, and no token is sent.
- **Limit** — the verdict is `LIMIT`. The app keeps running, and your server decides what to restrict.

| Detection case | Badge | Action | Code |
| :------------- | :---- | :----- | :--- |
| **Unlocked bootloader detection** | Definitive | Deny | `90001` |
| **Verified Boot failure detection** | Definitive | Deny | `90001` |
| **App signature mismatch detection** | Definitive | Deny | `90005` |
| **Revoked certificate detection** | Recommended | Limit | `90002` |
| **Software-level attestation detection** | False-Positive Risk | Limit | `90006` |
| **Attestation data absent detection** | False-Positive Risk | Limit | `90003` |
| **Root certificate verification failure detection** | False-Positive Risk | Limit | `90004` |
| Expired attestation certificate | — | Limit | `90007` |

The code is the value your server finds in the token's `verdictCodes` claim. The expired attestation certificate case is always detected and has no option in the console.

What each case means:

- **Unlocked bootloader** — the attestation record states that the bootloader is unlocked, so the device can run a modified system image.
- **Verified Boot failure** — the device did not boot in the verified state.
- **App signature mismatch** — the app that requested attestation is signed with a certificate other than yours, which means it was re-signed or repackaged. The attestation server can make this comparison only when your certificate fingerprint is registered for the app on the server. Before you rely on this case, ask the [Help Center](https://support.doverunner.com) to confirm that it is registered. Your server can also check the signing certificate itself; see [App Integrity Only](#app-integrity-only).
- **Revoked certificate** — the attestation was made with a certificate that has been revoked and is no longer trusted. A device that uses such a certificate can present itself as intact. Keep this case on: when it is off, such a device can receive `ALLOW`.
- **Software-level attestation** — the attestation was produced in software, not by the hardware keystore. This is normal on some older and low-end devices, and on emulators.
- **Attestation data absent** — the device returned no attestation data. This also happens on older OS versions, LineageOS, and devices from certain manufacturers.
- **Root certificate verification failure** — the certificate chain could not be verified against the trusted root certificates.
- **Expired attestation certificate** — a genuine hardware certificate chain that is past its validity period, as found on some old devices.

**How the actions behave today:** 
- **Deny closes the app.** It does not only withhold the token: the app terminates, the same way as for other blocked threats. Users on such devices cannot use the app at all, including the parts that do not call a Target URL.
- **The action of a case is fixed.** You cannot set a Definitive case to Limit. To handle those devices without closing the app, turn the case off and restrict `LIMIT` on your server; see [Restrict on the Server Without Closing the App](#restrict-on-the-server-without-closing-the-app).
- **A device that is not proven intact never receives `ALLOW`.** In Basic mode the console describes the other four cases as allowed, which means the app is not closed; the token still carries `LIMIT`. In Custom mode a case you turn off is no longer reported, but a device with an unlocked bootloader, a failed Verified Boot, software-level attestation, or no attestation data still receives `LIMIT`, with an empty `verdictCodes`.


**Tip:** 
Not sure which cases to turn on? Start from [Choose a Setup](#choose-a-setup).


## Enabling It When Sealing

On **Step 5 — Advanced Detection** of the [sealing wizard](https://docs.doverunner.com/mobile-app-security/android/android-sealing-options/#step-5--advanced-detection):

| Option | Values | Default | Description |
| :----- | :----- | :------ | :---------- |
| **Hardware Key Attestation** | Enable / Disable | Disable | Turns attestation on for this sealing. |
| **Target URLs** | URLs | — | Shown when attestation is enabled. The endpoints of your app that attestation protects. Up to 50 URLs of 500 characters each. |

Whenever attestation is enabled, the detection mode set in App Configurations is applied automatically.

### Target URLs

The token is attached only to requests whose URL matches a Target URL. Register the requests that are sensitive in your service, such as login, payment, and account changes, not every API call.

| Entry | Matches | Example |
| :---- | :------ | :------ |
| Exact URL | Only requests to exactly this URL. | `https://api.example.com/v1/login` |
| Prefix ending in `*` | Every request whose URL starts with the text before `*`. Use this when a path parameter or query string is added at runtime. | `https://api.example.com/v1/orders/*` |

**Caution:** 
- Entries are compared as plain text. The console describes the field as accepting a regular expression, but regular-expression syntax is not evaluated at runtime. Use an exact URL or a prefix ending in `*`.
- An exact URL does not match the same path with a query string or a trailing slash added. Use a prefix for such requests.
- End a host-wide prefix with a slash before the `*`: `https://api.example.com/*`. Without the slash, `https://api.example.com*` would also match `https://api.example.com.attacker.net`.
- `*` alone is not accepted.
- Target URLs are built into the app at sealing time. To change them, seal again and release the new build.


### Supported HTTP Clients

The token is attached at the HTTP call sites of your app during sealing. Your source code is not changed.

| HTTP client | Supported |
| :---------- | :-------- |
| `HttpURLConnection`, Volley | Yes |
| OkHttp, Retrofit, Ktor (OkHttp engine) | Yes |
| OkHttp WebSocket | Yes. The token is attached to the request that opens the connection. |
| Cronet, HTTP sent from native (NDK) code, Ktor (CIO engine) | No |

If your protected requests go through an unsupported client, they are sent without a token. If no supported call site is found in the app at all, sealing fails.

## Verifying the Token on Your Server

### Token Header

A request to a Target URL carries the token in this header:

```http
X-DoveRunner-Attestation-Token: <token>
```

The token is a JWT: three parts separated by dots, `header.payload.signature`. The first two parts are only encoded, not encrypted, so anyone can read them or write their own. The signature is the only part that proves DoveRunner issued the token. **Never read the verdict before the signature is verified.**

Decoded, the header and payload of a token look like this:

```json
{
  "kid": "<key ID>",
  "typ": "JWT",
  "alg": "ES256"
}
```

```json
{
  "iss": "https://attest.doverunner.com",
  "sub": "A0000001",
  "jti": "5f0c6c0e-2f1b-4c1e-9a55-7c1d2b8e4a10",
  "packageName": "com.example.myapp",
  "verdict": "LIMIT",
  "assuranceLevel": "L1",
  "enforced": false,
  "verdictCodes": [90006],
  "aaSignatureDigests": ["3f8bd9c2a1e47d0f5b6c8a9e2d1f4b7c0a3e6d9f2b5c8a1e4d7f0b3c6a9e2d5f"],
  "iat": 1794700000,
  "exp": 1794700120
}
```

| Property | Value |
| :------- | :---- |
| Signature algorithm | `ES256`. No other algorithm is used. |
| Lifetime | About two minutes. Validate the `exp` claim; do not hard-code a lifetime. |
| Reuse | The app reuses one token for every protected request until it renews it. The same token arrives on many requests. |

### Public Key

DoveRunner creates a signing key pair for your account the first time you seal an app with Hardware Key Attestation enabled. After that sealing, request the public key through the [Help Center](https://support.doverunner.com).

The key is provided as a JWK (JSON):

```json
{
  "kty": "EC",
  "crv": "P-256",
  "kid": "<key ID>",
  "x": "<Base64URL>",
  "y": "<Base64URL>",
  "alg": "ES256"
}
```

- One public key is used for your account. It does not change at this time, so you can keep it without a refresh schedule.
- A JWKS endpoint and key rotation are not provided at this time. You do not need to look at the `kid` header.
- Keep the key in your server's configuration, not in source code, so that it can be replaced without a code change.

### Claims

After the signature is verified, the payload contains these claims. Ignore claims you do not recognize.

| Claim | Type | Description |
| :---- | :--- | :---------- |
| `verdict` | String | `ALLOW` or `LIMIT`. Base your decision on this claim. |
| `packageName` | String | Package name of the app that was attested. Compare it with your app's package name. |
| `verdictCodes` | Array of numbers | Codes of the detected cases, most significant first, for example `[90002]`. Empty when no enabled case was detected. See [Detection Codes with LIMIT](#detection-codes-with-limit). |
| `aaSignatureDigests` | Array of strings | SHA-256 digests of the app's signing certificates as reported in the device's attestation, in lower-case hex. Empty when the device provided no attestation. The values are proven by hardware only when `verdict` is `ALLOW`. |
| `assuranceLevel` | String | `L3` with `ALLOW`, `L1` with `LIMIT`. Informational; log it, but decide on `verdict`. |
| `enforced` | Boolean | `true` with `ALLOW`, `false` with `LIMIT`. Informational; decide on `verdict`. |
| `iss` | String | URL of the token issuer. Informational. The value can differ by region or change later, so do not reject a token because of it unless you have confirmed the value for your environment through the [Help Center](https://support.doverunner.com). |
| `sub` | String | Your DoveRunner account ID. |
| `jti` | String | ID of the attestation that issued this token. It repeats on every request that reuses the token. |
| `iat`, `exp` | Number | Issued-at and expiry time, in Unix seconds. |

### Verification Steps


1. Read the `X-DoveRunner-Attestation-Token` header. If it is missing, apply your policy for [requests without a token](#requests-without-a-token).
2. Verify the signature with your public key, accepting only `ES256`. Use the verify function of a JWT library, not a plain decode.
3. Check that the token has not expired (`exp`). Most libraries do this as part of verification. Allow for a few seconds of difference between your server's clock and DoveRunner's.
4. Check that `packageName` is your app's package name.
5. Act on `verdict`.


Reject the request when any of steps 2 to 4 fails. Return a generic error, such as HTTP 403 with no reason, and keep the details in your own logs. A detailed error tells an attacker which check to work around.

**Caution:** 
Do not reject a token because you have seen its `jti` before. The app reuses a token until it renews it, so rejecting repeats blocks your own users. The signature proves that DoveRunner issued the token; it does not prevent replay. A captured token can be sent again until it expires, and the short lifetime only limits that window. The token is not bound to a user or a session, so keep your own authentication and authorization on protected requests.


### Sample Code

Each sample loads the public key (JWK), accepts only `ES256`, and rejects every verdict other than `ALLOW` and `LIMIT`. A request without a token is not a pass: the Node.js sample handles it by the policy you set, and the Python and Java samples return `MISSING` for your code to handle.

**Node.js**


Uses [`jsonwebtoken`](https://www.npmjs.com/package/jsonwebtoken), shown as an Express middleware.

```js
const crypto = require('crypto');
const fs = require('fs');
const jwt = require('jsonwebtoken');

// The public key DoveRunner issued for your account (a JWK, in JSON).
const jwk = JSON.parse(fs.readFileSync(process.env.ATTESTATION_PUBLIC_JWK_FILE, 'utf8'));
const PUBLIC_KEY = crypto.createPublicKey({ key: jwk, format: 'jwk' });
const PACKAGE_NAME = 'com.example.myapp';

// Policy for requests without a token. See "Requests Without a Token".
//   'monitor'  - let the request through and record it. For the rollout period only.
//   'restrict' - let the request through with the same restriction as LIMIT.
//   'block'    - reject the request.
const MISSING_TOKEN_POLICY = 'monitor';

function requireAttestation(req, res, next) {
  const token = req.get('X-DoveRunner-Attestation-Token');
  if (!token) {
    // No token: handled by MISSING_TOKEN_POLICY.
    return handleMissingToken(req, res, next);
  }

  let claims;
  try {
    // Checks the signature and the expiry (exp). Only ES256 is accepted.
    claims = jwt.verify(token, PUBLIC_KEY, { algorithms: ['ES256'], clockTolerance: 5 });
  } catch (err) {
    return res.status(403).json({ error: 'forbidden' });
  }

  if (claims.packageName !== PACKAGE_NAME) {
    return res.status(403).json({ error: 'forbidden' });
  }

  if (claims.verdict === 'ALLOW') {
    return next();
  }
  if (claims.verdict === 'LIMIT') {
    // Restrict the request: e.g. ask for an OTP, or lower the transaction limit.
    req.attestationLimited = true;
    req.attestationCodes = claims.verdictCodes || [];
    return next();
  }
  // Any other value is rejected.
  return res.status(403).json({ error: 'forbidden' });
}

function handleMissingToken(req, res, next) {
  req.attestationMissing = true; // record it in your logs
  if (MISSING_TOKEN_POLICY === 'monitor') {
    return next();
  }
  if (MISSING_TOKEN_POLICY === 'restrict') {
    req.attestationLimited = true;
    return next();
  }
  return res.status(403).json({ error: 'forbidden' }); // 'block', and any other value
}

module.exports = { requireAttestation };
```


**Python**


Uses [`PyJWT`](https://pyjwt.readthedocs.io/) with the `cryptography` package.

```python
import os

import jwt  # PyJWT, installed together with the "cryptography" package

# The public key DoveRunner issued for your account (a JWK, in JSON).
with open(os.environ["ATTESTATION_PUBLIC_JWK_FILE"]) as f:
    PUBLIC_KEY = jwt.PyJWK.from_json(f.read()).key
PACKAGE_NAME = "com.example.myapp"


def check_attestation(headers):
    """Returns (result, verdict_codes). result is "ALLOW", "LIMIT", "MISSING" or "REJECT"."""
    token = headers.get("X-DoveRunner-Attestation-Token")
    if not token:
        return "MISSING", []  # not a pass: allow it only while you monitor; see "Requests Without a Token"

    try:
        # Checks the signature and the expiry (exp). Only ES256 is accepted.
        claims = jwt.decode(
            token,
            PUBLIC_KEY,
            algorithms=["ES256"],
            options={"require": ["exp"]},
            leeway=5,
        )
    except jwt.InvalidTokenError:
        return "REJECT", []

    if claims.get("packageName") != PACKAGE_NAME:
        return "REJECT", []

    if claims.get("verdict") == "ALLOW":
        return "ALLOW", []
    if claims.get("verdict") == "LIMIT":
        # Restrict the request: e.g. ask for an OTP, or lower the transaction limit.
        return "LIMIT", claims.get("verdictCodes", [])
    return "REJECT", []  # any other value is rejected
```


**Java**


Uses [Nimbus JOSE + JWT](https://connect2id.com/products/nimbus-jose-jwt) (`com.nimbusds:nimbus-jose-jwt`).

```java
import com.nimbusds.jose.JWSAlgorithm;
import com.nimbusds.jose.JWSVerifier;
import com.nimbusds.jose.crypto.ECDSAVerifier;
import com.nimbusds.jose.jwk.ECKey;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.SignedJWT;

import java.util.Date;

public class AttestationVerifier {

    public enum Result { ALLOW, LIMIT, MISSING, REJECT }

    private static final String PACKAGE_NAME = "com.example.myapp";
    private static final long CLOCK_SKEW_MS = 5000;

    private final JWSVerifier verifier;

    /** @param publicJwkJson the public key DoveRunner issued for your account (a JWK, in JSON) */
    public AttestationVerifier(String publicJwkJson) throws Exception {
        this.verifier = new ECDSAVerifier(ECKey.parse(publicJwkJson));
    }

    /** @param token value of the X-DoveRunner-Attestation-Token header, or null */
    public Result check(String token) {
        if (token == null || token.isEmpty()) {
            return Result.MISSING; // not a pass: allow it only while you monitor; see "Requests Without a Token"
        }
        try {
            SignedJWT jwt = SignedJWT.parse(token);
            // Only ES256 is accepted, and the signature must verify.
            if (!JWSAlgorithm.ES256.equals(jwt.getHeader().getAlgorithm()) || !jwt.verify(verifier)) {
                return Result.REJECT;
            }

            JWTClaimsSet claims = jwt.getJWTClaimsSet();
            Date exp = claims.getExpirationTime();
            if (exp == null || exp.getTime() + CLOCK_SKEW_MS < System.currentTimeMillis()) {
                return Result.REJECT;
            }
            if (!PACKAGE_NAME.equals(claims.getStringClaim("packageName"))) {
                return Result.REJECT;
            }

            String verdict = claims.getStringClaim("verdict");
            if ("ALLOW".equals(verdict)) {
                return Result.ALLOW;
            }
            if ("LIMIT".equals(verdict)) {
                // Restrict the request. The reason is in claims.getClaim("verdictCodes").
                return Result.LIMIT;
            }
            return Result.REJECT; // any other value is rejected
        } catch (Exception e) {
            return Result.REJECT;
        }
    }
}
```



The same pattern applies in other languages: load the public key, verify with `ES256` only, check `exp` and `packageName`, then branch on `verdict`. If you hold the key in PEM format instead, pass the PEM text to `crypto.createPublicKey()` in Node.js, or directly as the key to `jwt.decode()` in Python.

### Acting on the Verdict

| What your server sees | Recommended action |
| :-------------------- | :----------------- |
| Valid token, `verdict` `ALLOW` | Process the request normally. |
| Valid token, `verdict` `LIMIT` | Process the request with a restriction of your choice: require a second authentication factor, lower the transaction limit, or apply a tighter rate limit. |
| Invalid signature, expired token, or wrong `packageName` | Reject the request. |
| No token | Apply your policy for [requests without a token](#requests-without-a-token). |

**Note:** 
Your server does not receive a token for a `DENY` verdict, because the app closes on the device. Do not build logic that waits for `DENY`. Treat any `verdict` other than `ALLOW` or `LIMIT` as a rejection, as the samples do.


`LIMIT` has an effect only if your server acts on it. If your server treats `LIMIT` the same as `ALLOW`, the cases with the Limit action change nothing for the user.

### Detection Codes with LIMIT

Start by acting on `verdict` alone. When you want finer control over `LIMIT`, read `verdictCodes`:

| `verdictCodes` contains | Detected case | What it suggests |
| :---------------------- | :------------ | :--------------- |
| `90002` | Revoked certificate | The attestation certificate has been revoked. Treat it as an elevated risk: this is the strongest warning among the Limit cases. Consider rejecting, or restricting strictly. |
| `90004` | Root certificate verification failure | The certificate chain could not be validated against the trusted root certificates. This may indicate an unsupported or untrusted attestation environment. |
| `90006` | Software-level attestation | No hardware-backed proof. Seen on older and low-end devices, and on emulators. |
| `90003` | Attestation data absent | The device sent no attestation. Seen on older OS versions and custom ROMs. |
| `90007` | Expired attestation certificate | A genuine but old device. Low risk. |
| (empty) | None | No enabled case was detected, but the device did not prove a locked bootloader and a verified boot, for example because that case is turned off. |

A token can list more than one code.

### Requests Without a Token

A request to a Target URL can arrive without the header for several reasons:

- The device received `DENY`. The app closes, and no request from it carries a token.
- The request does not come from your sealed app: a script, a modified copy with the protection removed, or another client that calls the same endpoint.
- The installed app is an older version that was sealed without Hardware Key Attestation.
- The token could not be issued in time. After the app starts, the first protected request waits up to about 4 seconds for the token and is then sent without it. This happens when the device's network is unstable or when the attestation server cannot be reached.
- The request was sent through an [unsupported HTTP client](#supported-http-clients), or its URL does not match a Target URL.
- Hardware Key Attestation is no longer enabled for your account. Builds that were sealed with it then stop receiving tokens.

The first two are the requests you want to stop, and the others are legitimate users. Tighten your policy in phases:

| Phase | Requests without a token |
| :---- | :----------------------- |
| **1. Monitor** | Allow, and record how often the header is present per endpoint and app version. Alert on sudden changes. This phase gives no protection: a request that leaves the header out is processed like any other. |
| **2. Restrict** | Treat as `LIMIT`: require additional authentication or apply tighter limits. |
| **3. Block** | Reject, once almost all traffic from current app versions carries a valid token. |

Allowing requests without a token is for the Monitor phase only, not a final setting. To enforce attestation, protected endpoints must restrict or reject requests that carry no valid token.

Signature verification uses only the stored public key, so it keeps working when the attestation server is unreachable. New tokens cannot be issued during such an outage, so affected requests arrive without a token and are handled by the phase you are in. A token that is present but invalid should always be rejected, in every phase.

**Before you move to Block:** 
- Requests sent through an [unsupported HTTP client](#supported-http-clients), and requests from app versions sealed without Hardware Key Attestation, never carry a token. Once you block, they are rejected.
- If the attestation server cannot be reached, apps cannot obtain new tokens, and the tokens they hold expire within about two minutes. Requests from your users are then rejected until tokens are issued again. Decide in advance how your server behaves in that case.


## Recommended Setups

This section gives the steps for each setup listed in [Choose a Setup](#choose-a-setup).

### Observe First

Use this setup to learn how your users' devices are classified before anything is enforced.


1. In **App Configuration → Hardware Key Attestation**, choose **Custom**, check the four cases with the Limit action, and leave the three Definitive cases unchecked. No case can then close the app.
2. Seal with attestation enabled, and verify the token on your server. Record `verdict`, `verdictCodes`, and whether a token was present, without restricting any request.
3. Review the share of `ALLOW`, `LIMIT`, and missing tokens by app version and by code. A `LIMIT` with an empty `verdictCodes` is a device that did not prove a locked bootloader and a verified boot. These are the devices on which a Definitive case would close the app.


### Restrict on the Server Without Closing the App

Use this setup when closing the app is not acceptable for your service, but you still want to limit what an untrusted device can do.

Keep the console setting of [Observe first](#observe-first). Because the Definitive cases are off, the app never closes because of attestation. A device with an unlocked bootloader or a failed Verified Boot still does not receive `ALLOW`: it arrives as `LIMIT` with an empty `verdictCodes`. On your server, restrict `LIMIT` on the protected requests, for example with additional authentication, and consider rejecting `90002`.

The trade-offs: your server cannot tell an unlocked bootloader apart from other unproven devices, and the app itself keeps running on such a device, including the parts that do not call a Target URL.

### Block Rooted and Tampered Devices

Use this setup when a compromised device must not run the app at all, as is common for financial and payment apps.

Keep **Basic**. The app closes when a Definitive case is detected. On your server, process `ALLOW` normally, restrict `LIMIT`, and reject requests whose `verdictCodes` contains `90002`. Run [Observe first](#observe-first) beforehand to estimate how many of your users a Definitive case affects.

### Accept Requests Only from Your App

Use this setup to stop scripts, bots, and unofficial clients from calling your API. What matters here is that a valid token is present, not which verdict it carries.

Choose the detection mode according to your device policy; if you do not want to restrict devices, use the setting of [Observe first](#observe-first). On your server, require a valid token on the protected endpoints and accept both `ALLOW` and `LIMIT`. Introduce the requirement through the phases in [Requests Without a Token](#requests-without-a-token), because older app versions send no token.

Two limits to be aware of:

- Your real app running on an emulator receives a `LIMIT` token. To stop automation that drives the real app on emulators, also reject `90003` and `90006` on those endpoints.
- A token is not tied to one request. It can be copied from a device and reused until it expires, so keep your own session controls on protected requests. Each token is issued to one device: one `jti` used with many accounts or IP addresses is abnormal, while repeats from one user are normal.

### App Integrity Only

Use this setup when you want to block modified, repackaged, or re-signed copies of your app, without restricting users based on the state of their device.


1. In **App Configuration → Hardware Key Attestation**, choose **Custom** and check **App signature mismatch detection** and **Revoked certificate detection**. Leave the other five cases unchecked, then click **Save**.

   - With **App signature mismatch detection**, a copy of your app that is signed with another certificate receives `DENY`: it shows the threat alert and closes. This case needs your certificate fingerprint to be registered on the attestation server; ask the [Help Center](https://support.doverunner.com) to confirm it.
   - **Revoked certificate detection** uses the Limit action, so it does not close the app for anyone. It is needed because the signing certificate reported by a device with a revoked attestation certificate cannot be trusted. With this case on, such a device receives `LIMIT`, not `ALLOW`.

   Devices with an unlocked bootloader or without hardware attestation are not closed by this setup.

2. Seal with **Hardware Key Attestation** enabled and add the Target URLs you want to protect.

3. On your server, verify the token as described in [Verifying the Token on Your Server](#verifying-the-token-on-your-server). Then, when `verdict` is `ALLOW`, compare `aaSignatureDigests` with the SHA-256 fingerprint of your own signing certificate, and reject the request when none of the digests matches.

   **Node.js**


   ```js
   // SHA-256 fingerprint of your signing certificate: lower-case hex, no colons.
   const MY_CERT_SHA256 = '3f8bd9c2a1e47d0f5b6c8a9e2d1f4b7c0a3e6d9f2b5c8a1e4d7f0b3c6a9e2d5f';

   function signedWithMyCertificate(claims) {
     const digests = (claims.aaSignatureDigests || []).map((d) => d.toLowerCase());
     return claims.verdict === 'ALLOW' && digests.includes(MY_CERT_SHA256);
   }
   ```

   
   **Python**


   ```python
   # SHA-256 fingerprint of your signing certificate: lower-case hex, no colons.
   MY_CERT_SHA256 = "3f8bd9c2a1e47d0f5b6c8a9e2d1f4b7c0a3e6d9f2b5c8a1e4d7f0b3c6a9e2d5f"


   def signed_with_my_certificate(claims):
       digests = [d.lower() for d in claims.get("aaSignatureDigests", [])]
       return claims.get("verdict") == "ALLOW" and MY_CERT_SHA256 in digests
   ```

   
   **Java**


   ```java
   // SHA-256 fingerprint of your signing certificate: lower-case hex, no colons.
   private static final String MY_CERT_SHA256 =
           "3f8bd9c2a1e47d0f5b6c8a9e2d1f4b7c0a3e6d9f2b5c8a1e4d7f0b3c6a9e2d5f";

   static boolean signedWithMyCertificate(JWTClaimsSet claims) throws java.text.ParseException {
       java.util.List<String> digests = claims.getStringListClaim("aaSignatureDigests");
       if (!"ALLOW".equals(claims.getStringClaim("verdict")) || digests == null) {
           return false;
       }
       for (String digest : digests) {
           if (MY_CERT_SHA256.equalsIgnoreCase(digest)) {
               return true;
           }
       }
       return false;
   }
   ```

   

   To get the fingerprint, run `keytool -list -v -keystore <your keystore>` or `apksigner verify --print-certs <your apk>`, then remove the colons and convert the value to lower case. If you use Play App Signing, use the **app signing key certificate** shown in Play Console, because that is the certificate on the app your users install.

4. Decide how to treat `LIMIT`. With `LIMIT`, the device did not provide hardware-backed proof, so neither DoveRunner nor your server can confirm which certificate signed the app: `aaSignatureDigests` can be empty, and a value that is present is not proven. A genuine app on an old device and a modified app on an emulator both arrive as `LIMIT`.

   - To enforce integrity strictly, restrict `LIMIT` on the protected endpoints, for example with additional authentication. Users whose devices cannot attest are then restricted too.
   - To affect fewer users, treat `LIMIT` the same as `ALLOW` and accept that integrity is proven only for devices that receive `ALLOW`.

5. Decide how to treat requests without a token. A modified copy with the protection removed sends no token, so integrity is enforced only when your server ends up requiring a valid token on the protected endpoints. Follow the phases in [Requests Without a Token](#requests-without-a-token).


### Different Rules per Endpoint

Your server does not have to treat a verdict the same way everywhere. Whatever setup you choose, you can apply a stricter rule where the risk is higher:

| Endpoint | Example rule |
| :------- | :----------- |
| Login | `LIMIT` requires a second authentication factor. |
| High-value transfer | Only `ALLOW` is accepted. |
| Sign-up, coupons, rewards | Reject `90003`, `90004`, and `90006`, which emulators and unverifiable devices produce. |
| Read-only requests | `ALLOW` and `LIMIT` are both accepted. |

## Troubleshooting

| Symptom | What to check |
| :------ | :------------ |
| No token header arrives from a sealed build | The build was sealed with version 3.3.0.0 or higher, with Hardware Key Attestation enabled and at least one Target URL.<br/>The request URL matches a Target URL as plain text, including a trailing slash and a query string.<br/>The request is sent through a [supported HTTP client](#supported-http-clients).<br/>It is not the first request after the app started on a slow network. |
| The app closes on a test device | A case with the Deny action was detected, typically an unlocked bootloader on a development device. Test on a device with a locked bootloader, or turn the case off in Custom mode while you test. |
| Every token carries `LIMIT` | Emulators and devices without hardware-backed attestation always receive `LIMIT`. `ALLOW` needs a physical device with a locked bootloader. Read `verdictCodes` for the reason. |
| Signature verification fails | You are using the public key of the account that sealed the app.<br/>Your code allows `ES256`.<br/>The whole header value is passed to the library, with nothing added or cut off. |
| Tokens are rejected as expired | Your server's clock is synchronized, and a few seconds of difference are allowed. The app renews the token before it expires, so repeated expiry points at the server clock. |
| Sealing fails after you enable attestation | No supported HTTP call site was found in the app, or the only Target URL is `*`. |
| A detection mode change has no effect | Allow a few minutes for the change to apply. A token that was already issued stays valid until it expires. |

## Before You Go Live

- You know how many users a Deny case would close the app for. If not, run [Observe first](#observe-first).
- Your server handles `LIMIT` on purpose, including `90002`. A device with a revoked attestation certificate arrives as `LIMIT`, not `DENY`.
- Your server verifies the signature before it reads any claim, and rejects invalid tokens with the same generic response.
- Your server validates `exp` and does not reject repeated `jti` values.
- Your policy for requests without a token starts in the Monitor phase, with an alert on sudden changes, and you have decided when it moves to Restrict or Block. Attestation is not enforced until it does.
- You tested with a sealed build on a physical device. An unsealed or debug build does not attach the token.
- You treat a detection mode change as a production change. It reaches released apps within minutes, without a new release.
- If you use `aaSignatureDigests`, you trust it only when `verdict` is `ALLOW`.

## Using It with the CLI Tool

The CLI tool has no options for Hardware Key Attestation. To apply it when you seal through the CLI, use a [sealing preset](https://docs.doverunner.com/mobile-app-security/android/android-preset/):


1. Set the detection mode for the app in App Configurations, as described above.
2. Open **Android → Preset** and create or edit a preset with sealing version 3.3.0.0 or higher.
3. In **Advanced Features**, enable **Hardware Key Attestation** and add the Target URLs, then save the preset.
4. Seal with the preset name:

   ```bash
   $ java -jar sealing.jar -url https://api.appsealing.com/covault/gw -authkey 123456789ABCDE -srcapk app-release.aab -sealedapk app-release-sealed.aab -sealing_preset_name my-preset-name
   ```


See [Using a Preset with the CLI Tool](https://docs.doverunner.com/mobile-app-security/android/android-preset/#using-a-preset-with-the-cli-tool) for the preset naming rules and the related warnings.

## FAQ

### App and Device Behavior

**Does Hardware Key Attestation require Google Play Services?**
No. It uses the hardware-backed keystore that is part of Android, so it also works on devices without Google Play Services.

**Is iOS supported?**
Not at this time. Hardware Key Attestation is available for Android apps only.

**Can I handle a Definitive case without closing the app?**
Not by changing its action: a Definitive case that is turned on always uses Deny, and Deny closes the app. You can turn the case off instead. Such a device then receives `LIMIT` with an empty `verdictCodes`, and your server can restrict it. See [Restrict on the Server Without Closing the App](#restrict-on-the-server-without-closing-the-app).

**Will users on older or unusual devices be blocked?**
Not by the app. Devices that cannot provide hardware attestation receive `LIMIT`, and the app keeps running. What such users can do is decided by how your server treats `LIMIT`.

**I turned a case off in Custom mode. Why do those devices still receive `LIMIT`?**
Turning a case off stops it from being detected and reported, but `ALLOW` is issued only when the device proves its state through hardware-backed attestation. A device that cannot prove it receives `LIMIT` with an empty `verdictCodes`.

**Does it slow down my app?**
The token is issued in the background when the app starts and is kept in memory. Only the first protected request after a start can wait for it, up to about 4 seconds; later requests use the stored token without waiting. On your server, verification is a local signature check.

**How is this different from the Play Integrity API?**
Play Integrity relies on Google Play Services and returns Google's aggregate verdict. Hardware Key Attestation reads the certificate chain produced by the device's hardware keystore and does not depend on Google Play Services. They can be used together.

### Token and Keys

**Why does my server never receive a `DENY` verdict?**
On `DENY` the app shows the threat alert and closes, so no token is sent. Your server receives tokens with `ALLOW` or `LIMIT` only.

**How do I know why a token carries `LIMIT`?**
Read the `verdictCodes` claim. See [Detection Codes with LIMIT](#detection-codes-with-limit).

**How long is a token valid, and should I limit its lifetime myself?**
A token is valid for about two minutes and is renewed by the app before it expires. Validate the `exp` claim and do not add your own maximum lifetime.

**Should I store `jti` values and reject a token I have already seen?**
No. The app reuses one token for several requests until it renews it, so the same `jti` arrives many times from legitimate users.

**Is there a JWKS endpoint, and how often does the key change?**
A JWKS endpoint and key rotation are not provided at this time. Use the public key issued for your account. It does not change, so you do not need a refresh schedule or a check on `kid`.

**Which signature algorithm and format are used?**
Only `ES256`, which is ECDSA with the P-256 curve and SHA-256. Reject tokens that declare any other algorithm. The signature is in the standard JWT format, the raw `R‖S` value (IEEE P1363), not ASN.1 DER. JWT libraries handle this for you; it matters only if you verify the signature with a low-level cryptography API.

**Can I get a sample token for testing?**
Seal a test build of your app with Hardware Key Attestation enabled, call a Target URL from a device, and capture the header on your server. Because the token is signed with your account's key, this also tests your public key.

### Operations

**Which API endpoints should I register as Target URLs?**
The requests that are sensitive in your service, such as login, payment, and changes to account or security settings. There is no fixed list; choose them according to your own risk assessment.

**What should my API return when it rejects a request?**
A generic error, such as HTTP 403 with no reason. Keep the reason in your own logs. Detailed error codes show an attacker which check failed.

**What happens if the DoveRunner attestation server is unavailable?**
Your server keeps verifying tokens, because verification needs only the stored public key. Apps cannot obtain new tokens during the outage, so their requests arrive without a token. What happens to them depends on your policy for requests without a token: in the Monitor phase they are processed, and once you restrict or block such requests they are restricted or rejected until tokens can be issued again. See [Requests Without a Token](#requests-without-a-token).

**Do I need to seal again after changing the settings?**
After changing Target URLs, yes: seal again and release the new build. After changing the detection mode, no: it is evaluated on the attestation server and applies within a few minutes, including to builds your users already have.