Update dependency kysely to v0.28.14 [SECURITY]#920
Open
renovate[bot] wants to merge 1 commit intomainfrom
Open
Update dependency kysely to v0.28.14 [SECURITY]#920renovate[bot] wants to merge 1 commit intomainfrom
renovate[bot] wants to merge 1 commit intomainfrom
Conversation
4142fcd to
79b61e1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.28.11→0.28.14GitHub Vulnerability Alerts
CVE-2026-32763
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 ('$...'), andvisitJSONPathLeg()appends each key/index value viathis.append(String(node.value))with no sanitization:Contrast with
sanitizeIdentifier()in the same file, which properly doubles delimiter characters: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):->$,->>$) produce aJSONPathNodetraversal →visitJSONPathLeg()concatenates the key directly into a single-quoted JSON path string ('$.key') — vulnerable, no escaping.->,->>) 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):
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:
Realistic application pattern
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 howsanitizeIdentifier()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.CVE-2026-33468
Summary
Kysely's
DefaultQueryCompiler.sanitizeStringLiteral()only escapes single quotes by doubling them ('→'') but does not escape backslashes. When used with the MySQL dialect (whereNO_BACKSLASH_ESCAPESis OFF by default), an attacker can use a backslash to escape the trailing quote of a string literal, breaking out of the string context and injecting arbitrary SQL. This affects any code path that usesImmediateValueTransformerto inline values — specificallyCreateIndexBuilder.where()andCreateViewBuilder.as().Details
The root cause is in
DefaultQueryCompiler.sanitizeStringLiteral():src/query-compiler/default-query-compiler.ts:1819-1821Where
LIT_WRAP_REGEXis defined as/'/g(line 121). This only doubles single quotes — it does not escape backslash characters.The function is called from
appendStringLiteral()which wraps the sanitized value in single quotes:src/query-compiler/default-query-compiler.ts:1841-1845This is reached when
visitValue()encounters an immediate value node (line 525-527), which is created byImmediateValueTransformerused inCreateIndexBuilder.where():src/schema/create-index-builder.ts:266-278The
MysqlQueryCompiler(atsrc/dialect/mysql/mysql-query-compiler.ts:6-75) extendsDefaultQueryCompilerbut does not overridesanitizeStringLiteral, inheriting the backslash-unaware implementation.Exploitation mechanism:
In MySQL with the default
NO_BACKSLASH_ESCAPES=OFFsetting, the backslash character (\) acts as an escape character inside string literals. Given input\' OR 1=1 --:sanitizeStringLiteraldoubles the quote:\'' OR 1=1 --appendStringLiteralwraps:'\'' OR 1=1 --'\'as an escaped (literal) single quote, so the string content is'and the second'closes the stringOR 1=1 --is parsed as SQLPoC
To verify against a live MySQL instance:
Impact
CreateIndexBuilder.where()orCreateViewBuilder.as()can inject arbitrary SQL statements when the application uses the MySQL dialect.The attack complexity is rated High (AC:H) because exploitation requires an application to pass untrusted user input into DDL schema builder methods, which is an atypical but not impossible usage pattern. The
CreateIndexBuilder.where()docstring (line 247) notes "Parameters are always sent as literals due to database restrictions" without warning about the security implications.Recommended Fix
MysqlQueryCompilershould overridesanitizeStringLiteralto escape backslashes before doubling quotes:src/dialect/mysql/mysql-query-compiler.tsAlternatively, the library could use parameterized queries for these DDL builders where the database supports it, avoiding string literal interpolation entirely. For databases that don't support parameters in DDL statements, the dialect-specific compiler must escape all characters that have special meaning in that dialect's string literal syntax.
Release Notes
kysely-org/kysely (kysely)
v0.28.14: 0.28.14Compare Source
Hey 👋
A small batch of bug fixes. Please report any issues. 🤞😰🤞
🚀 Features
🐞 Bugfixes
MySQL 🐬
\\') are used. by @igalklebanov in #1754 &054e801📖 Documentation
📦 CICD & Tooling
9e02f3b🐤 New Contributors
Full Changelog: kysely-org/kysely@v0.28.13...v0.28.14
v0.28.13: 0.28.13Compare Source
Hey 👋
A small batch of bug fixes. Please report any issues. 🤞😰🤞
🚀 Features
🐞 Bugfixes
sideEffects: falsein rootpackage.jsonresulting in bigger bundles in various bundlers. by @igalklebanov in #1746Insertableallows non-objects when a table has no required columns. by @igalklebanov in #1747PostgreSQL 🐘
ON COMMITclause not being output when using.as(query)inCREATE TABLEqueries. by @igalklebanov in #1748📖 Documentation
📦 CICD & Tooling
tsconfig.jsonfor TypeScript native. by @igalklebanov in #1749🐤 New Contributors
Full Changelog: kysely-org/kysely@v0.28.12...v0.28.13
v0.28.12: 0.28.12Compare Source
Hey 👋
A small batch of bug fixes. Please report any issues. 🤞😰🤞
🚀 Features
🐞 Bugfixes
eb.ref(col, '->$').key(key)is injectable. by @igalklebanov in #1727MySQL 🐬
mysql2@​v3.18.2support #1722 by @fenichelar in #1729📖 Documentation
📦 CICD & Tooling
🐤 New Contributors
Full Changelog: kysely-org/kysely@v0.28.11...v0.28.12
Configuration
📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.