GHSA-34WH-96P7-XCJQ
SQL injection when the configured client charset is not supported by the server (gb18030 on MariaDB)
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche 3.2.6 | mariadb · -7 d desde divulgación | |
| Remediación | Parche 3.3.5 | mariadb · -7 d desde divulgación | |
| Remediación | Parche 3.4.8 | mariadb · -7 d desde divulgación | |
| Remediación | Parche 3.5.5 | mariadb · -7 d desde divulgación | |
| Divulgación | Publicada | GHSA-34WH-96P7-XCJQ divulgada · CVSS 6.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
### Description
The connector selected its escaping from the charset the application requested, without checking which charset the server actually honoured. The collation was sent in the handshake, and the server silently ignores a collation it does not know: MariaDB implements no gb18030 charset, so a connection opened with charset gb18030 stayed on utf8mb4 while the connector escaped Buffer and stream parameters with the gb18030 recognizer. Since the gb18030 lead byte range is 0x81 to 0xFE, almost every lead byte followed by 0x5C was copied verbatim without an escape, and the server, lexing as utf8mb4, read the 0x5C as an escape introducer: 126 of the 128 possible lead bytes let a following quote end the string literal.
The same mismatch applies to any charset the server does not implement while the connector has an escaper for it.
### Impact
An attacker controlling a Buffer or stream parameter of a text-protocol query, on a connection configured with a charset the server does not support, could execute SQL inside the host statement with the privileges of the application's database user. With multipleStatements left to its default, the injection is bounded to the host statement.
Exposure requires a non-default client charset the server does not implement, set through the charset or collation option or a connection string.
### Resolution
A configured collation is always set with SET NAMES after the handshake, so a charset the server does not support is refused by the server and the connection fails, instead of the connector escaping for a charset the session does not use.
### Patches
Fixed in 3.2.6, 3.3.5, 3.4.8 and 3.5.5. Upgrade to the patched release of your branch.
### Workarounds
Use execute() or batch(), or use the default utf8mb4 client charset, until upgraded.
### References
CONJS-381: https://jira.mariadb.org/browse/CONJS-381
Fix commit: https://github.com/mariadb-corporation/mariadb-connector-nodejs/commit/13a368c
### Credit
Reported by Yalguun Tumenkhuu (@fg0x0 https://github.com/fg0x0/).
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmmariadb |
Corregida | 3.2.6, 3.3.5, 3.4.8, 3.5.5 | -7 d · -7 d · -7 d · -7 d | 3.5.5 no afectada |
3.2.63.3.53.4.83.5.5Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/mariadb-corporation/mariadb-connector-nodejs/security/advisories/GHSA-34wh-96p7-xcjqLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
