]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: acme: NUL terminate response buffer before PEM parsing
authorCyberpsychoJacob <gizardglazeman@gmail.com>
Fri, 15 May 2026 07:27:15 +0000 (11:27 +0400)
committerWilly Tarreau <w@1wt.eu>
Sat, 23 May 2026 16:09:59 +0000 (18:09 +0200)
commit4db85fc53e067c43acc45d3786e91fd5e63c7c9e
tree1c53d607e31e2cf7f2731f805b77f08ff0c80fd7
parent41bb1c24f6eff46ce9cf83c1b64963056506bf95
BUG/MEDIUM: acme: NUL terminate response buffer before PEM parsing

acme_res_certificate() passes the httpclient response buffer to
ssl_sock_load_pem_into_ckch(), which will then call BIO_new_mem_buf(buf, -1).
The "-1" flag will make the OpenSSL PEM parser determine the length by
using strlen(). However, the httpclient populates the response buffer with
__b_putblk() without writing a trailing NUL to it. The byte at area[data]
is whatever data previously resided there in the memory pool.

Thus, a malicious or compromised ACME CA can perform an arbitrary-length
out-of-bounds read until hitting the first NULL byte past the response
body. The OpenSSL PEM loader will try to iterate to load the chain
certificates, thus the PEM-looking garbage found in freed memory chunks
can be erroneously loaded as additional intermediate certificates. The
presence of a single NUL inside the valid response body will result in
silent truncation of the certificate.

Make sure that the area[data] contains a terminating NULL before passing
the buffer to the parser. Fail on insufficient room for the NUL terminator.

No backport required: The ACME client has been added in 3.x and this
code path didn't exist in 2.x.
src/acme.c