CVE-2026-107161: Cyrus-sasl: heap buffer overflow in cyrus-sasl add_to_challenge() allows malicious server to crash or compromise digest-md5 clients
A heap-based buffer overflow flaw was found in Cyrus SASL. The addtochallenge() function in the DIGEST-MD5 plugin computes the size of the buffer needed for a challenge/response field before DIGEST-MD5 quoting is applied, but does not recompute that size when quoting (escaping special characters) makes the value longer. The under-sized buffer is then passed to strcat(), causing a heap-based out-of-bounds write whose size depends on attacker-controlled input. A malicious or on-path DIGEST-MD5 (or HTTP Digest) server can trigger this flaw in a connecting client by supplying a crafted challenge field, such as realm or nonce, most likely resulting in a crash of the client application.
Other sources
AIONLYREPORT package: cyrus-sasl-2.1.28-29.el10 ------ Summary: Heap buffer overflow in addtochallenge() when quoting increases value length: A malicious server or peer can trigger a client-side heap overflow in Cyrus SASL during DIGEST-MD5 or HTTP Digest authentication by sending challenge fields with many escapable characters so the quoted value grows beyond the size calculated before allocation. Requirements to exploit: The attacker must control a malicious server or peer that a Cyrus SASL client authenticates to using DIGEST-MD5 or HTTP Digest. They must supply a challenge containing a field that is later re-emitted with needquotes=TRUE (for example nonce or opaque) and many escapable characters. This is a client-side issue during challenge handling, not the reverse server-side direction. Component affected: cyrus-sasl (plugins/digestmd5.c, client-side addtochallenge() used by DIGEST-MD5/HTTP Digest response generation) Version affected: cyrus-sasl-2.1.28-29.el10 (confirmed); the vulnerable logic likely predates this package version, but earlier affected versions were not confirmed here. Patch available: no Version fixed (if any already): unknown Upstream coordination: Not yet notified. This report is the initial triage. CVSS: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H - 8.8 (HIGH) AV:N - The issue is triggered by attacker-controlled challenge data received over a network authentication exchange. AC:L - No race or unusual conditions are required beyond use of the affected DIGEST-MD5 or HTTP Digest client path. PR:N - The attacker needs no prior privileges on the victim system. UI:R - A victim must initiate or complete authentication with the malicious server or peer. S:U - The overflow occurs within the client process that constructs the response. C:H - Reasonable worst-case impact for exploitable heap corruption is disclosure of client-accessible data. I:H - Reasonable worst-case impact for exploitable heap corruption is modification or code execution in the client context. A:H - Heap corruption can crash the client and may permit broader process compromise. Impact: Likely Important. This is a client-side memory-safety flaw reachable from attacker-controlled network input during DIGEST-MD5 or HTTP Digest authentication. A malicious server or peer can at least crash a vulnerable client, and reasonable worst-case impact includes stronger compromise in the client context if the overflow is exploitable. The need for the victim to authenticate to the malicious peer keeps this below Critical. Embargo: yes Reason: No upstream fix is known yet, and public disclosure before a fix is available would expose clients that still use DIGEST-MD5 or HTTP Digest to malicious servers or peers. Acknowledgement: Aisle Research Steps to reproduce: 1. Build cyrus-sasl with AddressSanitizer or another memory sanitizer. 2. Exercise the client-side DIGEST-MD5 or HTTP Digest code path so execution reaches makeclientresponse() / addtochallenge(). 3. From a malicious server or peer, send a challenge containing a field that will be re-emitted with needquotes=TRUE (for example nonce or opaque) and many escapable characters such as repeated \" and . 4. Trigger response generation by allowing the client to continue the authentication exchange. 5. Observe a heap-buffer-overflow at strcat(str, quoted) in addtochallenge() under the sanitizer. Mitigation: Avoid or disable DIGEST-MD5 and HTTP Digest when authenticating to untrusted servers or peers until a fix is available.
Prefer alternative authentication mechanisms that do not use this code path where feasible.
Apply an upstream or vendor fix once available.
Vulnerability Details
addtochallenge() computes newlen from the unquoted input length. When escaping is needed for " or \, quote() returns a longer string. The code updates valuesize after quoting, but reuses the stale pre-quote newlen when calling plugbufalloc(), then appends the expanded string with strcat(): c valuesize = strlen((char ) value); newlen = (unsigned) (curlen + 1 + namesize + 2 + valuesize + 2); ... valuesize = strlen(quoted); ret = plugbufalloc(utils, str, buflen, newlen); if (ret == SASLOK) { strcat(str, quoted); } Because plugbufalloc() only guarantees the requested size, a buffer that was exactly sized for the unquoted value can overflow when the quoted value becomes longer. Most relevant CWE IDs: CWE-131 Incorrect Calculation of Buffer Size
CWE-122 Heap-Based Buffer Overflow
CWE-787 Out-of-Bounds Write
Proposed Fix
Recompute newlen after quoting based on the current output length plus the expanded quoted value length, allocate using that recomputed size, and update curlen from the actual resulting string length instead of reusing the stale pre-quote size. ------ This report was generated using AI technology. Always review AI-generated content prior to use
— Red Hat
Cyrus-sasl: heap buffer overflow in cyrus-sasl addtochallenge() allows malicious server to crash or compromise digest-md5 clients
— Microsoft
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/cyrus-sasl2to a version that resolves this vulnerability.Fixed in 2.1.28+dfsg-10+deb12u1Fixed in 2.1.28+dfsg1-12 - Upgrade
Upgrade
debian/cyrus-sasl2to a version that resolves this vulnerability.Fixed in 2.1.28+dfsg-10+deb12u1 - Upgrade
Upgrade
debian/cyrus-sasl2to a version that resolves this vulnerability.Fixed in 2.1.28+dfsg1-12 - Configuration
Avoid or disable DIGEST-MD5 and HTTP Digest when authenticating to untrusted servers or peers, and prefer alternative authentication mechanisms that do not use this code path.
Cyrus SASL DIGEST-MD5 and HTTP Digest authentication = disabled - Compensating control
Build cyrus-sasl with AddressSanitizer or another memory sanitizer to detect the heap-buffer-overflow.
Event History
Frequently Asked Questions
Which systems are realistically exposed to this flaw?
The affected side is a Cyrus SASL client using the DIGEST-MD5 plugin or HTTP Digest authentication. Exposure occurs when that client connects to an attacker-controlled server or peer, or when an on-path attacker can supply a crafted authentication challenge.
What does an attacker need to exploit it?
No client privileges are required, but the attacker must be able to act as a malicious DIGEST-MD5 or HTTP Digest server or peer, or interfere with the authentication exchange on path. The crafted challenge contains fields such as a realm or nonce with many characters that require escaping when quoted.
What is the likely impact on a vulnerable client?
The crafted challenge causes an undersized heap buffer to be written with strcat(), producing an attacker-controlled out-of-bounds write. The most likely result is a client application crash, although the reported impact includes potential compromise of the client.
What can be done if an update cannot be applied immediately?
Avoid using DIGEST-MD5 or HTTP Digest authentication with untrusted servers or peers. Restrict connections to trusted authentication endpoints and prevent on-path modification of authentication exchanges where possible.