Validate remote-verify QR before persisting account state#331
Merged
thestinger merged 1 commit intoGrapheneOS:mainfrom Apr 27, 2026
Merged
Validate remote-verify QR before persisting account state#331thestinger merged 1 commit intoGrapheneOS:mainfrom
thestinger merged 1 commit intoGrapheneOS:mainfrom
Conversation
The EnableRemoteVerify QR handler called Long.parseLong(values[1]) outside the try/catch that guarded Integer.parseInt(values[3]), so a QR with a non-numeric user id crashed the activity instead of showing the "invalid account QR code" snackbar. It also wrote KEY_USER_ID and KEY_SUBSCRIBE_KEY to SharedPreferences *before* scheduling the job. If parsing the interval threw, the prefs were already committed: RemoteVerifyJob.isEnabled() then returned true (hiding the "Enable remote verification" button) while no job was ever scheduled, leaving the user with no in-app way to recover short of "Disable remote verification". Parse both numeric fields inside a single try/catch and only commit preferences and schedule the job once every field has been validated.
RankoR
approved these changes
Apr 27, 2026
quh4gko8
approved these changes
Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hardens the
Stage.EnableRemoteVerifybranch of the QR scan result handler inAttestationActivityso that a malformed account QR can no longer crash the app or leave remote verification in a half-enabled state.Problem
In AttestationActivity.java the handler did:
Two issues:
Long.parseLong(values[1])is outside thetry. Any QR of the formattestation.app <non-numeric> …triggers an uncaughtNumberFormatExceptionin theActivityResultLauncherlambda and crashes the activity. Only the interval field was guarded.SharedPreferencesbefore the interval is parsed and the job is scheduled. If the interval is malformed, the prefs are already persisted, so:RemoteVerifyJob.isEnabled()returnstrue, hiding the "Enable remote verification" button inonResume().RemoteVerifyJob.isScheduled()returnsfalse— no job runs.Fix
Parse both
userIdandintervalinside a singletry/catch (NumberFormatException). Only after both parse successfully are preferences committed and the job scheduled. Behavior on a valid QR is unchanged.