fix: use SecurityLevel.KEYSTORE in createSwAuth to match real hardware

Duck Detector's 'TEE Simulator generate-mode fingerprint' probe scans the
generateKey reply parcel for a 16-byte marker where the securityLevel byte
is 0x00 (SOFTWARE). Real KeyMint HAL uses 0x64 (KEYSTORE=100) for
keystore-enforced metadata (creation time, user ID, etc.).

This single-line change aligns with real hardware behavior and defeats
the probe. Tested on OnePlus 13 (Android 16, KSU 3.2.4):
- Before: 'TEE Simulator generate-mode fingerprint: Matched' (score 50)
- After:  'No TEE Simulator generate-mode fingerprint observed' (score 4)

Reference: https://github.com/eltavine/Duck-Detector-Refactoring/commit/e368038
This commit is contained in:
Andrea-lyz
2026-05-15 16:23:05 +02:00
parent db882ec326
commit 4ecbfc7259
@@ -1123,7 +1123,12 @@ private fun KeyMintAttestation.toAuthorizations(
}
return Authorization().apply {
this.keyParameter = param
this.securityLevel = SecurityLevel.SOFTWARE
// Real KeyMint HAL marks keystore-enforced metadata (creation
// time, user id, etc.) with SecurityLevel.KEYSTORE (0x64), not
// SOFTWARE (0x00). Using SOFTWARE here is detectable by probes
// that scan the generateKey reply parcel for the 0x00 byte at
// the securityLevel slot of the last authorization entry.
this.securityLevel = SecurityLevel.KEYSTORE
}
}