CodeBlanks Logo Icon CodeBlanks

Anti-tamper

Learn anti-tamper and jailbreak detection.

What is anti-tamper?

Anti-tamper means stopping or limiting the app on a modified device. Jailbreak (iOS) and root (Android) detection are run. On these devices app data can be stolen; that is why sensitive features are turned off.

In React Native detection is done with react-native-jailbreak-detect or expo-secure-store. When jailbreak is detected the app hides sensitive screens or closes entirely. This is standard in payment and banking apps. Full protection is not possible; but detection makes the attacker's job harder. Anti-tamper is most effective when paired with obfuscation.

Practice Write a jailbreak detection function

Write an isJailbroken function. If the platform is 'ios' return true (simple skeleton). Use Platform.OS.

Starter code

App.js
import { Platform } from 'react-native';

// Add the isJailbroken function here

Sample solution

App.js
import { Platform } from 'react-native';

function isJailbroken() {
  if (Platform.OS === 'ios') {
    return true;
  }
  return false;
}

Reacting to detection

When jailbreak is detected the app can react in two ways: hide sensitive features or close entirely. Banking apps usually close; e-commerce apps only hide the payment step.

Example: if (isJailbroken()) { return <View><Text>This device is not supported</Text></View>; }. This informs the user and also stops someone trying to steal data. Detection is not always 100% accurate; that is why it is paired with encrypted storage like expo-secure-store. Encrypted storage makes data unreadable even on the device.

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which platform has root?

App.js
isRooted()
  • Web
  • Windows
  • Android Correct answer
  • iOS

Explanation: Root is the modified state of Android devices.

2 Platform check

Question
if (____.OS === 'ios')
Answer
if (Platform.OS === 'ios')

Explanation: Platform.OS comes from react-native.

3 Match each piece to its role

Term Meaning
jailbreak iOS modification
root Android modification
isJailbroken Detection function
expo-secure-store Encrypted store

All lessons in Expert