Skip to content

Skip requiresCryptoObject branch for verifyIdentity to prevent crash - #102

Closed
AlexBurrowsTBA wants to merge 1 commit into
Cap-go:mainfrom
tba-doncaster:verify-fix
Closed

Skip requiresCryptoObject branch for verifyIdentity to prevent crash#102
AlexBurrowsTBA wants to merge 1 commit into
Cap-go:mainfrom
tba-doncaster:verify-fix

Conversation

@AlexBurrowsTBA

@AlexBurrowsTBA AlexBurrowsTBA commented Jul 8, 2026

Copy link
Copy Markdown

verifyIdentity() (with mode="verify") is for identity confirmation and doesn't perform any keystore/crypto operations, but the default configuration sets requireCryptoObject to true, which causes AuthActivity to create a CryptoObject and pass it to BiometricPrompt.authenticate().

This triggers two bugs:

  1. When no allowedBiometryTypes are specified, the default config sets promptAuthenticators to BIOMETRIC_STRONG | BIOMETRIC_WEAK with a CryptoObject - Android's BiometricPrompt requires BIOMETRIC_STRONG only when a CryptoObject is present, so this throws IllegalArgumentException on every device regardless of hardware.
  2. Even if the caller works around the first bug by passing allowedBiometryTypes=[FINGERPRINT] to force BIOMETRIC_STRONG only, the onAuthenticationSucceeded callback runs validateCryptoObject() which can fail with "Biometric security check failed" despite successful authentication.

This commit adds "verify".equals(mode) guards in AuthActivity to:

  • Skip CryptoObject creation in the authenticate path
  • Skip CryptoObject validation in the success callback

Secure credential modes are unaffected and continue to use the crypto path as before.

Summary by CodeRabbit

  • Bug Fixes
    • Improved biometric verification flow so successful verification completes immediately and consistently.
    • Biometric prompts now use the simpler authentication path for verification, helping avoid unexpected validation issues during sign-in.

`verifyIdentity()` (with mode="verify") is for identity confirmation and doesn't perform any keystore/crypto operations, but the default configuration sets `requireCryptoObject` to `true`, which causes AuthActivity to create a CryptoObject and pass it to `BiometricPrompt.authenticate()`.

This triggers two bugs:
1. When no `allowedBiometryTypes` are specified, the default config sets `promptAuthenticators` to `BIOMETRIC_STRONG | BIOMETRIC_WEAK` with a `CryptoObject` - Android's `BiometricPrompt` requires `BIOMETRIC_STRONG` only when a `CryptoObject` is present, so this throws `IllegalArgumentException` on every device
regardless of hardware.
2. Even if the caller works around the first bug by passing `allowedBiometryTypes=[FINGERPRINT]` to force `BIOMETRIC_STRONG` only, the `onAuthenticationSucceeded` callback runs `validateCryptoObject()` which can fail with "Biometric security check failed" despite successful authentication.

This commit adds `"verify".equals(mode)` guards in AuthActivity to:
 - Skip `CryptoObject` creation in the authenticate path
 - Skip `CryptoObject` validation in the success callback

Secure credential modes are unaffected and continue to use the crypto path as before.
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8a7839ba-c877-417e-86d6-12f764b274a8

📥 Commits

Reviewing files that changed from the base of the PR and between 3996383 and 370e5ab.

📒 Files selected for processing (1)
  • android/src/main/java/ee/forgr/biometric/AuthActivity.java
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Cap-go/capacitor-updater (manual)

📝 Walkthrough

Walkthrough

Modifies AuthActivity.java's biometric authentication flow in "verify" mode: on successful authentication, "verify" mode now finishes the activity immediately, and the authenticate() call now skips CryptoObject when mode is "verify".

Changes

Verify Mode Handling

Layer / File(s) Summary
Verify mode success and prompt flow
android/src/main/java/ee/forgr/biometric/AuthActivity.java
Adds explicit "verify" branch in onAuthenticationSucceeded that finishes the activity, and updates the authenticate() call condition to skip CryptoObject when mode is "verify" or crypto object isn't required.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: bypassing the crypto-required path for verifyIdentity to avoid crashes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Beta npm build

This PR comes from a fork, so beta publish is disabled for security.

If you need a beta package, move the branch into this repository first.

@AlexBurrowsTBA
AlexBurrowsTBA marked this pull request as ready for review July 8, 2026 13:19
@riderx

riderx commented Jul 9, 2026

Copy link
Copy Markdown
Member

Thanks @AlexBurrowsTBA — recreated this fix in-repo as #103 so we can run Cap-go CI / beta publish.

@riderx

riderx commented Jul 9, 2026

Copy link
Copy Markdown
Member

Closing in favor of in-repo PR #103 (same fix, Cap-go CI green).

@riderx

riderx commented Jul 9, 2026

Copy link
Copy Markdown
Member

Superseded by #103

@riderx riderx closed this Jul 9, 2026
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.

2 participants