From 7d4c753d66a671b2e8206c9092336b194b8ec45f Mon Sep 17 00:00:00 2001 From: JingMatrix Date: Thu, 4 Dec 2025 02:00:37 +0100 Subject: [PATCH] Bypass KeyMint hooks for certain UIDs Adds a check using `ConfigurationManager.shouldSkipUid` at the start of the `onPreTransact` handlers for key generation and import. If a UID is configured to be skipped, the transaction is forwarded directly to the hardware, and the post-transaction hook is bypassed. This prevents certificate patching and other modifications for trusted or problematic apps, improving compatibility. --- .../keystore/shim/KeyMintSecurityLevelInterceptor.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt b/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt index 3484649..7f4f940 100644 --- a/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt +++ b/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt @@ -44,11 +44,15 @@ class KeyMintSecurityLevelInterceptor( if (code == GENERATE_KEY_TRANSACTION) { logTransaction(txId, transactionNames[code]!!, callingUid, callingPid) + if (ConfigurationManager.shouldSkipUid(callingUid)) + return TransactionResult.ContinueAndSkipPost data.enforceInterface(IKeystoreSecurityLevel.DESCRIPTOR) return handleGenerateKey(callingUid, data) } else if (code == IMPORT_KEY_TRANSACTION) { logTransaction(txId, transactionNames[code]!!, callingUid, callingPid) + if (ConfigurationManager.shouldSkipUid(callingUid)) + return TransactionResult.ContinueAndSkipPost data.enforceInterface(IKeystoreSecurityLevel.DESCRIPTOR) val alias = data.readTypedObject(KeyDescriptor.CREATOR)?.alias