Google SafetyNet attestation workarounds for Magisk
Go to file
osm0sis 3a3f95b696 magisk: fix Realme fingerprint reader issues
- move ro.boot.flash.locked to late props since any earlier appears to break Realme fingerprint readers

Thanks @byxiaorun for finding the problem prop, and @Jowat97 for testing
2021-12-21 15:15:28 -08:00
.github github: Add Patreon funding link 2021-07-04 00:22:44 -07:00
java_module Use constant for name when removing real provider 2021-10-16 17:21:00 -07:00
magisk magisk: fix Realme fingerprint reader issues 2021-12-21 15:15:28 -08:00
zygisk zygisk: Remove template readme 2021-11-15 22:02:55 -08:00
.gitignore magisk: Add new module template 2021-10-30 17:51:53 -07:00
.gitmodules zygisk: Import Zygisk module template 2021-10-30 17:50:50 -07:00
build.sh build: Update for Zygisk + new Magisk template 2021-10-30 17:51:55 -07:00
LICENSE Remove Riru implementation 2021-10-30 18:33:29 -07:00
README.md readme: Update for 2.1.2 and 2.2.0 releases 2021-11-15 22:13:12 -08:00

Universal SafetyNet Fix

This is a universal fix for SafetyNet on devices with hardware-backed attestation and unlocked bootloaders (or custom verified boot keys). It defeats both hardware attestation and the SafetyNet CTS profile updates released in 2021. The only requirement is that you can pass basic attestation, which requires a valid combination of device and model names, build fingerprints, and security patch levels. MagiskHide is required as a result.

Passing basic attestation is out-of-scope for this module; this module is meant to defy hardware attestation, as well as reported "basic" attestation that actually uses hardware under-the-hood. Use MagiskHide Props Config to spoof your CTS profile if you have trouble passing basic attestation. This is a common issue on old devices and custom ROMs.

Android versions 712 are supported, including OEM skins such as Samsung One UI and MIUI. This module requires Zygisk (for Magisk Canary) or Riru (for stable Magisk).

Installation

The module must be installed using Magisk Manager, not TWRP or any other custom recovery.

Always make sure you have the latest version of the module installed before reporting any issues.

Zygisk

If you are using Magisk Canary, you need the Zygisk version of this module. Download and install the latest Zygisk version of this module from GitHub Releases.

Riru

If you are using stable Magisk, you need the Riru version of this module. Download and install the latest Riru version of this module from GitHub Releases. You will also need to install "Riru" through Magisk Manager.

How does it work?

Google Play Services opportunistically uses hardware-backed attestation to enforce SafetyNet security (since January 12, 2021), and enforces its usage based on the device model name (since September 2, 2021).

This module uses Riru to inject code into the Google Play Services process and then register a fake keystore provider that overrides the real one. When Play Services attempts to use key attestation, it throws an exception and pretends that the device lacks support for key attestation. This causes SafetyNet to fall back to basic attestation, which is much weaker and can be bypassed with existing methods.

However, blocking key attestation alone does not suffice because basic attestation fails on devices that are known by Google to support hardware-backed attestation. This module bypasses the check by appending a space character to the device model name. This has minimal impact on UX when only applied to Google Play Services, but it's sufficient for bypassing enforcement of hardware-backed attestation.

Unlike many other approaches, this doesn't break other features because key attestation is only blocked for Google Play Services, and even within Play Services, it is only blocked for SafetyNet code. As a result, other attestation-based features (such as using the device as a security key) will still work.

ROM integration

Ideally, this workaround should be incorporated in custom ROMs instead of injecting code with a Magisk module. See the ProtonAOSP website for more information.

Support

If you found this module helpful, please consider supporting development with a recurring donation on Patreon for benefits such as exclusive behind-the-scenes development news, early access to updates, and priority support. Alternatively, you can also buy me a coffee. All support is appreciated.