Vulnerabilities in pkg:npm/@hypequery/clickhouse

PACKAGE
Advisory Identifier: GHSA-6wcc-39rp-hh9p
Advisory Summary

CVE-2026-54658 is a CRITICAL (CVSS 9.8) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting @hypequery/clickhouse libraries in the npm ecosystem. The issue involves @hypequery/clickhouse has sql injection in parameter escaping that allows arbitrary sql execution. Remediation is available by upgrading affected packages to version 2.5.1.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/@hypequery/clickhouse

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/@hypequery/clickhouse. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-6wcc-39rp-hh9p CVE-2026-54658 CRITICAL @hypequery/clickhouse has SQL Injection in parameter escaping that allows arbitrary SQL execution

CVE-2026-54658 at a Glance

CVE Identifier CVE-2026-54658
GHSA Identifier GHSA-6wcc-39rp-hh9p
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product @hypequery/clickhouse
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.8

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

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

How to Fix CVE-2026-54658

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

@hypequery/clickhouse fixed: 2.5.1
npm install @hypequery/clickhouse@2.5.1
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 @hypequery/clickhouse

How to Check if You Are Affected

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

npm ls @hypequery/clickhouse

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

Note: The npm ls @hypequery/clickhouse 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 @hypequery/clickhouse, 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

A SQL injection vulnerability exists in the `escapeValue()` function used for parameter substitution. `escapeValue()` dispatches on the type of the parameter value, and two of its branches failed to escape safely. An attacker who can control a parameter value can terminate the enclosing string literal and have the rest of the value parsed as SQL. **Vector 1 - string parameters. Fixed in 2.0.2.** The string branch escaped `'` as `''` but left `\\` untouched. ClickHouse honours C-style backslash escapes as well as SQL-standard quote doubling, so a value ending in an odd number of backslashes escapes the closing quote and the next parameter lands outside the literal: ``` where('a', 'eq', 'x\\') -> WHERE a = 'x\\' AND b = ' OR 1=1 --' ``` **Vector 2 - object and array parameters. Fixed in 2.5.1, NOT in 2.0.2.** The final branch of the same function rendered non-scalar values as `` `'${JSON.stringify(value)}'` `` with no escaping at all. JSON has no reason to escape the apostrophe, so any nested string containing `'` terminates the literal: ``` where('meta', 'eq', { k: \"x' OR 1=1 -- \" }) -> WHERE meta = '{\"k\":\"x' OR 1=1 -- \"}' ``` The 2.0.2 patch changed only the string branch and did not address this. Vector 2 remained exploitable in **2.0.2, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.2.0, 2.3.0, 2.4.0 and 2.5.0** - every release this advisory previously reported as patched. **Who is impacted.** Any application on a version below 2.5.1 that passes user-controlled input as a query parameter. Both vectors are reachable through the documented public API: `.where(column, operator, value)`, the `in` operator, and `adapter.render()` / `rawQuery()`. **Schema type declarations do not mitigate vector 2.** `createQueryBuilder().table()` builds its state with an empty column map, so the filter validator has no declared type to check against and returns without validating. Even where a schema is supplied, only `String`, `Int32`, `Int64`, `Float64` and `Date` columns are type-checked - `Map`, `Array`, `Bool`, `UUID`, `DateTime`, `UInt*`, `Enum` and `Nullable` columns are not - and any column name containing a `.` skips validation entirely. ## Patches Upgrade to **2.5.1 or later**. Both vectors are closed there. - **Vector 1** - fixed in **2.0.2** by `2dc1df7bae` (the referenced `4dfa9d77` is the same change on the pull-request branch). Escapes backslashes before escaping single quotes. - **Vector 2** - fixed in **2.5.1** by `2879161a81`, which routes the serialised JSON back through `escapeValue()` so nested quotes are doubled. The same commit also rejects non-finite numbers and invalid `Date` values instead of emitting them into the query. For anyone auditing the history: the vector-2 fix is bundled inside `2879161a81`, whose commit message is *\"parenthesize logical groups in WHERE to preserve AND/OR precedence (#349)\"*. Commit `4a1d4e38aa` (#350), whose message *does* describe the escaping fix, changes only a `bigint` branch - the escaping fix is already present in its parent. ## Workarounds Upgrading is the only complete fix. For **vector 2** only, applications on 2.0.2–2.5.0 that cannot upgrade can serialise non-scalar parameters themselves and pass the resulting string. That routes the value through the string branch, which is correctly escaped from 2.0.2 onward: ```js .where('meta', 'eq', JSON.stringify(value)) // safe on >= 2.0.2 ``` There is no workaround for **vector 1** other than upgrading to 2.0.2 or later. Do not substitute application-level input validation or sanitisation for either fix. Correct escaping depends on the literal context the library constructs, so the library has to own it.

CVE-2026-54658 Affected @hypequery/clickhouse Versions

1 component(s)
Fixed Versions:
2.5.1
Product / Package Ecosystem Affected Versions Fixed Version
@hypequery/clickhouse
npm
< 2.5.1
2.5.1

References

Frequently Asked Questions

What is CVE-2026-54658?
CVE-2026-54658 is a security vulnerability in @hypequery/clickhouse involving @hypequery/clickhouse has SQL Injection in parameter escaping that allows arbitrary SQL execution under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which @hypequery/clickhouse versions are affected?
Affected versions include releases prior to 2.5.1 across affected packages: @hypequery/clickhouse.
What version fixes CVE-2026-54658?
Upgrading to 2.5.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @hypequery/clickhouse affected?
Yes, @hypequery/clickhouse is affected in releases prior to 2.5.1. Upgrade your dependency to 2.5.1 or later.
What is the CVSS score of CVE-2026-54658?
CVE-2026-54658 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-54658?
CVE-2026-54658 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-2026-54658?
Run the dependency tree command: 'npm ls @hypequery/clickhouse'. 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-6wcc-39rp-hh9p",
  "modified" : "2026-08-04T20:34:06Z",
  "published" : "2026-07-28T22:19:23Z",
  "aliases" : [ "CVE-2026-54658" ],
  "summary" : "@hypequery/clickhouse has SQL Injection in parameter escaping that allows arbitrary SQL execution",
  "details" : "A SQL injection vulnerability exists in the `escapeValue()` function used for parameter substitution. `escapeValue()` dispatches on the type of the parameter value, and two of its branches failed to escape safely. An attacker who can control a parameter value can terminate the enclosing string literal and have the rest of the value parsed as SQL.\n\n**Vector 1 - string parameters. Fixed in 2.0.2.** The string branch escaped `'` as `''` but left `\\\\` untouched. ClickHouse honours C-style backslash escapes as well as SQL-standard quote doubling, so a value ending in an odd number of backslashes escapes the closing quote and the next parameter lands outside the literal:\n\n```\nwhere('a', 'eq', 'x\\\\')          ->   WHERE a = 'x\\\\' AND b = ' OR 1=1 --'\n```\n\n**Vector 2 - object and array parameters. Fixed in 2.5.1, NOT in 2.0.2.** The final branch of the same function rendered non-scalar values as `` `'${JSON.stringify(value)}'` `` with no escaping at all. JSON has no reason to escape the apostrophe, so any nested string containing `'` terminates the literal:\n\n```\nwhere('meta', 'eq', { k: \\\"x' OR 1=1 -- \\\" })\n                                ->   WHERE meta = '{\\\"k\\\":\\\"x' OR 1=1 -- \\\"}'\n```\n\nThe 2.0.2 patch changed only the string branch and did not address this. Vector 2 remained exploitable in **2.0.2, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.2.0, 2.3.0, 2.4.0 and 2.5.0** - every release this advisory previously reported as patched.\n\n**Who is impacted.** Any application on a version below 2.5.1 that passes user-controlled input as a query parameter. Both vectors are reachable through the documented public API: `.where(column, operator, value)`, the `in` operator, and `adapter.render()` / `rawQuery()`.\n\n**Schema type declarations do not mitigate vector 2.** `createQueryBuilder().table()` builds its state with an empty column map, so the filter validator has no declared type to check against and returns without validating. Even where a schema is supplied, only `String`, `Int32`, `Int64`, `Float64` and `Date` columns are type-checked - `Map`, `Array`, `Bool`, `UUID`, `DateTime`, `UInt*`, `Enum` and `Nullable` columns are not - and any column name containing a `.` skips validation entirely.\n\n## Patches\n\nUpgrade to **2.5.1 or later**. Both vectors are closed there.\n\n- **Vector 1** - fixed in **2.0.2** by `2dc1df7bae` (the referenced `4dfa9d77` is the same change\n  on the pull-request branch). Escapes backslashes before escaping single quotes.\n- **Vector 2** - fixed in **2.5.1** by `2879161a81`, which routes the serialised JSON back through  `escapeValue()` so nested quotes are doubled. The same commit also rejects non-finite numbers and  invalid `Date` values instead of emitting them into the query.\n\nFor anyone auditing the history: the vector-2 fix is bundled inside `2879161a81`, whose commit message is *\\\"parenthesize logical groups in WHERE to preserve AND/OR precedence (#349)\\\"*. Commit `4a1d4e38aa` (#350), whose message *does* describe the escaping fix, changes only a `bigint` branch - the escaping fix is already present in its parent.\n\n## Workarounds\n\nUpgrading is the only complete fix.\n\nFor **vector 2** only, applications on 2.0.2–2.5.0 that cannot upgrade can serialise non-scalar parameters themselves and pass the resulting string. That routes the value through the string branch, which is correctly escaped from 2.0.2 onward:\n\n```js\n.where('meta', 'eq', JSON.stringify(value))   // safe on >= 2.0.2\n```\n\nThere is no workaround for **vector 1** other than upgrading to 2.0.2 or later.\n\nDo not substitute application-level input validation or sanitisation for either fix. Correct escaping depends on the literal context the library constructs, so the library has to own it.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@hypequery/clickhouse"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.5.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "< 2.0.2"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/hypequery/hypequery/security/advisories/GHSA-6wcc-39rp-hh9p"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-54658"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hypequery/hypequery/pull/349"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hypequery/hypequery/commit/2879161a810fed2c2222f785816ff05510976960"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hypequery/hypequery/commit/2dc1df7bae"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hypequery/hypequery/commit/4dfa9d77d70a08b970e722268b75ca7d13db0bdf"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/hypequery/hypequery"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hypequery/hypequery/blob/main/packages/clickhouse/CHANGELOG.md#202"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hypequery/hypequery/releases/tag/@hypequery/clickhouse@2.0.2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hypequery/hypequery/releases/tag/@hypequery/clickhouse@2.5.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-28T22:19:23Z",
    "nvd_published_at" : "2026-07-28T23:17:08Z"
  }
}