yashsingh1/xdaforums huggingface dataset:
[Sony Xperia XZ1 Compact Questions & Answers] j4nn:
[MENTION=5201076]Enyime[/MENTION], if your AndroidAttestation Key is still provisioned, downgrade from pie to oreo seems to be safe if your skip flashing persist.sin.

But the Android Attestation Key seems to be useless after you unlock.

It might be useful only with a locked phone to provide cryptographic prove to external party that your phone runs factory unmodified firmware.

Unlocking does not remove the key. But that key is used by Trust Zone, signing what TZ knows internally and TZ knows if phone was booted via locked verified boot or not. So that key may sign only the true state - locked/unlocked state cannot be falsified into the trust zone, similarly as the bootloader cannot be re-locked.

This makes the Android Attestation Key useless until TZ is exploited first getting full control over it. Even though that was done in past, those vulnerabilities are patched, so I would assume very low probability for that ever to happen.

It looks like everybody seeks all keys to check "OK" while not knowing what they are truly for if useful at all.

Can somebody find a test case for the SOMC FIDO Key for example instead? This one could really be useful.

It should provide cryptographic auth for payments or logins via biometrics (like fingerprint) but not sending biometrics to third party but still doing crypto auth with the third party, using the FIDO key.

It is a difference if fingerprint is used for internal auth in the phone's app or if it enables use of FIDO key which does auth with the third party instead of use of password / pin / whatever...
[Sony Xperia XZ1 Compact Questions & Answers] Gaaat:
I didn't fully understand what you mean for "test case", but I can say that since my somc Fido key became not provisoned I was not able to log into my Google account with a notification on my phone but I had to wait for a one time code sent to my number, fingerprint login into apps seems to work ok, Gpay seems to be functional but I couldn't verify if contactless payments are working.

I lost those keys after I updated to pie.
[Sony Xperia XZ1 Compact Questions & Answers] j4nn:
[MENTION=9165204]Gaaat[/MENTION], by "test case" I mean something, that shows availability or not availability of the FIDO key.

It could be what you mention with google account.

Could you please provide more details?

Did you have two factor authentication enabled with google account?

Somehow connected FIDO key from your phone to it?

And when FIDO key was not available anymore google send you one time code to confirm identity?
[Sony Xperia XZ1 Compact Questions & Answers] Gaaat:
[MENTION=4418980]j4nn[/MENTION] I had two factor authentication enabled and before the downgrade I was able to authorize access on every device just by tapping on a window that popped up in my Xperia Xz premium, now after I log into my account the option "authorize from your device" is grayed out and I can only choose to receive a verification code to my number or to use a backup code, I didn't verify this after the downgrade but I'm sure that before your unlocking the bootloader the keys were provisioned.

Additional informations: when I upgraded to pie after the unlocking during the setup it asked me if I wanted to use this device for authentication and I tapped on yes, but it obviously didn't work.

Also, on service menu > security: there's Suntory blobs [ERROR], while the other options are set on [ACTIVE]
[Sony Xperia XZ1 Compact Questions & Answers] j4nn:
[MENTION=9165204]Gaaat[/MENTION], can you please try the pie version of "secd" ignore unlock patch?

post#395 from [MENTION=4727726]S-trace[/MENTION]

to see if it changes anything with your google account authentication.
[Sony Xperia XZ1 Compact Questions & Answers] Gaaat:
I thinked about it but my device is XZ Premium not XZ1 Compact and I wanted to avoid bootloops, is it safe to install?

Also, I'm on 47.2.A.2.33 not .306
[Sony Xperia XZ1 Compact Questions & Answers] j4nn:
Ok, I missed that you have XZp. I guess it is safe to install - meaning in case of XZp, there is probably no /vendor partition, so flashing it would fail - no change.

If there was /vendor and flashing it went through, it could work. I do not know, if pie for XZp has /vendor partition or not and if so, if the patch binary is "compatible".

You can check if you have /vendor on pie, can't you.
[Sony Xperia XZ1 Compact Questions & Answers] Gaaat:
I've checked with es file Explorer and I have /vendor partition, I'll try to flash asap
[Sony Xperia XZ1 Compact Questions & Answers] yacloo:
XZp doesn't have a vendor partition

/vendor is symlink to /system/vendor
[Sony Xperia XZ1 Compact Questions & Answers] j4nn:
[MENTION=9165204]Gaaat[/MENTION], you may try this one - tried to port the [MENTION=4727726]S-trace[/MENTION]'s patch from xz1c to xzp, using binary from xzp 47.2.A.2.33 fw.

Obviously it is not tested, but I hope it would work. If it does not work, you may reflash system partition to revert the change.

Please test it with regard to somc fido key and your experience with two factor authentication to your google account. Thanks.
[Sony Xperia XZ1 Compact Questions & Answers] Gaaat:
YOU'RE GREAT!!!!! X-Reality working again, somc Fido keys became provisioned again in service menu and Suntory blobs are [Ready], and I can even authorize accesses on my Google account via notification on my XZp.

You did an excellent job!
[Sony Xperia XZ1 Compact Questions & Answers] karrouma:
Tried the xzp 2.33 on my xzp dual 2.33

It is working fine now

Thank you
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
It's work also on my site (G8141).

Thanks a lot :)
[Sony Xperia XZ1 Compact Questions & Answers] landsome:
Have the same problem after newflashing from oreo to pie, also changing customization. Lost android attest key, SOMC attest key no longer shown, SOMC FIDO intact. Nothing to do so far, right?

I also see no effect of losing the attest key, btw.
[Sony Xperia XZ1 Compact Questions & Answers] sulistyoarif:
Great man! Me too. Now all function on my G8142 works fine very well. X Reality and VIDEO IMAGE ENHANCEMENT!!

HUGE THANKS! For your hard work.

Edited: full magisk and me still get OTA update?
[Sony Xperia XZ1 Compact Questions & Answers] kountry83:
Just did the whole thing with backup TA and unlock/restore ta image. Upgrade to latest 47.2.A.4.41 pie for my Sony XZP dualsim. Still shows this, any ideas.

Also another thing I wanted to mention is that I deleted the .ta files and persist sin before I flashed 47.2.A.4.41 pie.
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
Try to restore once again your TA partition... Does you've flashed also the Secd?
[Sony Xperia XZ1 Compact Questions & Answers] kountry83:
Do I have to go back to the exploited firmware to restore again? Yes I did flash the secd_ignore_unlock_XZP_Android_9.0_47.2.A.2.33.zip but I flashed it on 47.2.A.4.41 firmware. Couldn't find the secd ignore for Android_9.0_47.2.A.4.41.
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
The TA you can flash direct under the current firmware. I've make this also some times. During Boot the FW move the keys in the TA.

A newer Secd I haven't seen till now. If the kernel the same (I don't know) , it should not make any difference.
[Sony Xperia XZ1 Compact Questions & Answers] kountry83:
Tried restoring TA-locked.img on 47.2.A.4.41 once again and still shows the same thing as the image I posted and I flashed the secd-ignore-unlocked for XZP pie.

I used these commands:

adb push TA-locked.img /data/local/tmp

cd /data/local/tmp

dd if=TA-locked.img of=/dev/block/bootdevice/by-name/TA

sync

sync

Then rebooted. Am I doing something wrong because it worked perfectly on the exploited Android Oreo XZP G8142 Firmware.

Thanks again
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
Does something not working anymore?

The only reason to flash the Secd was, that the x-video could not enabled in Pie. All others (no OTA) should be working
[Sony Xperia XZ1 Compact Questions & Answers] kountry83:
Only camera works right

Widevine says L3 and video enhancement doesn't work.

This is the only thing that shows good

Only my TEE Listener is active.

Tzxflattest status OK Ver. 2

Everything else shows error and not provisioned.
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
Let's try what's happen, if you go to the FW 2.33 In this version it is working on my side. A higher version is in this momeinot available for me.. So I can't test a higher version in this moment

Gesendet von meinem viennalte mit Tapatalk
[Sony Xperia XZ1 Compact Questions & Answers] kountry83:
Retried everything and flashed 2.33. Everything is showing good now. Thank you!
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
Who can confirm, that also 47.2.A.4.41 is working with a restored TA and Secd Patch, after all thinks was OK in 2.33?
[Sony Xperia XZ1 Compact Questions & Answers] vofferz:
For xz1c everything on 4.41 is just the way it was on 2.33. After secd patch all keys show provisioned, widevine and blobs ready and ok.
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
Which files does you have deleted before update via Newflasher from 2.33 to 4.41 ? Only all *. ta files, the persit and the user.... sin?
[Sony Xperia XZ1 Compact Questions & Answers] vofferz:
Yes, all .ta, and userdata & persist .sin-files. Maybe I also deleted cache or some other "empty" (really small that is) .sin file, but I don't think it has any real effect.

After updating with newflasher, I just flashed magisk and the secd patch again in TWRP and everything works fine. Maybe I had to reinstall some magisk modules also.

Anyway, no keys were lost and everything in the security info screen shows just like before the update.
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
Thx a lot.... now the Central Europe Version must be released to 4.41. So as I've seen in the German Cust Version it is not possible to add a SIP account, which is possible in the CE1 version ;)

Gesendet von meinem viennalte mit Tapatalk
[Sony Xperia XZ1 Compact Questions & Answers] DannyWilde:
Hello all,

after i tried to flash stock firmware Android 9 with newflasher on my XZ2 compact, i saw yesterday that my Attest Key is NOT PROVISIONED too.

I deleted all .ta files befor flashing with newflasher.

Is there any possibility to get Attest key provisioned again?

Does anybody know, what does not work, when keys are not provisioned?

thanks in advanced
[Sony Xperia XZ1 Compact Questions & Answers] j4nn:
[MENTION=7833215]DannyWilde[/MENTION], I am afraid you've lost Android Attest Key forever if you flashed the fw with persist*.sin present with newflasher. That was also my case and the reason I started this thread.

But it is not that bad - this key is not that important.

It might get used only in case your phone is still locked - see post#58 for more details.

With that key present and phone still locked, it is possible for example for google to verify (using crypto certificates and signatures, involving verified boot and trust zone) that your firmware was not unlocked and not modified in any way.
[Sony Xperia XZ1 Compact Questions & Answers] DannyWilde:
My booitloader is locked.

I trink about selling the phone, but i don't want to get another one problemes with this phone.

So do you think I can sell the phone without worrying to harm the one who is going to buy it?
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
If I buy a phone from you and a banking apk will told me, that the device is not trusted.... I'll believe, I will be go in contact with you immediately...

Gesendet von meinem viennalte mit Tapatalk
[Sony Xperia XZ1 Compact Questions & Answers] Gaaat:
Is there a way to patch the secd ignore for 4.41?
[Sony Xperia XZ1 Compact Questions & Answers] vofferz:
It doesn't affect the attest key, so maybe this is the wrong thread. Anyway, I've used the same secd patch that was made for pie 0.306 with 2.33, 4.41 and 4.45. Works just fine.
[Sony Xperia XZ1 Compact Questions & Answers] Gaaat:
As far as I understood it's a way to prevent the phone from verifying the attest key presence, that's why I posted here. Somehow I flashed some persist.sin and lost those keys so the secd ignore is the only way I have to re-enable X-Reality and other functionalities that need them.

Correct me if I'm wrong, but I suppose that the patch is working in your case because you still have your persist partition intact.

(Also, I'm using an XZ Premium, not XZ compact or XZ1)
[Sony Xperia XZ1 Compact Questions & Answers] DannyWilde:
So you think a banking app will not work?

Will i notice this, when i install an banking app?

Or when i will try to pay whith an app?
[Sony Xperia XZ1 Compact Questions & Answers] j4nn:
[MENTION=7833215]DannyWilde[/MENTION], in my opinion that would not happen anytime soon. The reason is that there are lot of devices that do not have hardware backed keystore and attestation.

This hw back cryptographic attestation might allow google not to offer install of specific apps, but only in case they would require hw backed attestation. That means all those devices that do not have such feature in their chipset could not be verified in such way. So this is a "feature" for future, when nearly all phones have such thing and when google decides based on that majority that it is no longer needed to support phones without it. Similarly a vendor of a certain app can make this decision for his app (like a bank for a banking app).

So in case a bank decides to require hw back attestation to verify a phone in order to allow install of the app from play store, all older devices would be forbidden too and they still could even be locked not modified at all.

So in far future, if you do not unlock until then, the android attest key might get a use.

Think about it, how much useful is that.
[Sony Xperia XZ1 Compact Questions & Answers] j4nn:
This thread is primarily about the attest key. Patching secd does not have any influence to that key.

If you have lost your persist partition, you can never have your attest key back.

When you unlock, it does not matter if you have persist still with your phone's attest key or not - unlocked device only "verifies" as unlocked no matter what you do!

Having Android Attest Key "PROVISIONED" with unlocked device (either with or without patched secd) provides only a placebo effect - in reality having it (untouched persist partition) would only make easier to google to discover that your phone has been unlocked!
[Sony Xperia XZ1 Compact Questions & Answers] vofferz:
Secd patch at least for me makes suntory blobs appear ok and somc fido key provisioned. Also makes x-reality work again because on some level android thinks that bl is locked.

Anyway, afaik Android attest key has nothing to do with the secd patch.
[Sony Xperia XZ1 Compact Questions & Answers] j4nn:
howto trully verify Android Attest Key working presence

I've modified the Auditor app (original source available here: AndroidHardening/Auditor) so it can be simply used to check if our Android Attest Key is really present and working or not.

And that in both cases - with still locked phone and also with already unlocked phone.

Following modifications have been done (see also attached git diff against v7 for the source code changes):

simplified the attestation not to require a second device, instead verification results from auditor mode are displayed right away in auditee mode

added device info for unlocked xz1 and xz1c (they have new verified boot key after unlock)

verification screen now shows info obtained from TEE which is signed in TEE

relaxed all the checks that original app refused to continue with attestation:

original author apk signature check removed

allow attestation of unlocked devices

do not check for minimum OS/Vendor/Boot patch levels

moved certificates chain verification at the end so that obtained info can be at least logged

added logging of certificates chain and they verification status of each step

added logging of parsed attestation extension block

removed display of device identity (fingerprint) so we can freely post images here

moved display of "OEM unlocking allowed" item up in order to fit into the top screenshot

instead of the basic/strong attestation variants, the green and orange colors are used for locked and unlocked bootloader status

If you have your attest key present, this app will detect your unlocked bootloader even if magisk is used to mask that trying to look as a locked phone.

If response from TEE is modified, it is detected by signature checks of certificates chain.

Attached you can find a debug apk build of the modified Auditor v7.

After touching Auditee button just scan any auditor challenge QR code - the 2nd screenshot available here on playstore works just fine (avoiding need of Auditor device).

If you get "Error encountered verifying attestation: signature verification failed" right after QR scan, just the upper right menu to "Clear Auditee pairings" and try again please.
[Sony Xperia XZ1 Compact Questions & Answers] j4nn:
A phone with lost attestation key cannot be used by Auditor app as there is an exception right at start - documented already in post#30 in this thread.

And as discovered by [MENTION=4782500]pbarrette[/MENTION] (see post#13 here, thanks) the Android Attestation Key status in the service tests security screen can be made provisioned by simply creating of 5 empty files in keymaster64 directory - but that would not make the key working obviously.

Conclusion:

Android attest key might only be useful if bootloader is still locked to provide cryptographic proof of still locked verified boot untouched stocked firmware running on the phone.

If bootloader is unlocked, that key may be used by external party (play store for example) to easily detect unlocked state without any possibility to fake that due to certificate chains leading to google's root certificate, so they can easily check (outside of the phone) all the signatures of from the phone retrieved hw backed attestation data.
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
Install e. g. the app from from" Sparkasse ".

It doesn't matter if I hide Magisk or not : on the start screen there is a notificationin red that the phones is rooted

Gesendet von meinem viennalte mit Tapatalk
[Sony Xperia XZ1 Compact Questions & Answers] vofferz:
That probably has nothing to do with the Android attest keys. The app just detects root/magisk even with magiskhide.
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
You are right, but I'll believe DannyWilde wants ell his phone (without telling unlook/root)
[Sony Xperia XZ1 Compact Questions & Answers] DannyWilde:
I did this a few days befor. The app worked without any problemes.
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
The app is working without problems, but is readable that the phone is rooted... the question was a few days before, what's happen if the phone sold.... does a buyer recognized that something was modified with the phone e. g. Banking SW.

My short answer : yes

Gesendet von meinem viennalte mit Tapatalk
[Sony Xperia XZ1 Compact Questions & Answers] S1gma:
Just tested it on my never unlocked/never rooted xz1c with attest key lost. No, the mentioned app does not produce any error nor warning. Lack of attest key is not visible to user of never unlocked phone. At least for now.
[Sony Xperia XZ1 Compact Questions & Answers] DannyWilde:
I did not see any notification when using the banking app.
[Sony Xperia XZ1 Compact Questions & Answers] j4nn:
Updated the first post adding the most important info (with posts links) there, marking the thread as [SOLVED].

Thanks again to all who participated in testing/research of anything regarding the android attest key.
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
In the case that we need a newer Secd patch : does it will be available here in this thread.?
[Sony Xperia XZ1 Compact Questions & Answers] j4nn:
[MENTION=7055162]mad0701[/MENTION], secd patches in this thread are off topic. Some was provided just for the purpose to check about a key presence test procedure.

In my opinion - all those secd patches variants - they are not a proper solution. There are other components in the fw that check unlock status independently.

A proper solution is now available with my kernel patch that hides bootloader unlock on kernel level and therefore allows completely unmodified stock fw, including possibility to fully install fota system update. With locked TA restored the security screen looks perfect with that kernel.

Just check following threads for more details:

[XZp] rooted kernel hiding bootloader unlock with working fota

[XZ1] rooted kernel hiding bootloader unlock with working fota

[XZ1c] rooted kernel hiding bootloader unlock with working fota

[XZ1c/XZ1/XZp] temp root exploit to backup drm keys implemented post#663 and post#667: [XZ2] rooted kernel hiding bootloader unlock with working fota (tested by [MENTION=3989065]serajr[/MENTION] who posted short video proof in post#672) - TA backup not available for XZ2, but with my kernel patch, we were able to do fota system update on unlocked and rooted XZ2 phone having root before and after fota installation regardless drm keys had been lost
[Sony Xperia XZ1 Compact Questions & Answers] mad0701:
Hmmm...

I have seen the linked thread some times ago..

But:

I've saved the TA partition (unlooked) Ok

I've unlooked the BL Ok

I've flashed TWRP = Nok (for your kernel)

Secd patch works beautiful... if I could following this way, it will be nice.... flash an update via Newflasher, flash TWRP, Secd and Magisk behind and all things are running well.

The kernel must be recompiled at every update; isn't it?

Im not sure, if I flash the FW once again via Newflasher (with any ta files, persit*, SSD* and user data. sin) if the kernel works together with pre-installed TWRP and maybe touched partitions.
[Sony Xperia XZ1 Compact Questions & Answers] j4nn:
[MENTION=7055162]mad0701[/MENTION], there are multiple ways possible to use the kernels. In my opinion, the best way is to have untouched stock fw, having systemless customizations provided by proper magisk modules. As mentioned, twrp may also be booted from usb via 'fastboot boot', so it is not necessary to flash it.

But as described also, there are alternative use of the kernels. So if you do not want fota system update, there is a way to flash the kernel (and flash twrp too if wanted) and just benefit from proper way to hide unlocked state. If used only proper systemless customizations via magisk modules, you could still revert to untouched fw just before planning for fota system update by flashing stock kernel and stock recovery (fota kernel) and fastboot boot my kernel for the fota update.

I agree that the secd patch makes at least service menu security screen look all right (assuming locked TA restored).

But I know there are other binaries in stock fw that check about unlock status independently from secd. I am not sure what influence that could have.

Can you be 100% sure, that having just the secd patch does not have some other function limited/not working even though security screen looks good?

It would be great for example if someone could compare camera quality on pie of a phone with lost drm keys to a phone either still locked or to a phone with locked TA restored running my unlock hiding kernel (anybody who followed properly my renoroot howto to backup TA should have saved both - unlocked and locked TA state - so all of you can just restore TA-unlocked.img to get to lost drm keys state for testing and comparisons, restoring TA-locked back later when done).

You know, it has been proved already in this thread, that info in the security screen may not always tell, if something really works or not.

So patched secd might just provide a placebo effect.

On the other hand, my kernel patch effectively "fixes" all binaries in the fw asking about unlock state via trust zone api, so in my opinion, this makes the phone much closer (with TA restored) to a still locked one.

You are right about the need to recompile the kernel for each new release - I agree, that is unfortunate. But I do not have any better way.