TEESimulator: Android keystore simulation
TEESimulator earns its place on a researcher's device. It does one thing with unusual precision: it generates attestation chains that are internally consistent by construction, because they come from the same reference TA that ships in AOSP. That matters when you are testing code that verifies the chain, not just the final flag. The catch is the keybox—you supply it, and until you do the interceptor is a no-op. For security researchers and developers who need this specific capability, it is the most direct path; for anyone else the setup cost exceeds the payoff.
What is TEESimulator?
TEESimulator is a Magisk module that simulates hardware-backed key pairs and attestation on Android. It injects a native library into the keystore daemon at boot, intercepts requests from configured apps, and serves them via a software KeyMint operating within the real keystore process. The attestation certificates it generates are signed with a user-provided keybox, and the rest of the system never knows the difference.
How it hooks into Android's keystore
- ✓Inject interceptors into keystore2 (Android 12+) via PLT-hook on AIBinder_transact, and into the legacy keystore daemon (Android 10/11) via ioctl hook on libbinder
- ✓Route requests per-call: targeted apps hit the simulated KeyMint; everything else forwards to real hardware unchanged
- ✓Generate attestation chains from AOSP's reference KeyMint TA (kmr-ta) using BoringSSL, signed with the user's keybox — internally consistent by construction
- ✓Freeze real device root-of-trust values (verified-boot key, device-locked flag) from a harvest at boot so stored keys stay decryptable
- ✓Profile-based configuration assigns apps to named bundles with their own keybox, patch levels, OS version, and device identity
- ✓WebUI (KernelSU/APatch) for managing profiles, inspecting stored keys, and flashing canary builds in-place
- ✓No-op safety: with no keybox loaded the interceptor simply does nothing, leaving the device fully functional
What you can do with TEESimulator
- •Security researchers testing how apps interpret attestation results without a certified device
- •Developers debugging their own attestation verification code before shipping
- •Auditing apps that check the full certificate chain, not just the PASS/FAIL flag
- •Generating controlled attestation parameters (patch level, OS version, device identity) for fuzzing
- •Running attestation-dependent test suites in CI with a rooted device
Installing TEESimulator
Flash the module zip through Magisk, KernelSU, or APatch and reboot. Place a keybox.xml containing both RSA and ECDSA private keys at /data/adb/teesim/keybox.xml. Create or edit /data/adb/teesim/config.json to list target apps under a named profile, or use the WebUI to configure everything visually. The daemon watches the config directory and applies changes live; no reboot required after edits.
Strengths
- ✓Uses the actual AOSP reference KeyMint TA rather than a reimplementation, so attestation chains match what a real TEE produces
- ✓Per-app routing means the rest of the system—banking apps, payment handlers—continues using genuine hardware keys
- ✓Profile system supports multiple keyboxes and device identity sets for different apps simultaneously
- ✓Root-of-trust values are harvested from real hardware, keeping stored keys decryptable across reboots
- ✓Minimal blast radius: the interceptor is inert without a keybox and recoverable by killing the keystore daemon
Requirements and constraints
- △Requires root access and a 64-bit device (arm64-v8a or x86_64) running Android 10 or newer
- △You must source and manage your own keybox with RSA and ECDSA keys — the module ships none
- △Building from source requires the Android SDK (for aidl) and NDK; prebuilt releases are not officially distributed
- △Apps that verify attestation through Play Integrity API rather than direct keystore queries will not be affected
- △No support for Android versions below 10
How TEESimulator compares to other tools
Frequently asked questions
Yes. It hooks different entry points depending on the version: AIBinder_transact in keystore2 on Android 12+, and ioctl on libbinder in the legacy keystore daemon on Android 10 and 11. Both paths lead to the same reference KeyMint TA and keybox-based signing.
PlayIntegrityFix patches Play Services and the Play Store to return a PASS result without involving the TEE at all. TEESimulator generates genuine attestation certificate chains from a KeyMint TA, so apps that verify the full chain get something structurally identical to what a certified device produces.
Yes, root is mandatory. The module injects a native library into the keystore daemon at boot, which requires privileged access. It works with Magisk, KernelSU, and APatch.
TEESimulator loads AOSP's reference KeyMint TA (kmr-ta) into the keystore process and signs attestation chains with a user-supplied keybox. Because it uses the same code path as a real TEE, the certificates are internally consistent by construction.
TEESimulator targets hardware-backed key attestation at the keystore level. It does not directly affect Play Integrity API checks made by Play Services, which take a separate path. Whether it helps with licensing depends on how that specific app validates attestation.
Without a valid keybox the interceptor stays a no-op and the device functions normally. If something goes wrong, killing the keystore daemon forces a clean restart with no interception until the daemon is re-injected.
The problem it solves
Testing how an app handles attestation is hard when the hardware refuses to cooperate. A physical device reports whatever it reports; an emulator may not implement KeyMint at all. You need a way to generate believable attestation chains with controlled parameters (patch level, verified-boot state, device identity) without a certified device, and you need those chains to hold up under scrutiny by apps that validate the full certificate path.
Who should try it — and who should skip
Security researchers and developers who need to test attestation-dependent app behavior with full certificate chain fidelity. If you are auditing code that validates attestation beyond a simple PASS check, TEESimulator gives you the most accurate simulation available on a single device. Skip it if you just need Play Store access — that use case is better served by simpler patches, and sourcing a valid keybox is non-trivial.
Related repositories
Still deciding about TEESimulator?
One click hands the question to an AI along with this page — see what it says about TEESimulator.
