> ## Documentation Index
> Fetch the complete documentation index at: https://docs.musterbox.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment integrity & anti-tamper

> The on-device integrity checks that gate purchases, and how to respond.

Before any purchase, the SDK inspects the host for tamper indicators. This is
a **pre-gate**: detected risks block the purchase before a request is sent.

## The check

```rust theme={"dark"}
use musterbox_sdk::security::check_environment_integrity;

let env = check_environment_integrity();
// env.level -> "SAFE" | "WARN" | "COMPROMISED"
// env.risks -> [{ name, supported, detected }]
```

Browser/engine equivalents (`checkEnvironmentIntegrity`) surface the same
levels.

## Risk classification

| Level         | Trigger                                                           | Purchase effect  |
| ------------- | ----------------------------------------------------------------- | ---------------- |
| `SAFE`        | No risks detected                                                 | Proceeds to mint |
| `WARN`        | Non-critical risk (screen recording, suspicious accessibility, …) | Blocked          |
| `COMPROMISED` | Critical risk (`DEVICE_ROOTED`, `DEBUGGER_ATTACHED`)              | Blocked          |

On any detected risk the SDK:

1. reports an `ENV_COMPROMISED` security event (best-effort, backend `202`),
2. returns `PurchasePreflight::Blocked { level, risks }`.

No purchase request is sent.

## What to do when a purchase is blocked

* Read `level` + `risks` from the pre-flight result and surface a generic,
  player-safe message ("purchase is unavailable on this device").
* **Do not** retry automatically — the environment will not change mid-session.
* Treat repeat blocks on the same device as a signal for your operations team.

## Beyond purchase-gating: host hardening

Integrity checking exists to protect the purchase path. It is **not** a
complete anti-cheat. For gameplay integrity:

* run your own authoritative server (the platform only agrees on *who*, *which
  match*, and *what result*),
* use the mutual-claim protocol (both participants must agree),
* keep `boardHash` proof game-defined and opaque.

## Reporting

If you believe a device is compromised or your game was targeted:

* report through the SDK security-event channel,
* then follow [Report a security incident](/guides/report-security-incident).

Next: [Report a security incident](/guides/report-security-incident).
