<?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>Plugin-Collection-Sql — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/plugin-collection-sql/</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>Wed, 24 Jan 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/plugin-collection-sql/feed.xml" rel="self" type="application/rss+xml"/><item><title>NocoBase SQL Injection via Missing Validation on Update Endpoint</title><link>https://feed.craftedsignal.io/briefs/2024-01-24-nocobase-sql-injection/</link><pubDate>Wed, 24 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-24-nocobase-sql-injection/</guid><description>A SQL injection vulnerability exists in nocobase plugin-collection-sql versions 2.0.32 and earlier due to missing validation on the sqlCollection:update endpoint, allowing attackers with collection management permissions to execute arbitrary SQL queries and exfiltrate data.</description><content:encoded><![CDATA[<p>The <code>@nocobase/plugin-collection-sql</code> plugin for NocoBase is vulnerable to SQL injection. Specifically, the <code>checkSQL()</code> validation function, responsible for preventing dangerous SQL keywords, is applied to the <code>collections:create</code> and <code>sqlCollection:execute</code> endpoints, but is absent from the <code>sqlCollection:update</code> endpoint. This oversight allows an attacker with collection management permissions (specifically, the <code>pm.data-source-manager.collection-sql</code> snippet) to inject arbitrary SQL code. The attack involves creating a SQL collection with benign SQL, updating it with malicious SQL bypassing validation, and subsequently querying the collection to execute the injected SQL. This vulnerability, confirmed to affect versions 2.0.32 and earlier, can lead to unauthorized data access, privilege escalation, and potentially remote code execution on the database server.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>The attacker gains collection management permissions, possibly through compromised credentials or exploiting another vulnerability.</li>
<li>The attacker crafts a request to the <code>collections:create</code> endpoint to create a new SQL collection with a benign SQL query, such as <code>&quot;SELECT 1 as id&quot;</code>.</li>
<li>The NocoBase server processes the request, and the <code>checkSQL()</code> function validates the SQL query and allows the collection creation.</li>
<li>The attacker crafts a malicious request to the <code>sqlCollection:update</code> endpoint, targeting the newly created collection. The request contains a SQL payload designed to extract sensitive data, such as <code>&quot;SELECT * FROM users&quot;</code>, or execute malicious functions.</li>
<li>The NocoBase server processes the update request, but crucially, the <code>checkSQL()</code> function is not called, allowing the malicious SQL payload to be saved to the collection configuration.</li>
<li>The attacker crafts a request to the <code>&lt;collection_name&gt;:list</code> endpoint to query the updated collection.</li>
<li>The NocoBase server executes the stored malicious SQL query against the database.</li>
<li>The database returns the results of the malicious query, potentially containing sensitive data (e.g., user credentials), which is then returned to the attacker.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of this SQL injection vulnerability can have severe consequences. Attackers can exfiltrate sensitive data, including user credentials and password hashes, leading to confidentiality breaches. Furthermore, by using database-specific functions such as <code>pg_read_file</code> or <code>LOAD_FILE</code>, attackers can potentially read arbitrary files from the database server&rsquo;s filesystem. The vulnerability can also be exploited for privilege escalation, allowing attackers to gain unauthorized access to other databases or execute arbitrary code on the database server. While the number of victims is unknown, any NocoBase instance running a vulnerable version of the <code>@nocobase/plugin-collection-sql</code> plugin is susceptible to this attack.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Apply the fix suggested in the advisory by adding <code>checkSQL()</code> to the <code>update</code> action within the <code>@nocobase/plugin-collection-sql</code> plugin.</li>
<li>Deploy the Sigma rule <code>Detect NocoBase SQL Injection via Update Endpoint</code> to detect attempts to exploit this vulnerability by monitoring HTTP requests to the <code>sqlCollection:update</code> endpoint.</li>
<li>Upgrade to a patched version of <code>@nocobase/plugin-collection-sql</code> that includes the necessary validation on the <code>update</code> action, mitigating the risk of SQL injection.</li>
<li>Implement the more comprehensive defense measures recommended in the advisory, such as centralizing validation and strengthening the blocklist of dangerous SQL keywords to prevent future vulnerabilities.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>sql-injection</category><category>web-application</category><category>nocobase</category></item></channel></rss>