
PEACH
Un cadre d’isolation des locataires
When a connection is configured for TLS (ssl set, including with a pinned CA and rejectUnauthorized: true), mysql2 begins parsing MySQL packets before the TLS handshake has completed. An on-path (MITM) attacker, or a rogue server the client is directed to, can send — in the same TCP segment as the server greeting — a forged OK packet followed by a forged result set. mysql2 parses these as plaintext packets, marks the connection authenticated, and returns the attacker-chosen rows to the application. The TLS handshake never completes, yet the application believes it is operating over a CA-verified TLS channel.
This defeats the protection that rejectUnauthorized: true exists to provide: certificate verification is part of the TLS handshake, which never runs, so the forged session is accepted without any certificate ever being validated.
The forged result reaches any command already queued when the greeting arrives — the documented pool.query() and createConnection()-then-query() usage. Reproduced 10/10 on 3.24.6 and on current master.
Scope note: the client's credentials and query text are not disclosed to the attacker. sendCredentials() is gated on the real secureConnect event, and query bytes are written into the stalled TLS socket rather than sent in cleartext. The impact is on integrity (forged authentication result and forged data returned to the application), not on confidentiality of the client's secrets.
ssl (object form, ssl: true, or a named profile), including rejectUnauthorized: true with a pinned CA.lib/commands/client_handshake.js handshakeInit() sends the SSL upgrade request, calls connection.startTLS(...), and then synchronously returns the handshakeResult state. The packet parser processes every packet contained in the greeting's TCP chunk synchronously (lib/base/connection.js), so packets that follow the greeting in the same chunk are parsed as plaintext before TLS is established. startTLS()'s removal of the plaintext data listener only affects subsequent socket reads, not the chunk already in flight. An out-of-order sequence id only emits a warning and is not fatal.
Do not advance the handshake state machine past the SSL request until the socket reports secureConnect. Treat any packet that arrives before TLS completes as a fatal protocol error instead of parsing it. A conforming server sends nothing between the greeting and the TLS ServerHello, so this introduces no false positives. Fixed in 3.26.0 (commit abcf681).
CVSS v4.0: CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:H/VA:L/SC:N/SI:N/SA:N (High). Integrity is fully compromised (the attacker controls the rows and the apparent authentication result); confidentiality of the client's secrets is not directly affected, which is why it is not rated Critical. If the application makes trust or authorization decisions based on query results, the effective impact is higher.
Reported privately by @ebadfd.
Source: NVD
Évaluation gratuite des vulnérabilités
É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.
Obtenez une démo personnalisée
"La meilleure expérience utilisateur que j’ai jamais vue, offre une visibilité totale sur les workloads cloud."
"Wiz fournit une interface unique pour voir ce qui se passe dans nos environnements cloud."
"Nous savons que si Wiz identifie quelque chose comme critique, c’est qu’il l’est réellement."