Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.99k stars 557 forks source link

Memory corruption of $1 when assigning $1 to $_ inside regex embedded code block #20580

Open florian-pe opened 1 year ago

florian-pe commented 1 year ago

A memory corruption of $1 is happening inside a regex embedded code block, during a regex match, in specific conditions :

When those conditions are met we can see garbage bytes at the start of $1 (different ones each time) and $1 vary in length each time. Even with those conditions, no memory corruption appears when we print $1 again after the match.

The bug does not appear if we assign another value than $1 to $_ or if we assign $1 to another variable than $_. The bug also does not appear if the length of the captured substring is < 1250 bytes.

Here is the golfed test .

#!/usr/bin/perl
use v5.10;

my $str = "a" x 2000;

# $str=~ m/^(.{1249})(?{ $_=$1; say $1; })/;  # no bug
$str=~ m/^(.{1250})(?{ $_=$1; say $1; })/;  # bug

say $1;  # no longer corrupted

Example output

� ?]� ?]��%O�U��%O�Uaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

I hope that this bug doesn't cause too much headeache. Florian.

Perl configuration

Summary of my perl5 (revision 5 version 36 subversion 0) configuration:

  Platform:
    osname=linux
    osvers=5.12.15-arch1-1
    archname=x86_64-linux-thread-multi
    uname='archlinux'
    config_args='-des -Dusethreads -Duseshrplib -Doptimize=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -flto -Dprefix=/usr -Dvendorprefix=/usr -Dprivlib=/usr/share/perl5/core_perl -Darchlib=/usr/lib/perl5/5.36/core_perl -Dsitelib=/usr/share/perl5/site_perl -Dsitearch=/usr/lib/perl5/5.36/site_perl -Dvendorlib=/usr/share/perl5/vendor_perl -Dvendorarch=/usr/lib/perl5/5.36/vendor_perl -Dscriptdir=/usr/bin/core_perl -Dsitescript=/usr/bin/site_perl -Dvendorscript=/usr/bin/vendor_perl -Dinc_version_list=none -Dman1ext=1perl -Dman3ext=3perl -Dcccdlflags='-fPIC' -Dlddlflags=-shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto -Dldflags=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    optimize='-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -flto'
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='12.1.0'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags ='-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-lpthread -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=/lib/../lib/libc.so.6
    so=so
    useshrplib=true
    libperl=libperl.so
    gnulibc_version='2.35'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.36/core_perl/CORE'
    cccdlflags='-fPIC'
    lddlflags='-shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto -L/usr/local/lib -fstack-protector-strong'

Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
    USE_THREAD_SAFE_LOCALE
  Built under linux
  Compiled at May 29 2022 08:49:34
  @INC:
    /usr/lib/perl5/5.36/site_perl
    /usr/share/perl5/site_perl
    /usr/lib/perl5/5.36/vendor_perl
    /usr/share/perl5/vendor_perl
    /usr/lib/perl5/5.36/core_perl
    /usr/share/perl5/core_perl
hvds commented 1 year ago

Note that the payload line should be: $str=~ m/^(.{1250})(?{ $_=$1; say $1; })/; # bug (It appeared slightly different in the emailed original, but I assume the ticket has been edited to correct it.)

With my system perl (Ubuntu, 5.26.1) I do not see a problem at 1250 characters, but I do if I increase string length to 20000 and ask for 12500 characters.

Not sure if I'll have time to investigate this, but it sounds interesting.

tonycoz commented 1 year ago
==170770== Invalid read of size 8
==170770==    at 0x483F7DF: memmove (vg_replace_strmem.c:1270)
==170770==    by 0x524B9B: Perl_sv_setpvn (sv.c:4720)
==170770==    by 0x496317: Perl_reg_numbered_buff_fetch (regcomp.c:7466)
==170770==    by 0x4DA687: Perl_magic_get (mg.c:805)
==170770==    by 0x4DF0FA: Perl_mg_get (mg.c:201)
==170770==    by 0x522344: Perl_sv_2pv_flags (sv.c:2821)
==170770==    by 0x59EF8F: Perl_do_print (doio.c:1305)
==170770==    by 0x4FB83E: Perl_pp_print (pp_hot.c:838)
==170770==    by 0x4CE2B8: Perl_runops_debug (dump.c:2427)
==170770==    by 0x5AD2BD: S_regmatch (regexec.c:5332)
==170770==    by 0x5AD2BD: S_regtry (regexec.c:3200)
==170770==    by 0x5BCCD1: Perl_regexec_flags (regexec.c:2688)
==170770==    by 0x4FDC8D: Perl_pp_match (pp_hot.c:1446)
==170770==  Address 0x4c55328 is 24 bytes inside a block of size 2,026 free'd
==170770==    at 0x48399AB: free (vg_replace_malloc.c:538)
==170770==    by 0x5105B8: Perl_sv_setsv_flags (sv.c:4489)
==170770==    by 0x4F8BF9: Perl_pp_sassign (pp_hot.c:224)
==170770==    by 0x4CE2B8: Perl_runops_debug (dump.c:2427)
==170770==    by 0x5AD2BD: S_regmatch (regexec.c:5332)
==170770==    by 0x5AD2BD: S_regtry (regexec.c:3200)
==170770==    by 0x5BCCD1: Perl_regexec_flags (regexec.c:2688)
==170770==    by 0x4FDC8D: Perl_pp_match (pp_hot.c:1446)
==170770==    by 0x4CE2B8: Perl_runops_debug (dump.c:2427)
==170770==    by 0x44CB9A: S_run_body (perl.c:2456)
==170770==    by 0x44CB9A: perl_run (perl.c:2372)
==170770==    by 0x41F636: main (perlmain.c:114)
==170770==  Block was alloc'd at
==170770==    at 0x483877F: malloc (vg_replace_malloc.c:307)
==170770==    by 0x4D0587: Perl_safesysmalloc (util.c:130)
==170770==    by 0x51E37F: Perl_sv_grow (sv.c:1595)
==170770==    by 0x51176A: Perl_sv_setsv_flags (sv.c:4525)
==170770==    by 0x4F8BF9: Perl_pp_sassign (pp_hot.c:224)
==170770==    by 0x4CE2B8: Perl_runops_debug (dump.c:2427)
==170770==    by 0x44CB9A: S_run_body (perl.c:2456)
==170770==    by 0x44CB9A: perl_run (perl.c:2372)
==170770==    by 0x41F636: main (perlmain.c:114)

My theory: Inside {?{ ... }) blocks $_ is aliased to the string being matched, the assignment here ends up assigning to $str, releasing the old PV, so $1 returns data from a freed buffer.

demerphq commented 1 year ago

On Mon, 5 Dec 2022 at 01:23, Tony Cook @.***> wrote:

==170770== Invalid read of size 8 ==170770== at 0x483F7DF: memmove (vg_replace_strmem.c:1270) ==170770== by 0x524B9B: Perl_sv_setpvn (sv.c:4720) ==170770== by 0x496317: Perl_reg_numbered_buff_fetch (regcomp.c:7466) ==170770== by 0x4DA687: Perl_magic_get (mg.c:805) ==170770== by 0x4DF0FA: Perl_mg_get (mg.c:201) ==170770== by 0x522344: Perl_sv_2pv_flags (sv.c:2821) ==170770== by 0x59EF8F: Perl_do_print (doio.c:1305) ==170770== by 0x4FB83E: Perl_pp_print (pp_hot.c:838) ==170770== by 0x4CE2B8: Perl_runops_debug (dump.c:2427) ==170770== by 0x5AD2BD: S_regmatch (regexec.c:5332) ==170770== by 0x5AD2BD: S_regtry (regexec.c:3200) ==170770== by 0x5BCCD1: Perl_regexec_flags (regexec.c:2688) ==170770== by 0x4FDC8D: Perl_pp_match (pp_hot.c:1446) ==170770== Address 0x4c55328 is 24 bytes inside a block of size 2,026 free'd ==170770== at 0x48399AB: free (vg_replace_malloc.c:538) ==170770== by 0x5105B8: Perl_sv_setsv_flags (sv.c:4489) ==170770== by 0x4F8BF9: Perl_pp_sassign (pp_hot.c:224) ==170770== by 0x4CE2B8: Perl_runops_debug (dump.c:2427) ==170770== by 0x5AD2BD: S_regmatch (regexec.c:5332) ==170770== by 0x5AD2BD: S_regtry (regexec.c:3200) ==170770== by 0x5BCCD1: Perl_regexec_flags (regexec.c:2688) ==170770== by 0x4FDC8D: Perl_pp_match (pp_hot.c:1446) ==170770== by 0x4CE2B8: Perl_runops_debug (dump.c:2427) ==170770== by 0x44CB9A: S_run_body (perl.c:2456) ==170770== by 0x44CB9A: perl_run (perl.c:2372) ==170770== by 0x41F636: main (perlmain.c:114) ==170770== Block was alloc'd at ==170770== at 0x483877F: malloc (vg_replace_malloc.c:307) ==170770== by 0x4D0587: Perl_safesysmalloc (util.c:130) ==170770== by 0x51E37F: Perl_sv_grow (sv.c:1595) ==170770== by 0x51176A: Perl_sv_setsv_flags (sv.c:4525) ==170770== by 0x4F8BF9: Perl_pp_sassign (pp_hot.c:224) ==170770== by 0x4CE2B8: Perl_runops_debug (dump.c:2427) ==170770== by 0x44CB9A: S_run_body (perl.c:2456) ==170770== by 0x44CB9A: perl_run (perl.c:2372) ==170770== by 0x41F636: main (perlmain.c:114)

My theory: Inside {?{ ... }) blocks $_ is aliased to the string being matched, the assignment here ends up assigning to $str, releasing the old PV, so $1 returns data from a freed buffer.

Wow. My brain exploded when I saw this. I had never noticed this (mis)feature before. Assigning to $ like this violates many assumptions in the regex engine. I am a bit shocked this is the only breakage related to it, although I guess most people wouldn't do this. I cannot find code to defend against malicious modification of the matched strings contents during matching so I am a little surprised we can't make horrible things happen by setting $ to an empty string or whatnot during matching. I suspect I just havent tried enough.

Anyway, this is related to COW, the difference at 1250 bytes and 1249 bytes comes from the config for when to COW a string during copy. I made the regex engine show the eval_state->sv before and after the callback and you can see that the issue involves COW, if you change the .{1250} to .{1249} the corruption in $x will go away,

$ ./perl -Ilib -MDevel::Peek -le'($s="a"x1250)=~/(.{1250})(?{ $ = $1; $x="$1."; Dump($); Dump($x)})/;' SV = PV(0x55bc98dcdff0) at 0x55bc98df4240 REFCNT = 2 FLAGS = (POK,pPOK) PV = 0x55bc98dfcae0 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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