New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Anyone know anything more about CVE-2026-40018 (Dovecot SQL Injection)?
in Help
Hi all!
TIL about https://documentation.open-xchange.com/dovecot/security/advisories/html/2026/oxdc-adv-2026-0003.html#cve-2026-40018-mysql-multi-byte-escaping-wrong, but the page doesn't provide much infos about the vulnerability...
I couldn't find anything else about it, has anyone here any infos they can share? I'll take a binary "just shut down your mail server and wait for the patch" ![]()
Thanks!
Thanked by 1ralf
Comments
cvss score is 7.4, with vector
AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N. network exploitable, high attack complexity, no privileges or user interaction needed. confidentiality and integrity impact are high. no availability impact. affects dovecot pro core2.3.0through3.1.5, and ce core2.3.0through2.4.4. discovered 2026 04 08, credited to tipsennn via yeswehack. fix released 2026 08 26. no public exploit known. cwe isCWE 89, sql injection. the bug is in the mysql sql driver escaping path,driver_mysql_escape_string()insrc/lib-sql/driver-mysql.c. the connected path usesmysql_real_escape_string(), which reads the active mysql connection charset. when the sql connection drops and reconnecting fails, the old code falls back to plainmysql_escape_string(), which does not know the charset. the old code comment even flagged the tradeoff directly: "the next query will most likely fail anyway so it shouldn't matter that much what we return here." that assumption turned out wrong. this matters withbig5,gbk,sjis,cp932, andgb18030, where0x5ccan be a valid trailing byte inside a multi byte character. the multibyte mechanism itself is the known root cause class, though the exact remote exploit sequence isnt publicly documented by dovecot. the general idea: a crafted byte sequence can cause the backslash meant to escape a quote to get absorbed into the character before it instead. the quote then stays active and breaks out of the string literal. the trigger path sql connection drops, reconnect fails, escaping falls back to the charset unaware function,0x5cgets consumed as a multi byte trailing byte, the quote stays active. as an inferred consequence of that escaping failure, attacker controlled sql can reach the mysql parser, though this is not an exploit sequence dovecot has published themselves. same escaping failure class asCVE 2006 2313,CVE 2006 2314, andCVE 2026 55855.CVE 2006 2314is the closest match since it specifically involves0x5cas a multi byte trailing byte. standard utf8 and utf8mb4 dont have this trailing byte issue. for dovecot, this hits the mysql sql driver, and auth paths likepassdbanduserdbuse that same escaping path when configured for sql. the public adisory doesnt give a full component by component exploit matrix, and theres no confirmeddictquota exploit path listed either. the exact remote trigger sequence isnt published, so this trigger path comes from the known source behavior and the general mysql multi byte escaping mechanism, not a confirmed public writeup.the fix is source level, confirmed in the actual 2.4.4 to 2.4.5 diff. the disconnected fallback branch is deleted entirely.
driver_mysql_escape_string()changes signature from returningconst char *to returningintwithoutput_r/error_rout parameters. if still disconnected after the reconnect attempt, it now sets*error_r = SQL_ERRSTR_NOT_CONNECTEDand returns-1, no escaping happens, no query gets built. the connected path is unchanged, still callingmysql_real_escape_string(). the vendor confirms pro3.1.6is the first fixed pro revision, carrying the same fix.EDIT: Fixed some mistakes ( 13th time ). 95% confidence i got all of these from different sources, so there might be some inconsistencies or mistakes.
Ok, so looking at the UTF-8 Wikipedia page, 0x5c (backslash) really can't be a part of a multibyte character (as all UTF-8 multibyte has a 0x80 set). I don't think that the client (=attacker) can change the charset used in the DB connection, so as long as the table uses utf8mb, this is a non-issue?
Another "mitigation" might be to make sure that the DB is not disconnected. In my case it runs on the same server, so as long as I start Dovecot after the DB it should be fine.