{"id":"GHSA-8cpq-38p9-67gx","revision":null,"records":[{"revision":"d4b9a5af589741759d940ed4a2e7c9e5","observedAt":"2026-10-23T15:48:27.903+00:00","statement":{"source":"cve-program","id":"CVE-2026-33468","aliases":[],"title":"Kysely has a MySQL SQL Injection via Insufficient Backslash Escaping in `sql.lit(string)` usage or similar methods that append string literal values into the compiled SQL strings","description":"Kysely is a type-safe TypeScript SQL query builder. Prior to version 0.28.14, Kysely's `DefaultQueryCompiler.sanitizeStringLiteral()` only escapes single quotes by doubling them (`'` → `''`) but does not escape backslashes. When used with the MySQL dialect (where `NO_BACKSLASH_ESCAPES` is 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 uses `ImmediateValueTransformer` to inline values — specifically `CreateIndexBuilder.where()` and `CreateViewBuilder.as()`. Version 0.28.14 contains a fix.","state":0,"publishedAt":"2026-03-26T17:03:05.972+00:00","modifiedAt":"2026-03-26T19:52:10.689+00:00","affected":[{"ecosystem":"Vendor product","name":"kysely","ranges":[],"versions":[],"rawVersionEvidence":"{\n                    \"vendor\": \"kysely-org\",\n                    \"product\": \"kysely\",\n                    \"versions\": [\n                        {\n                            \"version\": \"< 0.28.14\",\n                            \"status\": \"affected\"\n                        }\n                    ]\n                }"}],"metrics":[{"system":"CVSS 3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H","score":8.1,"severity":"HIGH"}],"references":["https://github.com/kysely-org/kysely/security/advisories/GHSA-8cpq-38p9-67gx"],"sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-33468","license":"CVE Program Terms of Use","key":"cve-program:CVE-2026-33468","identifiers":["CVE-2026-33468"]},"retained":false,"historicalAffected":[]},{"revision":"36ce6675465d41258f2b84b7241045b1","observedAt":"2026-11-15T10:03:23.685+00:00","statement":{"source":"euvd","id":"EUVD-2026-16265","aliases":["CVE-2026-33468","GHSA-8cpq-38p9-67gx"],"title":"Kysely is a type-safe TypeScript SQL query builder. Prior to version 0.28.14, Kysely's `DefaultQueryCompiler.sanitizeStringLiteral()` only escapes single quotes by doubling them (`'` → `''`) but does not escape backslashes. When used with t…","description":"Kysely is a type-safe TypeScript SQL query builder. Prior to version 0.28.14, Kysely's `DefaultQueryCompiler.sanitizeStringLiteral()` only escapes single quotes by doubling them (`'` → `''`) but does not escape backslashes. When used with the MySQL dialect (where `NO_BACKSLASH_ESCAPES` is 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 uses `ImmediateValueTransformer` to inline values — specifically `CreateIndexBuilder.where()` and `CreateViewBuilder.as()`. Version 0.28.14 contains a fix.","state":0,"publishedAt":null,"modifiedAt":null,"affected":[],"metrics":[{"system":"EUVD CVSS 3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H","score":8.1,"severity":null}],"references":["https://github.com/kysely-org/kysely/security/advisories/GHSA-8cpq-38p9-67gx"],"sourceUrl":"https://euvd.enisa.europa.eu/vulnerability/EUVD-2026-16265","license":"ENISA EUVD · source terms and attribution apply","enrichment":{"sourceStatus":null,"weaknesses":[],"productCriteria":[],"sourceDates":{"datePublished":"Mar 26, 2026, 5:03:05 PM","dateUpdated":"Mar 26, 2026, 7:52:10 PM"},"relatedAdvisories":[],"note":"EUVD source date text has no stated timezone and is retained without inventing a UTC instant. Related bulletin membership is not an alias, common cause or applicability claim. A missing vector with a zero score is treated as unrated. Complete vendor/product and underlying source evidence remains in the original JSON."},"key":"euvd:EUVD-2026-16265","identifiers":["EUVD-2026-16265","CVE-2026-33468","GHSA-8cpq-38p9-67gx"]},"retained":false,"historicalAffected":[]},{"revision":"b853d78e070b4ed6b32d58ccb8fb26f7","observedAt":"2026-10-25T08:17:18.375+00:00","statement":{"source":"nvd","id":"CVE-2026-33468","aliases":[],"title":"Kysely is a type-safe TypeScript SQL query builder. Prior to version 0.28.14, Kysely's `DefaultQueryCompiler.sanitizeStringLiteral()` only escapes single quotes by doubling them (`'` → `''`) but does not escape backslashes. When used with t…","description":"Kysely is a type-safe TypeScript SQL query builder. Prior to version 0.28.14, Kysely's `DefaultQueryCompiler.sanitizeStringLiteral()` only escapes single quotes by doubling them (`'` → `''`) but does not escape backslashes. When used with the MySQL dialect (where `NO_BACKSLASH_ESCAPES` is 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 uses `ImmediateValueTransformer` to inline values — specifically `CreateIndexBuilder.where()` and `CreateViewBuilder.as()`. Version 0.28.14 contains a fix.","state":0,"publishedAt":"2026-03-26T17:16:41.007+00:00","modifiedAt":"2026-06-17T10:37:32.943+00:00","affected":[],"metrics":[{"system":"CVSS 3.1 · security-advisories@github.com · Secondary","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H","score":8.1,"severity":"HIGH"}],"references":["https://github.com/kysely-org/kysely/security/advisories/GHSA-8cpq-38p9-67gx"],"sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2026-33468","license":"NIST NVD usage terms; underlying source attribution retained","enrichment":{"sourceStatus":"Analyzed","weaknesses":["CWE-89"],"productCriteria":["cpe:2.3:a:kysely:kysely:*:*:*:*:*:node.js:*:*"],"sourceDates":{"published":"2026-03-26T17:16:41.007","lastModified":"2026-06-17T10:37:32.943"},"relatedAdvisories":[],"note":"NVD analysis and CPE criteria are source context, not proof that a package or your environment is affected. Complete affected data, logical configurations and SSVC are retained in the original JSON."},"key":"nvd:CVE-2026-33468","identifiers":["CVE-2026-33468"]},"retained":false,"historicalAffected":[]},{"revision":"ffb094e3e767429d9d75b3633eb2d888","observedAt":"2026-10-24T13:17:17.793+00:00","statement":{"source":"osv","id":"GHSA-8cpq-38p9-67gx","aliases":["CVE-2026-33468"],"title":"Kysely has a MySQL SQL Injection via Insufficient Backslash Escaping in `sql.lit(string)` usage or similar methods that append string literal values into the compiled SQL strings","description":"## Summary\n\nKysely's `DefaultQueryCompiler.sanitizeStringLiteral()` only escapes single quotes by doubling them (`'` → `''`) but does not escape backslashes. When used with the MySQL dialect (where `NO_BACKSLASH_ESCAPES` is 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 uses `ImmediateValueTransformer` to inline values — specifically `CreateIndexBuilder.where()` and `CreateViewBuilder.as()`.\n\n## Details\n\nThe root cause is in `DefaultQueryCompiler.sanitizeStringLiteral()`:\n\n**`src/query-compiler/default-query-compiler.ts:1819-1821`**\n```typescript\nprotected sanitizeStringLiteral(value: string): string {\n  return value.replace(LIT_WRAP_REGEX, \"''\")\n}\n```\n\nWhere `LIT_WRAP_REGEX` is defined as `/'/g` (line 121). This only doubles single quotes — it does not escape backslash characters.\n\nThe function is called from `appendStringLiteral()` which wraps the sanitized value in single quotes:\n\n**`src/query-compiler/default-query-compiler.ts:1841-1845`**\n```typescript\nprotected appendStringLiteral(value: string): void {\n  this.append(\"'\")\n  this.append(this.sanitizeStringLiteral(value))\n  this.append(\"'\")\n}\n```\n\nThis is reached when `visitValue()` encounters an immediate value node (line 525-527), which is created by `ImmediateValueTransformer` used in `CreateIndexBuilder.where()`:\n\n**`src/schema/create-index-builder.ts:266-278`**\n```typescript\nwhere(...args: any[]): any {\n  const transformer = new ImmediateValueTransformer()\n\n  return new CreateIndexBuilder({\n    ...this.#props,\n    node: QueryNode.cloneWithWhere(\n      this.#props.node,\n      transformer.transformNode(\n        parseValueBinaryOperationOrExpression(args),\n        this.#props.queryId,\n      ),\n    ),\n  })\n}\n```\n\nThe `MysqlQueryCompiler` (at `src/dialect/mysql/mysql-query-compiler.ts:6-75`) extends `DefaultQueryCompiler` but does **not** override `sanitizeStringLiteral`, inheriting the backslash-unaware implementation.\n\n**Exploitation mechanism:**\n\nIn MySQL with the default `NO_BACKSLASH_ESCAPES=OFF` setting, the backslash character (`\\`) acts as an escape character inside string literals. Given input `\\' OR 1=1 --`:\n\n1. `sanitizeStringLiteral` doubles the quote: `\\'' OR 1=1 --`\n2. `appendStringLiteral` wraps: `'\\'' OR 1=1 --'`\n3. MySQL interprets `\\'` as an escaped (literal) single quote, so the string content is `'` and the second `'` closes the string\n4. ` OR 1=1 --` is parsed as SQL\n\n## PoC\n\n```typescript\nimport { Kysely, MysqlDialect } from 'kysely'\nimport { createPool } from 'mysql2'\n\ninterface Database {\n  orders: {\n    id: number\n    status: string\n    order_nr: string\n  }\n}\n\nconst db = new Kysely<Database>({\n  dialect: new MysqlDialect({\n    pool: createPool({\n      host: 'localhost',\n      database: 'test',\n      user: 'root',\n      password: 'password',\n    }),\n  }),\n})\n\n// Simulates user-controlled input reaching CreateIndexBuilder.where()\nconst userInput = \"\\\\' OR 1=1 --\"\n\nconst query = db.schema\n  .createIndex('orders_status_index')\n  .on('orders')\n  .column('status')\n  .where('status', '=', userInput)\n\n// Compile to see the generated SQL\nconst compiled = query.compile()\nconsole.log(compiled.sql)\n// Output: create index `orders_status_index` on `orders` (`status`) where `status` = '\\'' OR 1=1 --'\n//\n// MySQL parses this as:\n//   WHERE `status` = '\\'   ← string literal containing a single quote\n//   ' OR 1=1 --'          ← injected SQL (OR 1=1), comment eats trailing quote\n```\n\nTo verify against a live MySQL instance:\n\n```sql\n-- Setup\nCREATE DATABASE test;\nUSE test;\nCREATE TABLE orders (id INT PRIMARY KEY, status VARCHAR(50), order_nr VARCHAR(50));\nINSERT INTO orders VALUES (1, 'active', '001'), (2, 'cancelled', '002');\n\n-- The compiled query from Kysely with injected payload:\n-- This returns all rows instead of filtering by status\nSELECT * FROM orders WHERE status = '\\'' OR 1=1 -- ';\n```\n\n## Impact\n\n- **SQL Injection:** An attacker who controls values passed to `CreateIndexBuilder.where()` or `CreateViewBuilder.as()` can inject arbitrary SQL statements when the application uses the MySQL dialect.\n- **Data Exfiltration:** Injected SQL can read arbitrary data from the database using UNION-based or subquery-based techniques.\n- **Data Modification/Destruction:** Stacked queries or subqueries can modify or delete data.\n- **Authentication Bypass:** If index creation or view definitions are influenced by user input in application logic, the injection can alter query semantics to bypass access controls.\n\nThe 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.\n\n## Recommended Fix\n\n`MysqlQueryCompiler` should override `sanitizeStringLiteral` to escape backslashes before doubling quotes:\n\n**`src/dialect/mysql/mysql-query-compiler.ts`**\n```typescript\nconst LIT_WRAP_REGEX = /'/g\nconst BACKSLASH_REGEX = /\\\\/g\n\nexport class MysqlQueryCompiler extends DefaultQueryCompiler {\n  // ... existing overrides ...\n\n  protected override sanitizeStringLiteral(value: string): string {\n    // Escape backslashes first (\\ → \\\\), then double single quotes (' → '')\n    // MySQL treats backslash as an escape character by default (NO_BACKSLASH_ESCAPES=OFF)\n    return value.replace(BACKSLASH_REGEX, '\\\\\\\\').replace(LIT_WRAP_REGEX, \"''\")\n  }\n}\n```\n\nAlternatively, 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.","state":0,"publishedAt":"2026-03-20T20:48:55+00:00","modifiedAt":"2026-09-10T03:51:00.0316818+00:00","affected":[{"ecosystem":"npm","name":"kysely","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"0"},{"kind":"fixed","version":"0.28.14"}]}],"versions":[],"rawVersionEvidence":null}],"metrics":[{"system":"CVSS_V3","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H","score":null,"severity":null},{"system":"Publisher rating","vector":null,"score":null,"severity":"HIGH"}],"references":["https://github.com/kysely-org/kysely/security/advisories/GHSA-8cpq-38p9-67gx","https://nvd.nist.gov/vuln/detail/CVE-2026-33468","https://github.com/kysely-org/kysely"],"sourceUrl":"https://github.com/advisories/GHSA-8cpq-38p9-67gx","license":"GitHub Advisory Database · CC-BY-4.0","key":"osv:GHSA-8cpq-38p9-67gx","identifiers":["GHSA-8cpq-38p9-67gx","CVE-2026-33468"]},"retained":false,"historicalAffected":[]}],"coverage":[{"source":"cisa-kev:global","scope":"Complete CISA KEV catalog; all vendors. Missing entries do not establish absence of exploitation.","generation":"2026-11-15T12:00:55.3946839+00:00","complete":true,"records":1781,"lastAttemptAt":"2026-11-15T12:00:55.3946839+00:00","lastSuccessAt":"2026-11-15T12:00:55.579435+00:00","error":null,"lastVerifiedAt":"2026-11-15T12:00:55.5794357+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"cve-program","scope":"Official CVE Program baseline and cumulative hourly delta; all vendors, published and rejected records","generation":"cve-7de4d7559a5263003f03d9f70577ab06f92ba4178309f26fce53e22a4a959294-9f2801eea6d0b63da2583193add6be220e1b53bbbe4ef94b9346425ef1596ca8","complete":true,"records":425788,"lastAttemptAt":"2026-11-15T12:00:54.4294537+00:00","lastSuccessAt":"2026-11-15T12:00:54.4082037+00:00","error":null,"lastVerifiedAt":"2026-11-15T12:00:54.4294537+00:00","snapshotPublishedAt":"2026-11-15T11:26:58+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"euvd","scope":"Rolling EUVD lookups of CVE aliases in current public OSV archives; 500 identifiers per refresh, rechecked after 48 hours. Not a global EUVD catalog. Successful not-found lookups count as checked; they do not imply withdrawal or safety. No reader inventory is sent.","generation":"enrichment-850c26e23e9a454eb8654cf34d45fa51","complete":false,"records":13821,"lastAttemptAt":"2026-11-15T12:10:42.9128167+00:00","lastSuccessAt":"2026-11-15T12:10:42.908+00:00","error":"92 identifier lookups failed; latest failures include AccessDenied (HTTP 403). Other identifiers were checked independently.","lastVerifiedAt":"2026-11-15T12:10:42.908+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":13568,"expectedIdentifiers":13874,"failedIdentifiers":92},{"source":"first-epss:nuget","scope":"FIRST EPSS for explicit CVE aliases in the collected public NuGet archive. Not a global EPSS backfill.","generation":"2026-11-15T12:00:55.3946839+00:00","complete":true,"records":1125,"lastAttemptAt":"2026-11-15T12:00:55.3946839+00:00","lastSuccessAt":"2026-11-15T12:00:55.580236+00:00","error":null,"lastVerifiedAt":"2026-11-15T12:00:55.580236+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"nvd","scope":"Rolling NVD lookups of CVE aliases in current public OSV archives; 500 identifiers per refresh, rechecked after 48 hours. Not a global NVD catalog. Successful not-found lookups count as checked; they do not imply withdrawal or safety. No reader inventory is sent.","generation":"enrichment-d33b5144615b488f88b7a7390696bc39","complete":false,"records":13833,"lastAttemptAt":"2026-11-15T12:01:03.1788889+00:00","lastSuccessAt":"2026-11-15T10:02:36.038+00:00","error":"1 identifier lookups failed; latest failures include HttpError (HTTP 503). Other identifiers were checked independently.","lastVerifiedAt":"2026-11-15T10:02:36.038+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":13873,"expectedIdentifiers":13874,"failedIdentifiers":1},{"source":"osv:Go","scope":"Complete OSV Go ecosystem archive, including withdrawn and malicious-package source records; statement counts are not unique CVE counts","generation":"go-64eea06dbd27de8464d5dbce1b78cc794cc59e2d901516ae0d3ea76e624cdae0","complete":true,"records":9955,"lastAttemptAt":"2026-11-15T12:00:55.0947737+00:00","lastSuccessAt":"2026-11-14T13:57:23.1208135+00:00","error":null,"lastVerifiedAt":"2026-11-15T12:00:55.0947737+00:00","snapshotPublishedAt":"2026-11-14T13:17:57+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"osv:NuGet","scope":"Complete OSV NuGet ecosystem archive, including GitHub Advisory Database records; NuGet version matching only","generation":"nuget-f4424d7d4861b1af1404bd15abcb83f295dcd003412a9340ca99dc8200aa148a","complete":true,"records":2014,"lastAttemptAt":"2026-11-15T12:00:54.588948+00:00","lastSuccessAt":"2026-11-13T19:57:08.2864435+00:00","error":null,"lastVerifiedAt":"2026-11-15T12:00:54.588948+00:00","snapshotPublishedAt":"2026-11-13T19:33:10+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"osv:crates.io","scope":"Complete OSV crates.io ecosystem archive, including withdrawn and malicious-package source records; statement counts are not unique CVE counts","generation":"crates.io-6086d649bcb454cdf302d7d9275177bda73550e1b6e446b3520e9b6266d3582c","complete":true,"records":3148,"lastAttemptAt":"2026-11-15T12:00:55.3229475+00:00","lastSuccessAt":"2026-11-15T11:05:17.1034234+00:00","error":null,"lastVerifiedAt":"2026-11-15T12:00:55.3229475+00:00","snapshotPublishedAt":"2026-11-15T10:03:04+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"osv:npm","scope":"Complete OSV npm ecosystem archive, including withdrawn and malicious-package source records; statement counts are not unique CVE counts","generation":"npm-ff18f36f13fcca3a20a3fb9274b59b8872d18869a99071730e1e79b625c8f612","complete":true,"records":232475,"lastAttemptAt":"2026-11-15T12:00:54.6916951+00:00","lastSuccessAt":"2026-11-15T11:05:10.4195883+00:00","error":null,"lastVerifiedAt":"2026-11-15T12:00:54.6916951+00:00","snapshotPublishedAt":"2026-11-15T10:33:06+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null}]}