From 9a7e4d72511dcf4907ec965d5045cf06a34b8af4 Mon Sep 17 00:00:00 2001 From: Enginex0 Date: Tue, 19 May 2026 14:35:12 +0100 Subject: [PATCH] fix(intercept): restore updateAad SSE injection Reverts 180dc03. The updateAad SSE injection landed earlier as the F1 quirk fix and was part of the score-4 baseline on mt6768. It was reverted in error during the score-4-to-14 rollback; the actual regression driver was the uncommitted DELETE_KEY absorber which has already been dropped. Restoring to match the working baseline. --- .../keystore/shim/KeyMintSecurityLevelInterceptor.kt | 3 ++- .../interception/keystore/shim/OperationInterceptor.kt | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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 8e57f01..6a9ea1c 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 @@ -194,7 +194,8 @@ class KeyMintSecurityLevelInterceptor( SystemLogger.info("Found new IKeystoreOperation. Registering interceptor...") val backdoor = getBackdoor(target) if (backdoor != null) { - val interceptor = OperationInterceptor(operation, backdoor) + val isAead = parsedParams.blockMode.firstOrNull() == BlockMode.GCM + val interceptor = OperationInterceptor(operation, backdoor, isAead) register(backdoor, operationBinder, interceptor, OperationInterceptor.INTERCEPTED_CODES) interceptedOperations[operationBinder] = interceptor } else { diff --git a/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/OperationInterceptor.kt b/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/OperationInterceptor.kt index c8236a3..b8051ac 100644 --- a/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/OperationInterceptor.kt +++ b/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/OperationInterceptor.kt @@ -13,6 +13,7 @@ import org.matrix.TEESimulator.interception.keystore.InterceptorUtils class OperationInterceptor( private val original: IKeystoreOperation, private val backdoor: IBinder, + private val isAead: Boolean, ) : BinderInterceptor() { override fun onPreTransact( @@ -27,6 +28,10 @@ class OperationInterceptor( val methodName = transactionNames[code] ?: "unknown code=$code" logTransaction(txId, methodName, callingUid, callingPid, true) + if (code == UPDATE_AAD_TRANSACTION && !isAead) { + return InterceptorUtils.createServiceSpecificErrorReply(KeystoreErrorCodes.invalidTag) + } + if (code == FINISH_TRANSACTION || code == ABORT_TRANSACTION) { KeyMintSecurityLevelInterceptor.removeOperationInterceptor(target, backdoor) } @@ -44,7 +49,8 @@ class OperationInterceptor( private val ABORT_TRANSACTION = InterceptorUtils.getTransactCode(IKeystoreOperation.Stub::class.java, "abort") - val INTERCEPTED_CODES = intArrayOf(FINISH_TRANSACTION, ABORT_TRANSACTION) + val INTERCEPTED_CODES = + intArrayOf(UPDATE_AAD_TRANSACTION, FINISH_TRANSACTION, ABORT_TRANSACTION) private val transactionNames: Map by lazy { IKeystoreOperation.Stub::class