> For AI agents: the complete documentation index is available at /react-native-nitro-device-info/llms.txt, the full documentation bundle is available at /react-native-nitro-device-info/llms-full.txt.

# Device Integrity API

**Local-only** device integrity detection APIs for detecting rooted (Android) or jailbroken (iOS) devices.

:::tip Need server-verifiable attestation?
These checks are local and bypassable. For hardware-backed, server-verified
attestation (Play Integrity / App Attest), see the
[Device Attestation API](/react-native-nitro-device-info/api/device-attestation.md) — an opt-in package that
complements these checks: use local detection as a fast offline pre-filter and
attestation as the gate your server trusts.
:::

## Overview

These APIs perform **local detection only** (file system checks, package detection, etc.) without any server-side verification. They're commonly used as one layer of defense in:

- Financial/banking apps
- Healthcare apps with sensitive data
- Enterprise MDM solutions
- Apps with DRM requirements

:::warning Limitations

**All detection methods are local-only and can be bypassed** by sophisticated tools (Magisk + Shamiko, RootHide, PlayIntegrityFix, etc.).

- **"Not detected" does NOT guarantee a secure device**
- These APIs do NOT use Play Integrity API or iOS App Attest
- Use as one layer of defense-in-depth, not as sole security measure

:::

Read the [availability badge definitions](/react-native-nitro-device-info/api/index.md#availability-badges). Both APIs belong to the core package; web only returns fallback values.

## API Reference

### `isDeviceCompromised()`

<span class="rp-badge rp-badge--tip">Since v1.4.2</span> <span class="rp-badge rp-badge--info">iOS 15.1+</span> <span class="rp-badge rp-badge--info">Android API 24+</span> <span class="rp-badge rp-badge--warning">Web: fallback</span>

Synchronously checks if the device is rooted (Android) or jailbroken (iOS).

```typescript
isDeviceCompromised(): boolean
```

**Returns:** `true` if device is compromised, `false` otherwise

**Performance:** \<50ms

**Emulator Policy:** Returns `false` on emulators/simulators for development convenience.

***

### `verifyDeviceIntegrity()`

<span class="rp-badge rp-badge--tip">Since v1.4.2</span> <span class="rp-badge rp-badge--info">iOS 15.1+</span> <span class="rp-badge rp-badge--info">Android API 24+</span> <span class="rp-badge rp-badge--warning">Web: fallback</span>

Asynchronous wrapper for device integrity verification.

```typescript
verifyDeviceIntegrity(): Promise<boolean>
```

**Returns:** Promise resolving to `true` if device is rooted/jailbroken

**Performance:**

- iOS: up to 200ms (includes SSH port scanning)
- Android: \<50ms (async wrapper for `isDeviceCompromised()`)

**Platform Differences:**

- **iOS:** Includes SSH port scanning (ports 22, 44) in addition to all checks performed by `isDeviceCompromised()`. This additional check can detect OpenSSH installed by jailbreak tools.
- **Android:** Same as `isDeviceCompromised()`, provided as async wrapper for API consistency.

**Emulator Policy:** Returns `false` on emulators/simulators.

## Detection Methods

### Android

| Method         | Priority | Description                                           |
| -------------- | -------- | ----------------------------------------------------- |
| su binaries    | High     | `/system/xbin/su`, `/system/bin/su`, `/sbin/su`, etc. |
| Magisk         | High     | `/data/adb/magisk`, Magisk Manager package            |
| KernelSU       | High     | `/data/adb/ksu`, KernelSU Manager package             |
| APatch         | High     | `/data/adb/apatch`, APatch Manager package            |
| Busybox        | Medium   | `/system/xbin/busybox`                                |
| Build props    | Medium   | `ro.debuggable=1`, `ro.secure=0`, test-keys           |
| Superuser apps | Low      | Legacy SuperSU, Superuser.apk                         |

### iOS

| Method            | Description                                   |
| ----------------- | --------------------------------------------- |
| Jailbreak apps    | Cydia, Sileo, Zebra, Installer 5              |
| URL schemes       | `cydia://`, `sileo://`, `zbra://`, `filza://` |
| System file write | `/private/jailbreak.txt` write test           |
| DYLD injection    | MobileSubstrate, libhooker, TweakInject       |
| Symbolic links    | `/Applications`, `/Library/Ringtones`         |
| SSH ports         | Port 22 (OpenSSH), Port 44 (checkra1n)        |

## Usage Examples

### Basic Check

```typescript
import { DeviceInfoModule } from 'react-native-nitro-device-info';

function SecurityCheck() {
  const isCompromised = DeviceInfoModule.isDeviceCompromised();

  if (isCompromised) {
    return <SecurityWarning />;
  }

  return <SecureContent />;
}
```

### Financial App Protection

```typescript
import { DeviceInfoModule } from 'react-native-nitro-device-info';

async function performTransaction(amount: number) {
  // Use async API for enhanced verification
  const isCompromised = await DeviceInfoModule.verifyDeviceIntegrity();

  if (isCompromised) {
    throw new Error('Transaction blocked: Device integrity check failed');
  }

  // Proceed with transaction
  return processPayment(amount);
}
```

### Conditional Feature Access

```typescript
import { DeviceInfoModule } from 'react-native-nitro-device-info';

function DeviceAuthenticationLogin() {
  const isSecure = !DeviceInfoModule.isDeviceCompromised();
  const hasDeviceAuthentication = DeviceInfoModule.isPinOrFingerprintSet;

  if (!isSecure) {
    // Fall back to password-only login on compromised devices
    return <PasswordLogin />;
  }

  if (hasDeviceAuthentication) {
    return <DeviceAuthenticationPrompt />;
  }

  return <PasswordLogin />;
}
```

## Platform Support

| API                       | iOS            | Android           |
| ------------------------- | -------------- | ----------------- |
| `isDeviceCompromised()`   | ✅              | ✅                 |
| `verifyDeviceIntegrity()` | ✅ (+ SSH scan) | ✅ (async wrapper) |

## Best Practices

1. **Don't rely solely on detection** - Use as one layer of defense-in-depth
2. **Handle gracefully** - Don't crash, provide alternative flows
3. **Log for analytics** - Track detection rates for security insights
4. **Test on real devices** - Emulators always return `false`
5. **Update regularly** - New rooting tools emerge frequently

## See Also

- [Device Attestation](/react-native-nitro-device-info/api/device-attestation.md)
- [isEmulator](/react-native-nitro-device-info/api/device-info.md#isemulator-boolean)
- [isPinOrFingerprintSet](/react-native-nitro-device-info/api/device-info.md#ispinorfingerprintset-boolean)
