From 682fd21afb5428b5716e62eaefb09a7419f9cfd7 Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Thu, 30 Nov 2023 14:28:09 -0500 Subject: Detect and prevent recursive config parsing If a malformed config file is provided such as the following: openssl_conf = openssl_init [openssl_init] providers = provider_sect [provider_sect] = provider_sect The config parsing library will crash overflowing the stack, as it recursively parses the same provider_sect ad nauseum. Prevent this by maintaing a list of visited nodes as we recurse through referenced sections, and erroring out in the event we visit any given section node more than once. Note, adding the test for this revealed that our diagnostic code inadvertently pops recorded errors off the error stack because provider_conf_load returns success even in the event that a configuration parse failed. The call path to provider_conf_load has been updated in this commit to address that shortcoming, allowing recorded errors to be visibile to calling applications. Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/22898) --- test/recursive.cnf | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 test/recursive.cnf (limited to 'test/recursive.cnf') diff --git a/test/recursive.cnf b/test/recursive.cnf new file mode 100644 index 0000000..505733a --- /dev/null +++ b/test/recursive.cnf @@ -0,0 +1,8 @@ +openssl_conf = openssl_init +config_diagnostics = yes + +[openssl_init] +providers = provider_sect + +[provider_sect] + = provider_sect -- cgit v1.1