Skip to content

fix(intercept): use ContinueAndSkipPost for KEY_ID createOperation NOT FOUND#26

Merged
Enginex0 merged 1 commit into
Enginex0:mainfrom
Andrea-lyz:fix/createOperation-key-id-not-found
May 30, 2026
Merged

fix(intercept): use ContinueAndSkipPost for KEY_ID createOperation NOT FOUND#26
Enginex0 merged 1 commit into
Enginex0:mainfrom
Andrea-lyz:fix/createOperation-key-id-not-found

Conversation

@Andrea-lyz

@Andrea-lyz Andrea-lyz commented May 26, 2026

Copy link
Copy Markdown

When handleCreateOperation receives a Domain.KEY_ID request for a key not in our generatedKeys cache, it correctly forwards to the real HAL. However, it previously returned TransactionResult.Continue, which lets the post-handler run. The post-handler unconditionally registers an OperationInterceptor on the IKeystoreOperation binder returned by real keystore2. This interceptor then interferes with the caller's operation (intercepting finish/abort/updateAad calls).

On devices where vendor daemons (e.g. fingerprint calibration) use Domain.KEY_ID for their hardware-backed keys, this causes operation failures.

Fix: return ContinueAndSkipPost (matching the existing Domain.APP NOT FOUND path) so the post-handler never runs for operations on keys we don't own.

Symptom: OnePlus engineering mode ultrasonic fingerprint calibration hash retrieval fails with module enabled, works with module disabled.

Summary by CodeRabbit

  • Bug Fixes
    • Improved key operation handling by preventing post-operation logic from executing when a requested key identifier cannot be resolved, enhancing system efficiency and reducing unnecessary processing in error scenarios.

Review Change Stack

…T FOUND

When handleCreateOperation receives a Domain.KEY_ID request for a key
not in our generatedKeys cache, it correctly forwards to the real HAL.
However, it previously returned TransactionResult.Continue, which lets
the post-handler run. The post-handler unconditionally registers an
OperationInterceptor on the IKeystoreOperation binder returned by real
keystore2. This interceptor then interferes with the caller's
operation (intercepting finish/abort/updateAad calls).

On devices where vendor daemons (e.g. fingerprint calibration) use
Domain.KEY_ID for their hardware-backed keys, this causes operation
failures — the OperationInterceptor races with the immediate
finish/abort call and may reject updateAad with INVALID_TAG if the
operation is not GCM mode.

Fix: return ContinueAndSkipPost (matching the existing Domain.APP NOT
FOUND path) so the post-handler never runs for operations on keys we
don't own. When the key IS in generatedKeys, we never reach this
return — we proceed to create a SoftwareOperation directly in
pre-transact.

Symptom: OnePlus engineering mode ultrasonic fingerprint calibration
hash retrieval fails with module enabled, works with module disabled.

Signed-off-by: Andrea-lyz <Andrea-lyz@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 26, 2026 20:55
@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ee1b0a85-aa98-4cb6-97bb-7d494b92654e

📥 Commits

Reviewing files that changed from the base of the PR and between b7983ce and ab4c1e9.

📒 Files selected for processing (1)
  • app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt

📝 Walkthrough

Walkthrough

This PR modifies how the KeyMint security level interceptor handles failed KeyId lookups. When a requested KeyId cannot be resolved from in-memory generated keys, the interceptor now skips post-transact interception by returning TransactionResult.ContinueAndSkipPost instead of TransactionResult.Continue.

Changes

KeyId Lookup Failure Handling

Layer / File(s) Summary
KeyId lookup failure handling
app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt
When a Domain.KEY_ID request cannot be resolved for the calling UID in handleCreateOperation, the transaction result changes from Continue to ContinueAndSkipPost, preventing post-transact interception from running for that case.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A KeyId sought but couldn't be found,
So skip the post-logic, don't look around—
Continue, but lightly, past the transaction's end,
One line of change, a swift defense.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: using ContinueAndSkipPost instead of Continue for the KEY_ID createOperation NOT FOUND case, which directly addresses the problem stated in the PR objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates KeyMint security-level interception behavior so that a “key not found” path forwards to HAL while skipping post-interception handling.

Changes:

  • Return TransactionResult.ContinueAndSkipPost instead of TransactionResult.Continue when the key entry is missing and the call is forwarded to HAL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -317,7 +317,7 @@ class KeyMintSecurityLevelInterceptor(
entry ?: run {
trackAndEnforceOpLimit(callingUid, txId)?.let { return it }
SystemLogger.info("[TX_ID: $txId] createOperation KeyId(${keyDescriptor.nspace}) NOT FOUND for uid=$callingUid. Forwarding to HAL.")
@Enginex0 Enginex0 merged commit 0eb8eb4 into Enginex0:main May 30, 2026
1 check passed
Enginex0 added a commit that referenced this pull request May 30, 2026
Grant-plane coherence (Android 16 incl.), Google Wallet + fingerprint
compatibility (PR #26/#27), and removal of the in-module PIF/bulletin
resolvers. Frozen at gitCommitCount 251.
@Andrea-lyz Andrea-lyz deleted the fix/createOperation-key-id-not-found branch May 30, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants