/

CVE-2026-41641

Severity:

HIGH RISK

(7.2)

SQL Injection in NocoBase SQL Collections

CVE-2026-41641

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89, CWE-284

Impact:

Unauthorized SQL Execution and Data Exfiltration

Severity:

HIGH RISK

(7.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

NocoBase versions prior to 2.0.39 contain a SQL injection pathway where dangerous SQL keyword validation is skipped on the sqlCollection:update endpoint.

An attacker with collection management permissions can create a benign SQL collection, then update it with arbitrary SQL that bypasses validation and execute it through normal queries, potentially exfiltrating sensitive data or performing other unauthorized database operations.

Affected context

This vulnerability affects NocoBase deployments that expose SQL collections to users with collection management capabilities.

It specifically manifests when:

  • SQL collections can be created and updated via the API or admin UI
  • The sqlCollection:update endpoint is accessible to users who are not fully trusted with direct database access
  • Application logic relies on keyword-based checks (e.g., checkSQL()) to block dangerous SQL, rather than enforcing strict query construction patterns

In such environments, the missing validation on updates becomes a covert path for running arbitrary SQL through an otherwise controlled feature.

Exploit preconditions

  • Attack surface: NocoBase API/UI endpoints handling SQL collections, particularly sqlCollection:update.
  • Required access: Valid account with permissions to manage collections (create, update, and query SQL collections).
  • Trigger point: Updating an existing SQL collection with malicious SQL after its initial creation passed validation and then invoking queries against that collection.
  • Why exploitation is possible: The checkSQL() validation that filters known dangerous SQL constructs is applied to collections:create and sqlCollection:execute but omitted from sqlCollection:update, allowing malicious SQL to be introduced post-creation and executed through normal collection operations.

Why this happens

The core issue is inconsistent validation of SQL inputs across related endpoints, mapping to CWE-89: Improper Neutralization of Special Elements used in an SQL Command (SQL Injection) and CWE-284: Improper Access Control.

NocoBase relies on a checkSQL() function to block dangerous keywords for SQL collections, but:

  • The validation is correctly applied when a collection is created and when certain SQL executions occur.
  • The same protective logic is not enforced when updating the SQL definition of an existing collection.

This creates an authorization and validation gap: users with collection management rights can inject arbitrary SQL during an update operation, bypassing the intended safeguards and effectively gaining direct SQL execution capabilities via the application's abstraction layer.

Potential impact

  • Unauthorized reading of sensitive data from arbitrary tables the database user can access
  • Modification or deletion of data, including business-critical records
  • Escalation of impact by abusing database functions, stored procedures, or linked databases
  • Circumvention of application-level access controls by querying data outside of allowed scopes
  • Potential tampering with application configuration or audit logs stored in the database

General mitigation guidance

Effective mitigation focuses on eliminating ad hoc SQL injection channels and aligning authorization with data access capabilities:

  • Ensure that all endpoints that accept SQL or SQL-like input share a common, centralized validation path so changes to validation cannot be bypassed on specific operations.
  • Avoid relying solely on keyword-based blocking; consider secure query construction strategies such as parameterization or restricted, template-based query building where raw SQL is not directly editable.
  • Restrict SQL collection management permissions to tightly controlled, trusted roles; treat them as equivalent to granting direct database access.
  • Introduce schema-level or view-based access controls that constrain what the application's database role can read or modify, limiting blast radius if arbitrary SQL is injected.
  • Apply defense-in-depth with least-privilege database accounts, minimizing the capabilities of the role used by NocoBase to execute SQL collections.

How teams detect issues like this

Detection can combine code-level and behavioral monitoring approaches:

  • Use static analysis and code review checklists to verify that input validation and SQL filtering logic is consistently applied across all create, update, and execute endpoints for SQL collections.
  • Search the codebase for direct SQL execution paths (e.g., raw query calls) and confirm that they pass through centralized validation or query builders, without special-case exceptions.
  • Implement logging and monitoring for SQL collections that:
  • Track changes to collection definitions, especially updates that significantly alter or expand SQL content.
  • Flag the use of high-risk SQL functions, cross-database links, or broad data access patterns in collection definitions.
  • Employ automated security testing or API fuzzing tools that attempt to introduce risky SQL constructs during both creation and update operations, verifying that responses and stored definitions are properly sanitized.

Sources

SourceLink
github.comgithub.com/nocobase/nocobase/commit/851aee543efa894142e0f7be03eb55d9cec06a91
github.comgithub.com/nocobase/nocobase/pull/9134
github.comgithub.com/nocobase/nocobase/releases/tag/v2.0.39
github.comgithub.com/nocobase/nocobase/security/advisories/GHSA-wrwh-c28m-9jjh

Frequently asked

questions

Yes, if the NocoBase instance is exposed over the network and an attacker can obtain an account with collection management permissions, they can exploit the issue via normal HTTP/API interactions.

The attacker must be able to create, update, and query SQL collections—typically a role with collection management rights. This is not a fully unauthenticated vulnerability, but it can be abused by a malicious or compromised privileged user.

Align all SQL-handling endpoints with a unified validation and execution model: route every create, update, and execute operation through the same hardened validation layer, and where possible, replace editable raw SQL with parameterized or pre-approved query templates.

When adding or modifying features that accept powerful inputs (like SQL), enforce a design rule that validation and authorization are centralized and reused rather than reimplemented per endpoint, and regularly audit permissioned "configuration" features as if they were direct access paths to the underlying data store.

Find out what's already
exploitable in your codebase.