fix: validate registration invite before password validation#7711
fix: validate registration invite before password validation#771110done wants to merge 2 commits into
Conversation
|
@10done is attempting to deploy a commit to the Flagsmith Team on Vercel. A member of the Team first needs to authorize it. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7711 +/- ##
==========================================
- Coverage 98.52% 98.37% -0.16%
==========================================
Files 1444 1444
Lines 54971 54968 -3
==========================================
- Hits 54161 54074 -87
- Misses 810 894 +84 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request moves the registration invite validation to the beginning of the validate method in api/custom_auth/serializers.py. However, this change exposes a user enumeration vulnerability because Django Rest Framework's field-level validators run before the serializer's validate method. This allows uninvited users to determine if an email is registered based on whether they receive a 400 (email exists) or a 403 (no invite) response. It is recommended to remove the default UniqueValidator and perform the uniqueness check manually after the invite validation.
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Fixes #7695
Moved
_validate_registration_invite()to execute beforesuper().validate()in
CustomUserCreateSerializer.validate().Uninvited users should be rejected immediately with 403 before the server
performs any further validation. The previous ordering also had a minor
security implication — it leaked password rule feedback to users who were
not authorised to register at all.
How did you test this code?
test_register__without_invite_when_disabled__returns_forbidden— passesdeterministically
custom_authunit + integration test suite — all passing