]> git.kaiwu.me - nginx.git/commit
Perl: request object validation
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 6 Jul 2026 04:14:28 +0000 (07:14 +0300)
committerSergey Kandaurov <s.kandaurov@f5.com>
Wed, 15 Jul 2026 10:06:50 +0000 (14:06 +0400)
commitcf94d5691a895994714efc288e07b3fec3af5089
tree1f3d831a2062a9470bdf9f5adfa2c3b1371b4256
parentd9b7669666c8acaf9ec109ce6c2f16011a5a3762
Perl: request object validation

Previously, using stale request objects resulted in accesses to already
freed memory, causing segmentation faults:

    location /stale {
        perl 'sub {
            my $r = shift;
            $prev->log_error(0, "next request arrived") if $prev;
            $prev = $r;
            $r->send_http_header;
            return OK;
        }';
    }

Similarly, incorrectly blessed objects might cause segmentation faults,
such as in the following configuration:

    location /bless {
        perl 'sub {
            my $v = 10;
            my $r = bless \$v, "nginx";
            $r->send_http_header;
            return OK;
        }';
    }

With this change, active request object is recorded in the
ngx_http_perl_call_handler() function, and checked by
ngx_http_perl_set_request() to prevent use of unexpected request
objects.

Reported by Axel Mierczuk, Keith Hoodlet, 1Password’s Off-by-1 Labs.

Signed-off-by: Sergey Kandaurov <pluknet@nginx.com>
Origin: https://freenginx.org/hg/nginx/rev/86a2685756ae
src/http/modules/perl/nginx.xs
src/http/modules/perl/ngx_http_perl_module.c
src/http/modules/perl/ngx_http_perl_module.h