Open p5pRT opened 5 years ago
While fuzzing perl v5.29.8-21-gde59f38ed9 built with afl and run under libdislocator\, I found the following program
s\,(?{0=qr{(?{{}])}};{}})\,\,
to perform an access outside of an allocated memory slot. ASAN diagnostics are:
==22697==ERROR: AddressSanitizer: heap-use-after-free on address 0x619000001c68 at pc 0x00000050f74d bp 0x7ffe9e708ec0 sp 0x7ffe9e708eb8 READ of size 2 at 0x619000001c68 thread T0 #0 0x50f74c in Perl_op_free /home/afl/afl-asan/op.c:888:27 #1 0x710f5e in Perl_yyparse /home/afl/afl-asan/perly.c:499:25 #2 0x5ebb7a in S_parse_body /home/afl/afl-asan/perl.c:2507:9 #3 0x5e1f33 in perl_parse /home/afl/afl-asan/perl.c:1798:2 #4 0x50b5fe in main /home/afl/afl-asan/perlmain.c:126:10 #5 0x7f1c15ef709a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) #6 0x43bde9 in _start (/home/afl/afl-asan/perl+0x43bde9)
0x619000001c68 is located 744 bytes inside of 1024-byte region [0x619000001980\,0x619000001d80) freed by thread T0 here: #0 0x4da220 in __interceptor_cfree.localalias.0 (/home/afl/afl-asan/perl+0x4da220) #1 0x50dbe1 in Perl_opslab_free /home/afl/afl-asan/op.c:535:2 #2 0x50e832 in Perl_opslab_force_free /home/afl/afl-asan/op.c:582:5 #3 0x715d32 in Perl_cv_undef_flags /home/afl/afl-asan/pad.c:341:17 #4 0xa1f14a in Perl_sv_clear /home/afl/afl-asan/sv.c:6631:6 #5 0xa27897 in Perl_sv_free2 /home/afl/afl-asan/sv.c:7092:9 #6 0x70e48d in S_SvREFCNT_dec /home/afl/afl-asan/./inline.h:216:6 #7 0x70e48d in Perl_yyparse /home/afl/afl-asan/perly.c:439 #8 0x5ebb7a in S_parse_body /home/afl/afl-asan/perl.c:2507:9 #9 0x5e1f33 in perl_parse /home/afl/afl-asan/perl.c:1798:2 #10 0x50b5fe in main /home/afl/afl-asan/perlmain.c:126:10 #11 0x7f1c15ef709a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
previously allocated by thread T0 here: #0 0x4da590 in calloc (/home/afl/afl-asan/perl+0x4da590) #1 0x50c770 in S_new_slab /home/afl/afl-asan/op.c:266:30 #2 0x50c770 in Perl_Slab_Alloc /home/afl/afl-asan/op.c:372 #3 0x539488 in Perl_newUNOP /home/afl/afl-asan/op.c:6215:5 #4 0x70d6d9 in Perl_yyparse /home/afl/afl-asan/perly.y:1086:23 #5 0x5ebb7a in S_parse_body /home/afl/afl-asan/perl.c:2507:9 #6 0x5e1f33 in perl_parse /home/afl/afl-asan/perl.c:1798:2 #7 0x50b5fe in main /home/afl/afl-asan/perlmain.c:126:10 #8 0x7f1c15ef709a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
This is a regression between 5.20 and 5.22\, bisect points to
commit 9b6b7be8acad62650aa5c229e89fad6706c8a0b0 Author: Father Chrysostomos \sprout@​cpan\.org Date: Thu Jan 8 18:49:32 2015 -0800
Simplify s/// and tr/// parsing logic
These two operators were being translated into subst(""\,"") and tr(""\,"") by the lexer. Then pmruntime in op.c would take apart the resulting list op. Instead of constructing a list op only to take it apart again\, feed the replacement part to pmruntime separately. We can achieve this by introducing a new token ('/') that the parser rec- ognizes as introducing a replacement.
If we had followed this approach to begin with\, then bug #123542 would never have happened.
On Tue\, 12 Mar 2019 09:44:20 -0700\, randir wrote:
While fuzzing perl v5.29.8-21-gde59f38ed9 built with afl and run under libdislocator\, I found the following program
s\,(?{0=qr{(?{{}])}};{}})\,\,
to perform an access outside of an allocated memory slot. ASAN diagnostics are:
==22697==ERROR: AddressSanitizer: heap-use-after-free on address 0x619000001c68 at pc 0x00000050f74d bp 0x7ffe9e708ec0 sp 0x7ffe9e708eb8 READ of size 2 at 0x619000001c68 thread T0 #0 0x50f74c in Perl_op_free /home/afl/afl-asan/op.c:888:27 #1 0x710f5e in Perl_yyparse /home/afl/afl-asan/perly.c:499:25 #2 0x5ebb7a in S_parse_body /home/afl/afl-asan/perl.c:2507:9 #3 0x5e1f33 in perl_parse /home/afl/afl-asan/perl.c:1798:2 #4 0x50b5fe in main /home/afl/afl-asan/perlmain.c:126:10 #5 0x7f1c15ef709a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) #6 0x43bde9 in _start (/home/afl/afl-asan/perl+0x43bde9)
0x619000001c68 is located 744 bytes inside of 1024-byte region [0x619000001980\,0x619000001d80) freed by thread T0 here: #0 0x4da220 in __interceptor_cfree.localalias.0 (/home/afl/afl-asan/perl+0x4da220) #1 0x50dbe1 in Perl_opslab_free /home/afl/afl-asan/op.c:535:2 #2 0x50e832 in Perl_opslab_force_free /home/afl/afl- asan/op.c:582:5 #3 0x715d32 in Perl_cv_undef_flags /home/afl/afl-asan/pad.c:341:17 #4 0xa1f14a in Perl_sv_clear /home/afl/afl-asan/sv.c:6631:6 #5 0xa27897 in Perl_sv_free2 /home/afl/afl-asan/sv.c:7092:9 #6 0x70e48d in S_SvREFCNT_dec /home/afl/afl-asan/./inline.h:216:6 #7 0x70e48d in Perl_yyparse /home/afl/afl-asan/perly.c:439 #8 0x5ebb7a in S_parse_body /home/afl/afl-asan/perl.c:2507:9 #9 0x5e1f33 in perl_parse /home/afl/afl-asan/perl.c:1798:2 #10 0x50b5fe in main /home/afl/afl-asan/perlmain.c:126:10 #11 0x7f1c15ef709a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
previously allocated by thread T0 here: #0 0x4da590 in calloc (/home/afl/afl-asan/perl+0x4da590) #1 0x50c770 in S_new_slab /home/afl/afl-asan/op.c:266:30 #2 0x50c770 in Perl_Slab_Alloc /home/afl/afl-asan/op.c:372 #3 0x539488 in Perl_newUNOP /home/afl/afl-asan/op.c:6215:5 #4 0x70d6d9 in Perl_yyparse /home/afl/afl-asan/perly.y:1086:23 #5 0x5ebb7a in S_parse_body /home/afl/afl-asan/perl.c:2507:9 #6 0x5e1f33 in perl_parse /home/afl/afl-asan/perl.c:1798:2 #7 0x50b5fe in main /home/afl/afl-asan/perlmain.c:126:10 #8 0x7f1c15ef709a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
This is a regression between 5.20 and 5.22\, bisect points to
commit 9b6b7be8acad62650aa5c229e89fad6706c8a0b0 Author: Father Chrysostomos \sprout@​cpan\.org Date: Thu Jan 8 18:49:32 2015 -0800
Simplify s/// and tr/// parsing logic
These two operators were being translated into subst(""\,"") and tr(""\,"") by the lexer. Then pmruntime in op.c would take apart the resulting list op. Instead of constructing a list op only to take it apart again\, feed the replacement part to pmruntime separately. We can achieve this by introducing a new token ('/') that the parser rec- ognizes as introducing a replacement.
If we had followed this approach to begin with\, then bug #123542 would never have happened.
This happens while parsing code fed to the interpreter\, so isn't a security issue under our usual criteria.
Tony
The RT System itself - Status changed from 'new' to 'open'
On Tue\, Apr 16\, 2019 at 09:59:40PM -0700\, Tony Cook via RT wrote:
On Tue\, 12 Mar 2019 09:44:20 -0700\, randir wrote:
While fuzzing perl v5.29.8-21-gde59f38ed9 built with afl and run under libdislocator\, I found the following program
s\,(?{0=qr{(?{{}])}};{}})\,\,
to perform an access outside of an allocated memory slot. ASAN diagnostics are:
This happens while parsing code fed to the interpreter\, so isn't a security issue under our usual criteria.
I've now moved this ticket to the public queue
-- The Enterprise is captured by a vastly superior alien intelligence which does not put them on trial. -- Things That Never Happen in "Star Trek" #10
Migrated from rt.perl.org#133925 (status was 'open')
Searchable as RT133925$