The analysis of the provided vulnerability description and the associated patch commit 55e3b79817e87512297695f7dccae86130d0c81e confirms the presence of multiple DQL injection vulnerabilities in Dgraph. The primary vulnerability, as detailed in the report, resides in the addQueryIfUnique function within edgraph/server.go. This function failed to sanitize the language tag (pred.Lang) extracted from a user-controlled JSON key before incorporating it into a DQL query via fmt.Sprintf. This allowed an unauthenticated attacker to inject arbitrary DQL and exfiltrate the entire database.
The patch addresses this by introducing a new function, validateLangTag, which uses a regular expression to ensure the language tag conforms to the BCP 47 standard, effectively blocking the injection.
A secondary injection vector was identified and patched in the buildUpsertQuery function in the same file. This function was vulnerable to injection via the cond field in mutations. The fix involves a new validateCondValue function that strictly validates the structure of the conditional expression, preventing the injection of additional query blocks. The commit also includes fixes for potential injection through val() references in ObjectIds, also within addQueryIfUnique. The presence of new test files and functions like TestDQLInjectionViaCondField and TestValidateLangTag further corroborates these findings.