Bug 515617 - perl panic caused by large integer in precision for POSIX::sprintf
Summary: perl panic caused by large integer in precision for POSIX::sprintf
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: perl
Version: 25
Hardware: All
OS: Linux
low
high
Target Milestone: ---
Assignee: Jitka Plesnikova
QA Contact: Fedora Extras Quality Assurance
URL: http://rt.perl.org/rt3/Public/Bug/Dis...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-08-05 00:30 UTC by David Dick
Modified: 2017-11-20 09:30 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2017-11-20 09:30:09 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 174683 0 medium CLOSED CVE-2005-3962 Perl integer overflow issue 2021-02-22 00:41:40 UTC

Description David Dick 2009-08-05 00:30:08 UTC
Description of problem:

perl panics if large number is used in the format section for sprintf.

Version-Release number of selected component (if applicable):


How reproducible:

Steps to Reproduce:
$ perl -MPOSIX -e 'POSIX::sprintf("%.2147483640f", 1);'
  
Actual results:

panic: malloc at ../../lib/POSIX.pm (autosplit into ../../lib/auto/POSIX/sprintf.al) line 387

Expected results:

exits with a zero

Additional info:

perl also seems to hang for a long time with using the slightly smaller number of 214748369

Comment 1 Josh Bressers 2009-08-06 20:07:01 UTC
This problem appears to go all the way back to RHEL3.

I'm not completely certain if this should be called a security flaw, as it's very dangerous to use arbitrary user input as part of a format string. Allowing arbitrary user input could quite likely be considered a flaw in itself.

Comment 2 Marcela Mašláňová 2009-09-14 13:36:44 UTC
Upstream ticket created.

Comment 3 Bug Zapper 2010-04-28 09:33:56 UTC
This message is a reminder that Fedora 11 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 11.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '11'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 11's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 11 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 4 David Dick 2010-05-26 01:11:13 UTC
This issue is recorded as CVE-2005-3962 and recorded as fixed by redhat in Bug 174683.  Could you take that patch and apply it to fedora?

Comment 5 Marcela Mašláňová 2010-07-15 11:11:22 UTC
I'd like to close it as solved in next releases because in F-13 with perl-5.10.1-112.fc13.i686 it's solved.

perl -MPOSIX -e 'POSIX::sprintf("%.2147483640f", 1);'
Out of memory!

Comment 6 David Dick 2010-07-15 13:07:53 UTC
Interesting.  It still fails on my fedora 13.

$ rpm -q perl
perl-5.10.1-112.fc13.i686
$ /usr/bin/perl -MPOSIX -e 'POSIX::sprintf("%.2147483640f", 1);'
panic: snprintf buffer overflow at ../../lib/POSIX.pm (autosplit into ../../lib/auto/POSIX/sprintf.al) line 387.

have you got similar readings for the sprintf.al file?

$ ls -la /usr/lib/perl5/auto/POSIX/sprintf.al
-rw-r--r-- 1 root root 338 Mar  7 17:03 /usr/lib/perl5/auto/POSIX/sprintf.al
$ md5sum /usr/lib/perl5/auto/POSIX/sprintf.al
17b07c02a407ab2778db1a9b2352a996  /usr/lib/perl5/auto/POSIX/sprintf.al
$ rpm -qf /usr/lib/perl5/auto/POSIX/sprintf.al
perl-5.10.1-112.fc13.i686

and finally 

$ rpm -V perl
$

i think that means my perl installation is sound. any ideas on what is happening?

Comment 7 Marcela Mašláňová 2010-07-15 13:31:51 UTC
I have the same data as you. I'll try on different machines.

Comment 8 Vincent Danen 2010-07-15 15:54:49 UTC
I've just tried it here, and on RHEL6 I get the "out of memory" exit as well.  I suspect this is due to not having much RAM in my VM (756MB RAM, 512MB swap).  I tried it on my RHEL5 box (8GB physical RAM) and it happily chewed up all the RAM and a whole lot of CPU before zsh eventually killed it.

% /usr/bin/perl -MPOSIX -e 'POSIX::sprintf("%.2147483640f", 1);'
zsh: killed     /usr/bin/perl -MPOSIX -e 'POSIX::sprintf("%.2147483640f", 1);'

However it does exit with a panic on my F13 box (also 8GB RAM):

% /usr/bin/perl -MPOSIX -e 'POSIX::sprintf("%.2147483640f", 1);'              
panic: snprintf buffer overflow at ../../lib/POSIX.pm (autosplit into ../../lib/auto/POSIX/sprintf.al) line 387.

I think this is a different issue than the CVE-2005-3692 however, unless it has regressed.  On RHEL3 it exits quickly (VM with 512MB RAM):

% /usr/bin/perl -MPOSIX -e 'POSIX::sprintf("%.2147483640f", 1);'
panic: malloc at ../../lib/POSIX.pm (autosplit into ../../lib/auto/POSIX/sprintf.al) line 367.

Comment 9 David Dick 2010-07-17 10:34:39 UTC
I had 4Gb of RAM for my f13 test if that helps.

Comment 10 Marcela Mašláňová 2010-07-20 15:34:41 UTC
This issue is public in rt [1], where can anyone access. Could you remove security tag? Or I can sum up our discussion and post it there.

I also believe this is a different issue than CVE-2005-369. 

None of my computers have more than 2M RAM, so that might be the reason, why I can't reproduce it. The different error on RHEL-5 and F-13 is given by perl release.

[1] http://rt.perl.org/rt3/Public/Bug/Display.html?id=68764

Comment 11 Vincent Danen 2010-07-20 17:37:56 UTC
Wow, that's an old bug and has been public for a long time.  There's no reason to keep this private.

Comment 12 Bug Zapper 2010-11-04 10:35:47 UTC
This message is a reminder that Fedora 12 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 12.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '12'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 12's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 12 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 13 Marcela Mašláňová 2010-11-04 16:30:56 UTC
This issue still wasn't resolved.

Comment 14 Petr Pisar 2011-10-04 16:38:37 UTC
I don't believe this is CVE-2005-3962. The %n is checked for current Perl already (the tests from <http://use.perl.org/article.pl?sid=05/12/15/0916221> patch set are part of standard test suite of perl package run at RPM package build time).

The message "panic: snprintf buffer overflow" comes from perl.h:1666 (Perl 5.14) where following macro is defined (formatted by me):

#define my_snprintf(buffer, len, ...) \
({ int __len__ = snprintf(buffer, len, __VA_ARGS__); \
   if ((len) > 0 && (Size_t)__len__ >= (len)) \
     Perl_croak_nocontext("panic: snprintf buffer overflow");\
   __len__; })

Thus it just says the requested string could not fit into buffer (see snprintf(3)). And dies.

So the problem is why buffer has not been preallocated large enough and `len' set to the length to accommodate the string.

Comment 17 Fedora End Of Life 2013-04-03 20:10:20 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19

Comment 18 Fedora Admin XMLRPC Client 2013-08-12 11:49:21 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 19 Fedora End Of Life 2015-01-09 21:40:15 UTC
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 20 Fedora End Of Life 2015-05-29 08:36:03 UTC
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '20'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 20 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 21 Fedora End Of Life 2015-11-04 15:30:01 UTC
This message is a reminder that Fedora 21 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 21. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '21'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 21 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 22 Petr Pisar 2015-11-04 16:05:10 UTC
perl-5.20.3-328.fc22.x86_64 has different error message:

$ perl -MPOSIX -e 'POSIX::sprintf("%.2147483640f", 1);'
panic: snprintf buffer overflow at /usr/lib64/perl5/POSIX.pm line 233.

Comment 23 Jitka Plesnikova 2016-05-23 11:11:48 UTC
perl-5.24.0-363.fc25 has the same error message

Comment 24 Jan Kurik 2016-07-26 04:26:36 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 25 development cycle.
Changing version to '25'.

Comment 25 Fedora End Of Life 2017-11-16 18:55:23 UTC
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '25'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 26 Petr Pisar 2017-11-20 09:30:09 UTC
This can be reduced to:

$ perl -e 'sprintf("%.2147483640f", 1);'
panic: snprintf buffer overflow at -e line 1.

The error message basically says arguments to be passed to libc's sprintf() would cause a buffer overflow and thus Perl interpreter will rather abort than continue.

So this is an intended behavior.

One could argue that Perl could invoke an exception instead that would be catchable or use better wording for the error message. But this up to the Perl authors.


Note You need to log in before you can comment on or make changes to this bug.