Commit 5a54bfd
committed
core: Report fake model name to GMS using reflection
SafetyNet currently enforces hardware attestation for specific devices
(mostly Pixels at the moment) by checking the product model name using
Build.MODEL. We could alter the product model name globally, but that's
ugly and can break apps that check the model name for features or to
just report information to the user.
Instead of modifying the model name globally, detect when Google Play
Services is launching and modify the Build.MODEL field in its post-fork
process instead. This is done early during app start before the app's
code starts to run. To be more stealthy, we also use reflection to edit
the final field directly and restore the final modifier once we're done
rather than removing final from the field declaration. This works
because even though part of SafetyNet runs in the context of client apps
(snet.jar), that's just a thin client — the real attestation logic takes
place in Play Services.
Instead of blatantly changing the model name to a completely different
device or dummy name, we only append an invisible U+200B ZERO-WIDTH
SPACE character to it so the user doesn't see a weird device logged into
their Google account. The invisible character is enough to defy
SafetyNet and make it revert back to basic (software) attestation.
This is hidden behind the ro.product.needs_model_edit property to avoid
unnecessary hacks on devices that don't need it.
Change-Id: I09495a7aa1e59b3bd59f3dbd4c9cdd701b00df5d1 parent f62feee commit 5a54bfd
1 file changed
+37
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
285 | 287 | | |
286 | 288 | | |
287 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
288 | 293 | | |
289 | 294 | | |
290 | 295 | | |
| |||
786 | 791 | | |
787 | 792 | | |
788 | 793 | | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
789 | 823 | | |
790 | 824 | | |
791 | 825 | | |
| |||
794 | 828 | | |
795 | 829 | | |
796 | 830 | | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
797 | 834 | | |
798 | 835 | | |
799 | 836 | | |
| |||
0 commit comments