BUG/MEDIUM: ssl: Fix crash in ocsp-update log function
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Wed, 20 Mar 2024 13:13:35 +0000 (14:13 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Wed, 20 Mar 2024 15:12:10 +0000 (16:12 +0100)
commitd4e3be18df73a4f15b7b609d00f1d036f7ab7f81
tree7c6adaed01907954524f29e1e5ca4fb9e0cde20f
parent5c25c577a0655be078079920e7702488fe1f99e5
BUG/MEDIUM: ssl: Fix crash in ocsp-update log function

The ocsp-update logging mechanism was built around the 'sess_log'
function which required to keep a pointer to the said session until the
logging function could be called. This was made by keeping a pointer to
the appctx returned by the 'httpclient_start' function. But this appctx
lives its life on its own and might be destroyed before
'ssl_ocsp_send_log' is called, which could result in a crash (UAF).
Fixing this crash requires to stop using the 'sess_log' function to emit
the ocsp-update logs. The log line will then need to be built by hand
out of the information actually available when 'ssl_ocsp_send_log' is
called. Since we don't use the "regular" logging functions anymore, we
don't need to use the error_logformat anymore. In order to keep a
consistent behavior than before, we will keep the same format for the
logs but replace the fields that required a 'sess' pointer by fake
values (the %ci:%cp for instance, which was never filled anyway).

This crash was raised in GitHub issue #2442.
It should be backported up to branch 2.8.
src/ssl_ocsp.c