GHSA-PQCC-F7JJ-MC82
SQL injection in string parameter and escape() escaping under big5, gbk, sjis and cp932 client charsets
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-PQCC-F7JJ-MC82 divulgada · CVSS 6.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
### Description
String parameters of the text protocol and Connection.escape() escaped the JavaScript string before encoding it, on the assumption that the escape characters are below 0x80 and therefore safe under any charset. That holds only if the encoder produces byte sequences the server reads the same way. iconv-lite's big5 is Big5-HKSCS, so ordinary characters encode to two-byte sequences the server does not recognise as big5, with 0x5C as their second byte: U+56ED encodes to FB 5C, U+6A9D to FD 5C, U+011A to 88 5C. The escape inserted after such a character landed right after a byte the server reads alone, the server took the 0x5C as an escape introducer, and a following quote ended the string literal.
Under big5, 22 BMP code points inject this way, 20 of them with a lead byte below 0xA1 that no correction of the lead byte range can reach. The trigger is an ordinary character in a text field, not a crafted byte string.
The text protocol is affected for string parameters, and Connection.escape() and Pool.escape() with a string argument, when the session charset is big5, gbk, sjis or cp932. execute() and batch() are not affected.
### Impact
An attacker controlling a string parameter of a text-protocol query, or a value passed to escape(), on a connection using one of these client charsets, 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 one of these non-default client charsets, set through the charset or collation option, a connection string, or SET NAMES.
### Resolution
Under these charsets, strings are now encoded first and escaped byte-wise with the charset recognizer, as Buffer parameters are, and escape() uses the same escaping as the parameter path, so both produce the same bytes.
### 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-380: https://jira.mariadb.org/browse/CONJS-380
Fix commit: https://github.com/mariadb-corporation/mariadb-connector-nodejs/commit/b66ff8a
### 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-pqcc-f7jj-mc82Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
