<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Database-Exfiltration — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/tags/database-exfiltration/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata — refreshed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Sat, 26 Oct 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/tags/database-exfiltration/feed.xml" rel="self" type="application/rss+xml"/><item><title>Dgraph Pre-Auth DQL Injection Vulnerability</title><link>https://feed.craftedsignal.io/briefs/2024-10-dgraph-dql-injection/</link><pubDate>Sat, 26 Oct 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-10-dgraph-dql-injection/</guid><description>A pre-authentication DQL injection vulnerability in Dgraph's `/mutate` endpoint, when ACL is disabled, allows attackers to exfiltrate the entire database by crafting a malicious `cond` field in an upsert mutation.</description><content:encoded><![CDATA[<p>A critical vulnerability exists in Dgraph, a graph database, allowing unauthenticated attackers to perform full database exfiltration. This flaw resides within the <code>/mutate</code> endpoint, specifically when Access Control Lists (ACL) are disabled, which is the default configuration. By injecting malicious DQL queries via a crafted <code>cond</code> field in an upsert mutation, attackers can bypass authorization checks and extract sensitive data, including user credentials and secrets. The vulnerability stems from the lack of proper sanitization of the <code>cond</code> field, leading to direct concatenation into the DQL query string. This vulnerability was found in v25.3.0, but may exist in other versions as well.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>The attacker sends an HTTP POST request to the <code>/mutate?commitNow=true</code> endpoint without any authentication headers (e.g., <code>X-Dgraph-AccessToken</code>, <code>X-Dgraph-AuthToken</code>).</li>
<li>The <code>mutationHandler</code> in <code>http.go</code> extracts the request body and processes the <code>mutations</code> array, including the <code>cond</code> field, using <code>strconv.Unquote</code>.</li>
<li>The request proceeds to <code>edgraph.Server.QueryNoGrpc</code>, where the <code>Cond</code> value is copied verbatim to <code>dql.Mutation.Cond</code> in <code>server.go</code>.</li>
<li>The <code>buildUpsertQuery</code> function in <code>server.go</code> performs a simple string replacement (<code>@if</code> to <code>@filter</code>) but otherwise concatenates the unsanitized <code>Cond</code> value into the DQL query.</li>
<li>The <code>dql.ParseWithNeedVars</code> parser processes the constructed DQL string, accepting the injected query blocks as valid DQL.</li>
<li>The <code>authorizeQuery</code> function in <code>access.go</code> returns <code>nil</code> immediately because ACL is disabled (<code>AclSecretKey == nil</code>), bypassing authorization checks.</li>
<li>The injected query block executes, traversing and extracting data from the database.</li>
<li>The response, containing the exfiltrated data, is returned to the attacker via <code>http.go</code>, effectively granting unauthorized access to sensitive information.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of this vulnerability results in complete database exfiltration. Attackers can retrieve all nodes, predicates, and values within the Dgraph database, including sensitive data such as user credentials, API keys, and Personally Identifiable Information (PII). Given the default configuration of Dgraph lacking ACL enabled, this poses a significant risk to organizations relying on Dgraph for data storage. The injection can also manipulate upsert conditions, bypassing uniqueness constraints and conditional mutation logic.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Enable ACL on all Dgraph instances and configure appropriate access controls to mitigate unauthorized data access.</li>
<li>Implement the Sigma rule <code>Detect Dgraph DQL Injection in Mutation Endpoint</code> to identify potentially malicious requests to the <code>/mutate</code> endpoint.</li>
<li>Sanitize and validate user-supplied input, especially the <code>cond</code> field in mutation requests, to prevent DQL injection attacks.</li>
<li>Monitor network traffic to detect suspicious POST requests to the <code>/mutate</code> endpoint with unusual or unexpected <code>cond</code> values.</li>
<li>Review and restrict network access to the Dgraph instance, limiting access only to authorized clients and networks.</li>
</ul>
]]></content:encoded><category domain="severity">critical</category><category domain="type">advisory</category><category>dgraph</category><category>dql-injection</category><category>injection</category><category>database-exfiltration</category></item></channel></rss>