From: Remi Tricot-Le Breton Date: Thu, 19 Nov 2026 15:44:03 +0000 (+0100) Subject: BUG/MINOR: ocsp: fix NULL dereference when the OCSP responder sends no header X-Git-Url: https://git.kaiwu.me/http/%7B@url%7D?a=commitdiff_plain;h=d4c0c5fdada7058f77667f913b6394b8beabc6af;p=haproxy.git BUG/MINOR: ocsp: fix NULL dereference when the OCSP responder sends no header Both OCSP response handlers look for a "Content-Type" header in the response received from the responder by iterating over hc->res.hdrs until they reach the end-of-array marker. But this array is only allocated when the response contains at least one header so the array may be NULL. This is reachable in production as soon as the OCSP auto-update is enabled. Any responder which answers with a header-less HTTP/1.0 response (a plain error page, a minimal embedded server, a proxy that strips the headers) crashes the worker. The same issue applies to the client-certificate OCSP check used by the "do-ocsp-request" action, where the request is sent to the URI found in the client certificate. This patch must be backported to 3.3. --- diff --git a/src/ssl_ocsp.c b/src/ssl_ocsp.c index e7355835a..d16b37c34 100644 --- a/src/ssl_ocsp.c +++ b/src/ssl_ocsp.c @@ -1333,7 +1333,7 @@ static struct task *ssl_ocsp_update_responses(struct task *task, void *context, int found = 0; /* Look for "Content-Type" header which should have * "application/ocsp-response" value. */ - for (hdr = hc->res.hdrs; isttest(hdr->v); hdr++) { + for (hdr = hc->res.hdrs; hdr && isttest(hdr->n); hdr++) { if (isteqi(hdr->n, ist("Content-Type")) && isteqi(hdr->v, ist("application/ocsp-response"))) { found = 1; @@ -1942,7 +1942,7 @@ int ssl_ocsp_check_ocsp_response(struct ocsp_clt_check_ctx *ctx) /* Look for "Content-Type" header which should have * "application/ocsp-response" value. */ - for (hdr = hc->res.hdrs; isttest(hdr->v); hdr++) { + for (hdr = hc->res.hdrs; hdr && isttest(hdr->n); hdr++) { if (isteqi(hdr->n, ist("Content-Type")) && isteqi(hdr->v, ist("application/ocsp-response"))) { found = 1;