GitHub Security Advisory: GHSA-mrxx-39g5-ph77
Package: github.com/dgraph-io/dgraph (GO)
Severity: CRITICAL (CVSS 9.1)
CWE: CWE-943: Improper Neutralization of Special Elements in Data Query Logic
Vulnerable versions: <= 1.2.8
Patched in: unpatched

Summary: Dgraph: Pre-Auth Full Database Exfiltration via DQL Injection in Upsert Condition Field

Details:
## 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 In