github.com/dgraph-io/dgraph/v25
Affected
- introduced
0, fixed25.3.3(semver)
Fixed versions
25.3.3
Fix
- Fixed version
25.3.3go get github.com/dgraph-io/dgraph/[email protected]
Advisory
Also known as: CVE-2026-41327, GO-2026-5516
Dgraph: Pre-Auth Full Database Exfiltration via DQL Injection in Upsert Condition Field
1. Executive Summary
A vulnerability has been found in Dgraph that gives an unauthenticated attacker full read access to every piece of data in the database. This affects Dgraph's default configuration where ACL is not enabled.
The attack is a single HTTP POST to /mutate?commitNow=true containing a crafted cond field in an upsert mutation. The cond value is concatenated directly into a DQL query string via strings.Builder.WriteString after only a cosmetic strings.Replace transformation. No escaping, parameterization, or structural validation is applied. An attacker injects an additional DQL query block into the cond string, which the DQL parser accepts as a syntactically valid named query block. The injected query executes server-side and its results are returned in the HTTP response.
There are no credentials involved. When ACL is disabled (the default), the /mutate endpoint requires no authentication. The authorizeQuery and authorizeMutation functions both return nil immediately when AclSecretKey is not configured. Even when ACL is enabled, a user with mutation-only permission can inject read queries that bypass per-predicate ACL authorization, because the injected query block is not subject to the normal authorization flow.
POC clip:
https://github.com/user-attachments/assets/edf43615-b0d5-46cd-abd9-2cb9423790d2
2. CVSS Score
CVSS 3.1: 9.1 (Critical)
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
| Metric | Value | Rationale |
| ------------------- | --------- | ---------------------------------------------------------------------------------- |
| Attack Vector | Network | HTTP POST to port 8080 |
| Attack Complexity | Low | Single request, no special conditions beyond default config |
| Privileges Required | None | No authentication when ACL is disabled (default) |
| User Interaction | None | Fully automated |
| Scope | Unchanged | Stays within the Dgraph data layer |
| Confidentiality | High | Full database exfiltration: all nodes, all predicates, all values |
| Integrity | High | The injection can also be used to manipulate upsert conditions, bypassing uniqueness constraints and conditional mutation logic |
| Availability | None | No denial of service |
3. Vulnerability Summary
| Field | Value |
| --------- | ------------------------------------------------------------------------------------------ |
| Title | Pre-Auth DQL Injection via Unsanitized Cond Field in Upsert Mutations |
| Type | Injection |
| CWE | CWE-943 (Improper Neutralization of Special Elements in Data Query Logic) |
| CVSS | 9.8 |
4. Target Information
| Field | Value |
| -------------------- | ---------------------------------------------------------------------------------------------- |
| Project | Dgraph |
| Repository | https://github.com/dgraph-io/dgraph |
| Tested version | v25.3.0 |
| HTTP handler | dgraph/cmd/alpha/http.go line 345 (mutationHandler) |
| Cond extraction | dgraph/cmd/alpha/http.go line 413 (strconv.Unquote) |
| Cond passthrough | edgraph/server.go line 2011 (ParseMutationObject, copies mu.Cond verbatim) |
| Injection sink | edgraph/server.go line 750 (upsertQB.WriteString(cond)) |
| Only transformation | edgraph/server.go line 730 (strings.Replace(gmu.Cond, "@if", "@filter", 1)) |
| Auth bypass (query) | edgraph/access.go line 958 (authorizeQuery returns nil when AclSecretKey == nil) |
| Auth bypass (mutate) | edgraph/access.go line 788 (authorizeMutation returns nil when AclSecretKey == nil) |
| Response exfiltration| dgraph/cmd/alpha/http.go line 498 (mp["queries"] = json.RawMessage(resp.Json)) |
| HTTP port | 8080 (default) |
| Prerequisite | None. Default configuration. ACL disabled is the default. |
5. Test Environment
| Component | Version / Details |
| -------------------- | --------------------------------------------------------------- |
| Host OS | macOS (darwin 25.3.0) |
| Dgraph | v25.3.0 via dgraph/dgraph:latest Docker image |
| Docker Compose | 1 Zero + 1 Alpha, default config, --security whitelist=0.0.0.0/0 |
| Python | 3.x with requests |
| Network | localhost (127.0.0.1) |
6. Vulnerability Detail
Location: edgraph/server.go lines 714-757 (buildUpsertQuery)
CWE: CWE-943 (Improper Neutralization of Special Elements in Data Query Logic)
The /mutate endpoint accepts JSON bodies containing a mutations array. Each mutation can include a cond field, intended for conditional upserts with syntax like @if(eq(name, "Alice")). This condition is supposed to be spliced into the DQL query as a @filter clause on a dummy var(func: uid(0)) block.
The handler at http.go:413 extracts the cond value via strconv.Unquote, which interprets \n as actual newlines but performs no sanitization:
mu.Cond, err = strconv.Unquote(string(condText.bs))
ParseMutationObject at server.go:2011 copies it verbatim:
res := &dql.Mutation{Cond: mu.Cond}
buildUpsertQuery at server.go:730 applies one cosmetic replacement then concatenates the raw string directly into the DQL query:
cond := strings.Replace(gmu.Cond, "@if", "@filter", 1)
// ...
x.Check2(upsertQB.WriteString(cond))
There is no escaping, no parameterization, no structural validation, and no character allowlist between the HTTP input and the query string concatenation.
Critical Basis: The source's own band: CRITICAL
0, fixed 25.3.3 (semver)25.3.3
25.3.3go get github.com/dgraph-io/dgraph/[email protected]0, last affected 24.1.8 (semver)None listed
No fixed version is listed.
0, last affected 1.2.8 (semver)None listed
No fixed version is listed.
Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0