Skip to content

Device Integrity & Anti-Tampering

All integrity checks are synchronous TurboModule calls — safe to use before any sensitive operation without awaiting a promise.

Basic checks

typescript
import {
  isRooted,
  isEmulator,
  isDebuggerAttached,
  isDeveloperModeEnabled,
  isHooked,
  verifySignature,
  getRootReasons,
} from '@think-grid-labs/react-native-shield';

const checkIntegrity = () => {
  if (isRooted()) {
    // Block sensitive actions or wipe session tokens
  }
  if (isEmulator()) {
    // Reject automated environments in production builds
  }
  if (isDebuggerAttached()) {
    // Halt execution to prevent runtime inspection
  }
  if (isDeveloperModeEnabled()) {
    // ADB/Developer Mode active (Android)
  }
  if (isHooked()) {
    // Frida/Xposed/Substrate detected — runtime may be instrumented
  }
  if (!verifySignature('YOUR_EXPECTED_SHA256_HASH')) {
    // APK may have been modified and redistributed
  }
};

Root / Jailbreak reason codes

Instead of a plain boolean, get a list of why the device is flagged — useful for risk scoring, logging, or tuning sensitivity per environment.

typescript
const reasons = getRootReasons();
// Android: ['su_binary', 'dangerous_packages']
// iOS:     ['jailbreak_files', 'sandbox_escape']

if (reasons.length > 0) {
  reportThreat({ reasons, platform: Platform.OS });
}

Reason code reference

CodePlatformMeaning
build_tagsAndroidBuild.TAGS contains test-keys
su_binaryAndroidsu binary found in common paths
su_commandAndroidwhich su command succeeded
dangerous_packagesAndroidKnown root manager apps installed (Magisk, SuperSU)
mount_flagsAndroid/system mounted read-write
jailbreak_filesiOSCydia, Sileo, Zebra, MobileSubstrate, bash, sshd found
sandbox_escapeiOSWrite outside sandbox succeeded
cydia_schemeiOScydia:// URL scheme is openable
substrate_loadediOSMobileSubstrate dylib loaded in process

Use cases

  • Banking / fintech — block transactions when su_binary or sandbox_escape is present
  • DRM-protected content — deny playback on devices with dangerous_packages
  • Risk-adaptive UX — show a warning without blocking when only build_tags is set (mild signal)

Implementation details

CheckAndroidiOS
RootBuild.TAGS, su binary scan, known root packages, /proc/mountsJailbreak files, sandbox write test, Cydia URL, dyld substrate scan
EmulatorBuild.FINGERPRINT/MODEL/HARDWARE/PRODUCT patternsTARGET_OS_SIMULATOR compile-time macro
Debuggerandroid.os.Debug.isDebuggerConnected()sysctl P_TRACED flag
SignatureSHA-256 of PackageManager signing certsPresence of embedded.mobileprovision
HookingClassLoader probe (Xposed/Substrate), frida-server filedyld image scan (Frida, Substrate, cycript, SSLKillSwitch)
Dev modeSettings.Global.DEVELOPMENT_SETTINGS_ENABLED, ADB_ENABLEDNot supported — always false

Released under the MIT License.