CVE-2022-23510: @cubejs backend/api gateway @cubejs-backend/api-gateway Row Level Security Bypass Vulnerability

HIGH
Advisory Identifier: GHSA-6jqm-3c9g-pch7
CVSS 7.7
CWE-89
Published
Advisory Summary

CVE-2022-23510 is a HIGH (CVSS 7.7) @cubejs-backend/api-gateway row level security bypass vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting @cubejs backend/api gateway libraries in the npm ecosystem. The issue involves @cubejs-backend/api-gateway row level security bypass. Remediation is available by upgrading affected packages to version 0.31.24.

CVE-2022-23510 at a Glance

CVE Identifier CVE-2022-23510
GHSA Identifier GHSA-6jqm-3c9g-pch7
Severity HIGH
CVSS v3.1 Base Score 7.7
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product @cubejs backend/api gateway
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.7

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

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
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-2022-23510

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

@cubejs-backend/api-gateway fixed: 0.31.24
npm install @cubejs-backend/api-gateway@0.31.24
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 @cubejs-backend/api-gateway

How to Check if You Are Affected

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

npm ls @cubejs-backend/api-gateway

Analyze the terminal output to locate any version of @cubejs backend/api gateway in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.31.24), your application is affected.

Note: The npm ls @cubejs-backend/api-gateway 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-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In @cubejs backend/api gateway, 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

### Impact All authenticated Cube clients could bypass row-level security and run arbitrary SQL via the newly introduced /v1/sql-runner endpoint. ### Patches The change has been reverted in 0.31.24 ### Workarounds Upgrade to >=0.31.24 or downgrade to <=0.31.22 ### Post mortem As part of implementing the Cube Cloud SQL runner functionality, we’ve added a new endpoint to the Cube Core so that we could add arbitrary queries directly to the queue, bypassing the modeling layer. The endpoint was added in this commit: https://github.com/cube-js/cube.js/commit/f1e25bb50323c0b99f3891d349467e7b637baeea It went through the code review; however, it slipped everyone’s attention that this endpoint completely bypasses any row-level security logic implemented in the modeling layer. Now anyone with a valid Cube JWT token could fetch any data, even if they were not allowed to do so by their security context. The issue was noticed by the Core team on Dec 12 and immediately reverted. The just-released 0.31.23 version of the Cube has been pulled out of all the registries, and a CVE was published on Github. Another change (https://github.com/cube-js/cube.js/commit/2c5db32f2ded074ebe5e83668eee8c024101240b) was also rolled back along with the SQL runner endpoint. It didn't pose a significant security threat, but it increased the attacker’s ability to enumerate cube schema, and it should be revisited. The 0.31.24 was released to replace the revoked version with a change completely reverted. All customers are urged to upgrade to the newest Cube version.

CVE-2022-23510 Affected @cubejs backend/api gateway Versions

1 component(s)
Fixed Versions:
0.31.24
Product / Package Ecosystem Affected Versions Fixed Version
@cubejs-backend/api-gateway
npm
≥ 0.31.23
< 0.31.24
All 1 versions
0.31.23
0.31.24

References

Frequently Asked Questions

What is CVE-2022-23510?
CVE-2022-23510 is a security vulnerability in @cubejs backend/api gateway involving @cubejs-backend/api-gateway row level security bypass under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which @cubejs backend/api gateway versions are affected?
Affected versions include releases prior to 0.31.24 across affected packages: @cubejs-backend/api-gateway.
What version fixes CVE-2022-23510?
Upgrading to 0.31.24 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @cubejs-backend/api-gateway affected?
Yes, @cubejs-backend/api-gateway is affected in releases prior to 0.31.24. Upgrade your dependency to 0.31.24 or later.
What is the CVSS score of CVE-2022-23510?
CVE-2022-23510 has a CVSS v3.1 base score of 7.7 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2022-23510?
CVE-2022-23510 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check npm dependencies for CVE-2022-23510?
Run the dependency tree command: 'npm ls @cubejs-backend/api-gateway'. 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-6jqm-3c9g-pch7",
  "modified" : "2022-12-12T21:28:35Z",
  "published" : "2022-12-12T21:28:35Z",
  "aliases" : [ "CVE-2022-23510" ],
  "summary" : "@cubejs-backend/api-gateway row level security bypass",
  "details" : "### Impact\nAll authenticated Cube clients could bypass row-level security and run arbitrary SQL via the newly introduced /v1/sql-runner endpoint.\n\n### Patches\nThe change has been reverted in 0.31.24\n\n### Workarounds\nUpgrade to >=0.31.24 or downgrade to <=0.31.22\n\n### Post mortem\nAs part of implementing the Cube Cloud SQL runner functionality, we’ve added a new endpoint to the Cube Core so that we could add arbitrary queries directly to the queue, bypassing the modeling layer.\n\nThe endpoint was added in this commit: https://github.com/cube-js/cube.js/commit/f1e25bb50323c0b99f3891d349467e7b637baeea\n\nIt went through the code review; however, it slipped everyone’s attention that this endpoint completely bypasses any row-level security logic implemented in the modeling layer. Now anyone with a valid Cube JWT token could fetch any data, even if they were not allowed to do so by their security context.\n\nThe issue was noticed by the Core team on Dec 12 and immediately reverted.\n\nThe just-released 0.31.23 version of the Cube has been pulled out of all the registries, and a CVE was published on Github.\nAnother change (https://github.com/cube-js/cube.js/commit/2c5db32f2ded074ebe5e83668eee8c024101240b) was also rolled back along with the SQL runner endpoint. It didn't pose a significant security threat, but it increased the attacker’s ability to enumerate cube schema, and it should be revisited.\n\nThe 0.31.24 was released to replace the revoked version with a change completely reverted. All customers are urged to upgrade to the newest Cube version.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@cubejs-backend/api-gateway"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.31.23"
      }, {
        "fixed" : "0.31.24"
      } ]
    } ],
    "versions" : [ "0.31.23" ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/cube-js/cube.js/security/advisories/GHSA-6jqm-3c9g-pch7"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-23510"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/cube-js/cube.js/commit/3c614674fed6ca17df08bbba8c835ef110167570"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/cube-js/cube.js/commit/f1140de508e359970ac82b50bae1c4bf152f6041"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/cube-js/cube.js"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-12-12T21:28:35Z",
    "nvd_published_at" : "2022-12-09T23:15:00Z"
  }
}