fix(graphql): enforce update auth on existing nodes linked via @hasInverse#9761
Open
kike-loco wants to merge 1 commit into
Open
fix(graphql): enforce update auth on existing nodes linked via @hasInverse#9761kike-loco wants to merge 1 commit into
kike-loco wants to merge 1 commit into
Conversation
…verse Nested add mutations could mutate protected parent nodes through inverse edges without running the parent's update @auth rules. Track affected existing UIDs during mutation rewrite and authorize them after add-node checks, closing the false-accept bypass for hasInverse and deep nested inserts. Co-authored-by: Cursor <cursoragent@cursor.com>
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
Fixes a false accept security gap in GraphQL add mutations: when a nested insert links to an existing parent via
@hasInverse, Dgraph mutates the parent's inverse predicate but previously only ran@auth addchecks on newly allocated UIDs. Protected parents were never validated, allowing unauthorized users to modify admin-only nodes indirectly.Example bypass (now blocked):
…when
ProtectedFoorequires admin for both add and update.asIDReference()adds an inverse link to an existing UID (mutation_rewriter.go)authorizeNewNodes(), runauthorizeAffectedNodes()using update rules on those nodes (mutation.go)Related discussion: https://discuss.dgraph.io/t/bug-auth-rules-of-parent-not-respected-when-child-with-hasinverse-is-added/12955
Test plan
go test ./graphql/resolve -run 'TestAddChildRecordsAffectedProtectedParent|TestNestedAddRecordsDeepNewNodes' -count=1go test ./graphql/resolve -run TestAuthQueryRewriting/Add_Mutation -count=1go test -tags=integration -run TestNestedAdd ./graphql/e2e/auth/...(requires Docker cluster with patched binary)Made with Cursor