The vulnerability is a DQL injection in Dgraph's GraphQL layer, specifically in the handling of the checkUserPassword query. The root cause is the unsafe construction of a DQL query using fmt.Sprintf in the passwordQuery function, located in graphql/resolve/query_rewriter.go. User-controlled input (the password) is directly embedded into the query string, allowing an attacker to inject arbitrary DQL by providing a password containing a double-quote character.
The patch addresses this by changing the query construction to use parameterized queries. Instead of interpolating the password directly, the new code uses a placeholder ($pwd0) in the DQL string and passes the password as a separate variable to the Dgraph query executor. This prevents the password from being interpreted as DQL code.
The analysis of the patch commit cee702c93f141eeb0c96a81f70830ec9e459efac confirms this. The changes in graphql/resolve/query_rewriter.go show the modification in passwordQuery to use a variable. The function signature of queryRewriter.Rewrite was updated to return these variables, and queryResolver.rewriteAndExecute in graphql/resolve/query.go was updated to pass these variables to the query executor. Therefore, passwordQuery is the primary vulnerable function, and queryRewriter.Rewrite and queryResolver.rewriteAndExecute are key functions in the vulnerable execution flow.