fix: validate identity_key against member's keyring, not org owner's#871
Merged
rohan-chaturvedi merged 1 commit intomainfrom May 4, 2026
Merged
Conversation
UpdateUserWrappedSecrets, RecoverAccountKeyring, and ChangeAccountPassword all compared the supplied identity_key to org.identity_key — the org owner's. Phase users each derive their own keyring from their own mnemonic, so this rejected every legitimate call from a non-owner member trying to rewrap their keyring (SSO recovery, password recovery, password change). Compare against org_member.identity_key instead. Update the docstrings and tests to reflect the corrected semantics.
nimish-ks
approved these changes
May 4, 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.
Summary
Three mutations introduced by the auth refactor (#849) —
UpdateUserWrappedSecretsMutation,RecoverAccountKeyringMutation, andChangeAccountPasswordMutation— compared the user-suppliedidentity_keyagainstorg.identity_key. That column is the org owner's identity_key, set once at org creation. Every Phase user derives their own keyring from their own mnemonic, so for any non-owner member the suppliedidentity_keywon't matchorg.identity_keyand the mutation rejects the call as "Invalid recovery proof."This breaks production for non-owner members:
UpdateUserWrappedSecretsMutation)RecoverAccountKeyringMutation)ChangeAccountPasswordMutation)The intent of the check is "the new identity_key must match the one this member registered with", which is
org_member.identity_key. Owner-only orgs happen to work because the owner'sorg_member.identity_key == org.identity_key.Changes
backend/backend/graphene/mutations/organisation.py: in all three mutations, move theOrganisationMember.objects.get(...)lookup ahead of the validation and compare againstorg_member.identity_key. Update docstrings.backend/tests/test_auth_password.py: tests had been mockingorg.identity_keyto drive the (incorrect) check. Switch the mocks toorg_member.identity_keyand update the assert-not-called assertions affected by the lookup-order change.Test plan
pytest backend/tests/test_auth_password.pypasses (54/54)