Repository navigation
Fixes #35840: only admins can change a user's domains - #35845
Merged
Merged
Conversation
Code Review ✅ Approved🔴 High risk · Making domain assignments admin-only across PATCH, PUT, and POST changes authorization; a bypass could let users self-grant access to domain assets. Restricts user domain changes to admins by adding domains to the existing admin-only checks in VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
mohityadav766
approved these changes
Oct 21, 2026
manerow
added this pull request to the merge queue
Oct 21, 2026
manerow
added a commit
that referenced
this pull request
Oct 21, 2026
5 tasks done
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
A rule such as "allow
EditAllwhenhasDomain()" lets users edit assets in their domains. But any user could add a domain to their own profile, withPATCH /v1/users/{id}orPUT /v1/users, andhasDomain()then treated them as a member. They could edit that domain's assets and move them into their own domain, getting around the fix for #33420 (PR #33471). ThroughPUTthis also worked for users withDomainOnlyAccessRole, and a non-admin allowed to edit other users could give them any domain.Why it happened
Every user owns their own profile, so the default owner rule lets them change any field of it.
UserResourcealready keeps the fields that grant access out of that rule: roles,isAdmin,isBotand closed teams need an admin. Domains grant access too, throughhasDomain(), but were not on that list.What this PR changes
Domains join those admin-only checks in
UserResource, with no new mechanism:/domainsneeds an admin, as/rolesdoes.The rule is recorded in
docs/decisions.What users will notice
How it was tested
UserResourceITcover each path above, another user's domains, and two controls (a self-edit keeps the user's domain; an admin sets domains). Onmainthe four that change behavior fail; the whole-document one and the two controls pass, since a whole-document patch was already admin-only. All seven pass here, on Postgres and MySQL.main.mainand from this branch: every way above of adding a domain returned 200 onmainand let the user edit the new domain's tables; here each returns 403 and stores nothing. Admin edits and other self-edits behave the same on both.Not in this PR
Fixes #35840


Confidence Score: 5/5
The PR appears safe to merge, with the previous test gap addressed.Summary
The PR restricts assigning domains to users to admins and records that decision.
Reviews (2) · Last reviewed commit: "Test that a team's domain cannot be clai..." · Reviewed by Greptile