Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null byte on command line on Debian #269

Closed
daxim opened this issue Jun 27, 2013 · 9 comments
Closed

Null byte on command line on Debian #269

daxim opened this issue Jun 27, 2013 · 9 comments

Comments

@daxim
Copy link
Contributor

daxim commented Jun 27, 2013

Security researchers have found crash bugs in perl5i as shipped in Debian Wheezy using Mayhem, an automated bug finding tool. http://lists.debian.org/debian-devel/2013/06/msg00720.html I have started communication with the Mayhem team in order to "short-circuit" the middle-men maintainers and get the details (the buggy command-line input, backtrace after crash, etc.) ASAP.

Is there any need to keep the details confidential until the underlying bugs are fixed? If not, I'll publish them just here.

@daxim
Copy link
Contributor Author

daxim commented Jun 27, 2013

Details are available at http://www.forallsecure.com/bug-reports/79c31f70848a65002493a88828e05970c3e75c1a/. The input there is a bit more complicated than actually needed to trigger the crash. It boils down to a null byte on the command-line:

perl5i \000 -e

Program received signal SIGSEGV, Segmentation fault.
__strlen_sse2 () at ../sysdeps/x86_64/strlen.S:31
(gdb) bt full
#0  __strlen_sse2 () at ../sysdeps/x86_64/strlen.S:31
No locals.
#1  0x00007ffff7a99e9e in __GI__IO_fputs (str=str@entry=0x0, fp=fp@entry=0x603070) at iofputs.c:36
        len = <optimized out>
        result = <optimized out>
#2  0x0000000000400a17 in main (argc=3, argv=0x7fffffffd8c8) at bin/perl5i.c:76
        tempfile = "/tmp/perl5i.xBStkm"
        fd = <optimized out>
        fh = 0x603070
        i = 4
        j = 3
        perl_cmd = 0x400c88 "/home/daxim/local/share/perlbrew/perls/perl-5.16.3/bin/perl"
        perl_args = {0x400c88 "/home/daxim/local/share/perlbrew/perls/perl-5.16.3/bin/perl", 
        0x603010 "-Mperl5i::cmd=/home/daxim/local/share/perlbrew/perls/perl-5.16.3/bin/perl5i", 0x7fffffffde1e "000", 0x0}
        dash_m = <optimized out>
        program = 0x0
        saw_dash_e = 1

perl5i.c line 76 is fprintf( fh, "%s", program );, program is 0x0.

@schwern
Copy link
Contributor

schwern commented Jun 29, 2013

I wrote bin/perl5i.c and I can tell you my C is horrible. Any help and
patching or rewrite of that code would be appreciated.

On Thu, Jun 27, 2013 at 2:13 PM, Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯
notifications@github.comwrote:

Details are available at
http://www.forallsecure.com/bug-reports/79c31f70848a65002493a88828e05970c3e75c1a/.
The input there is a bit more complicated than actually needed to trigger
the crash. It boils down to a null byte on the command-line:

perl5i \000 -e


Program received signal SIGSEGV, Segmentation fault.
__strlen_sse2 () at ../sysdeps/x86_64/strlen.S:31
(gdb) bt full
#0 __strlen_sse2 () at ../sysdeps/x86_64/strlen.S:31
No locals.
#1 0x00007ffff7a99e9e in __GI__IO_fputs (str=str@entry=0x0, fp=fp@entry=0x603070) at iofputs.c:36
len =
result =
#2 0x0000000000400a17 in main (argc=3, argv=0x7fffffffd8c8) at bin/perl5i.c:76
tempfile = "/tmp/perl5i.xBStkm"
fd =
fh = 0x603070
i = 4
j = 3
perl_cmd = 0x400c88 "/home/daxim/local/share/perlbrew/perls/perl-5.16.3/bin/perl"
perl_args = {0x400c88 "/home/daxim/local/share/perlbrew/perls/perl-5.16.3/bin/perl",
0x603010 "-Mperl5i::cmd=/home/daxim/local/share/perlbrew/perls/perl-5.16.3/bin/perl5i", 0x7fffffffde1e "000", 0x0}
dash_m =
program = 0x0
saw_dash_e = 1


perl5i.c line 76 is fprintf( fh, "%s", program );, program is 0x0.


Reply to this email directly or view it on GitHubhttps://github.com//issues/269#issuecomment-20155376
.

rurban pushed a commit to rurban/perl5i that referenced this issue Jul 14, 2013
fix dash_m init,
simplify dash_e logic (only -e, no -M)
schwern added a commit that referenced this issue Jul 23, 2014
Fix perl5i.c #269 to avoid crash on a null byte in the command line.
@schwern
Copy link
Contributor

schwern commented Jul 23, 2014

Fixed by #273

@schwern schwern closed this as completed Jul 23, 2014
@schwern schwern mentioned this issue Jul 23, 2014
@rurban
Copy link
Contributor

rurban commented Jul 23, 2014

thanks. yes, only mayhem brought me to this :)

@carnil
Copy link

carnil commented Jul 23, 2014

Hi!

On Wed, Jul 23, 2014 at 12:38:56PM -0700, Reini Urban wrote:

thanks. yes, only mayhem brought me to this :)

Is this really fixed with new upstream version 2.13.0?

With the reproducer

$ perl5i \000 -e

still get a Segemntation fault.

(this is on Debian unstable, built 2.13.0, but had no further time to
investigate).

Regards,
Salvatore

@schwern schwern reopened this Jul 23, 2014
@schwern schwern changed the title Debian crash bugs (Mayhem) Null byte on command line on Debian Jul 23, 2014
@schwern
Copy link
Contributor

schwern commented Jul 23, 2014

I cannot reproduce this on OS X, fwiw, with either 2.12.0 or 2.13.0. perl -e 'system "perl5i \x{00} -e"' acts equivalent to perl5i (it waits for code on stdin).

@xtaran
Copy link

xtaran commented Feb 6, 2015

perl -e 'system "perl5i \x{00} -e"' seems not the correct way to reproduce it. I cannot reproduce it in Debian Testing (currently having 2.13.0) with that commandline, but I can reproduce it with perl5i \000 -e and inside Perl's system() with perl -e 'system("perl5i \\000 -e");'

@schwern
Copy link
Contributor

schwern commented Feb 7, 2015

I can reproduce it on Wheezy/Sid with Perl 5.20.1.

@schwern
Copy link
Contributor

schwern commented Feb 7, 2015

I have it. It was just perl5i -e. It wouldn't check there was an argument after the -e, would read one too far on argv, and then try to printf that.

schwern added a commit that referenced this issue Feb 7, 2015
It would walk off argv and then try to printf garbage (probably null).

For #269
@schwern schwern closed this as completed Feb 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants