mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Abandon the use of Perl's Safe.pm to enforce restrictions in plperl, as it is
fundamentally insecure. Instead apply an opmask to the whole interpreter that imposes restrictions on unsafe operations. These restrictions are much harder to subvert than is Safe.pm, since there is no container to be broken out of. Backported to release 7.4. In releases 7.4, 8.0 and 8.1 this also includes the necessary backporting of the two interpreters model for plperl and plperlu adopted in release 8.2. In versions 8.0 and up, the use of Perl's POSIX module to undo its locale mangling on Windows has become insecure with these changes, so it is replaced by our own routine, which is also faster. Nice side effects of the changes include that it is now possible to use perl's "strict" pragma in a natural way in plperl, and that perl's $a and $b variables now work as expected in sort routines, and that function compilation is significantly faster. Tim Bunce and Andrew Dunstan, with reviews from Alex Hunsaker and Alexey Klyukin. Security: CVE-2010-1169
This commit is contained in:
@ -368,7 +368,16 @@ DO $$
|
||||
$$ LANGUAGE plperl;
|
||||
|
||||
-- check that restricted operations are rejected in a plperl DO block
|
||||
DO $$ eval "1+1"; $$ LANGUAGE plperl;
|
||||
DO $$ system("/nonesuch"); $$ LANGUAGE plperl;
|
||||
DO $$ qx("/nonesuch"); $$ LANGUAGE plperl;
|
||||
DO $$ open my $fh, "</nonesuch"; $$ LANGUAGE plperl;
|
||||
|
||||
-- check that eval is allowed and eval'd restricted ops are caught
|
||||
DO $$ eval q{chdir '.'}; warn "Caught: $@"; $$ LANGUAGE plperl;
|
||||
|
||||
-- check that compiling do (dofile opcode) is allowed
|
||||
-- but that executing it for a file not already loaded (via require) dies
|
||||
DO $$ warn do "/dev/null"; $$ LANGUAGE plperl;
|
||||
|
||||
-- check that we can't "use" a module that's not been loaded already
|
||||
-- compile-time error: "Unable to load blib.pm into plperl"
|
||||
|
Reference in New Issue
Block a user