Fix GPG nonce UUID validation using incorrect operand#592
Open
flightlesstux wants to merge 1 commit intopassbolt:masterfrom
Open
Fix GPG nonce UUID validation using incorrect operand#592flightlesstux wants to merge 1 commit intopassbolt:masterfrom
flightlesstux wants to merge 1 commit intopassbolt:masterfrom
Conversation
The _checkNonce() method compared $version (the protocol string 'gpgauthv1.3.0') against the return value of Validation::uuid(), which returns a boolean. This worked accidentally via PHP loose type coercion but is semantically wrong: any future change to the return type of Validation::uuid() would silently disable UUID validation entirely. Replace the loose comparison against $version with a direct boolean check on Validation::uuid($uuid).
Member
|
@flightlesstux Looks good. Good catch. |
Author
Thank you! |
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.
Problem
In
GpgAuthenticator::_checkNonce(), the UUID validation check compares the wrong operand:Validation::uuid()returns a boolean (true/false), not the UUID string. The variable being compared is$version— the protocol string'gpgauthv1.3.0'— which has nothing to do with UUID validation.This works today only because PHP loose type coercion happens to produce the correct boolean outcome:
Validation::uuid()returnstrue→'gpgauthv1.3.0' != true→false→ no error ✓Validation::uuid()returnsfalse→'gpgauthv1.3.0' != false→true→ error triggered ✓However, this is a fragile coincidence. If
Validation::uuid()ever returns a non-boolean (e.g., the validated string itself), the check would silently stop rejecting invalid UUIDs in the GPG authentication flow.Fix
Replace the accidental loose comparison with a direct boolean check on the validation result:
Impact