From 622b0325a548c79bd0dcee7c405ccc42de018bba Mon Sep 17 00:00:00 2001 From: CPANSec Security Scanner Bot Date: Tue, 24 Nov 2026 14:30:03 +0000 Subject: [PATCH] Net::Server::HTTP: always exit the exec_trusted_perl child exec_trusted_perl forks and the child loads the script with require. When the script died before any header was sent, the child re-threw the error instead of reaching its exit. The error unwound into the request handler the child had inherited from the worker, which sent a 500 response and returned to the accept loop. The child then carried on as an extra worker that the server had never forked and did not count or signal, past max_servers and after the server was stopped, and it failed later requests for the same script because the failed require is not retried. Log the error and send the 500 response from the child itself, as process_request would have done, and then fall through to the exit. The client still receives the same 500 response, and the parent's waitpid returns as soon as the child has exited. Notes for deciding whether to apply this patch: - The error from a script that dies before sending headers is now logged by the forked child instead of the worker. The client receives the same 500 response. - Not tested on a running server. It was checked by review and by applying it to Net-Server 2.018. - Applies on its own to Net-Server 2.018, and together with the other CPANSec patches for Net-Server 2.018 when they are applied in CVE-ID order. --- lib/Net/Server/HTTP.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Net/Server/HTTP.pm b/lib/Net/Server/HTTP.pm index d186e06..5f0b86e 100644 --- a/lib/Net/Server/HTTP.pm +++ b/lib/Net/Server/HTTP.pm @@ -633,8 +633,12 @@ sub exec_trusted_perl { if (!eval { require $file }) { my $err = "$@" || "Error while running trusted perl script\n"; $err =~ s{\s*Compilation failed in require at lib/Net/Server/HTTP\.pm line \d+\.\s*\z}{\n}; - die $err if !$self->{'request_info'}->{'headers_sent'}; - warn $err; + if (!$self->{'request_info'}->{'headers_sent'}) { # report here: the child must exit, not return to the server loop + $self->log(1, $err); + eval { $self->send_500($err) }; + } else { + warn $err; + } } exit; } else { -- 2.53.0