Bug 22960 - boost new integer overflow security issue
Summary: boost new integer overflow security issue
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: Security (show other bugs)
Version: 6
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: QA Team
QA Contact: Sec team
URL:
Whiteboard: MGA6-64-OK
Keywords: advisory, validated_update
Depends on:
Blocks:
 
Reported: 2018-04-27 18:49 CEST by David Walser
Modified: 2018-05-04 19:30 CEST (History)
4 users (show)

See Also:
Source RPM: boost-1.60.0-6.mga6.src.rpm
CVE:
Status comment:


Attachments
PoC to demonstrate regex integer overflow (884 bytes, text/plain)
2018-04-30 11:01 CEST, Len Lawrence
Details
Two simple utility test files (528 bytes, application/octet-stream)
2018-04-30 11:03 CEST, Len Lawrence
Details

Description David Walser 2018-04-27 18:49:07 CEST
Fedora has issued an advisory today (April 27):
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/thread/342ZTGQCOLK4EMJYROXHMDXITBWJISIU/

The upstream ticket and patch are linked from the RedHat bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1564252
Comment 1 Marja Van Waes 2018-04-27 21:21:06 CEST
Assigning to the registered maintainer.

CC: (none) => marja11
Assignee: bugsquad => shlomif

Stig-Ørjan Smelror 2018-04-28 22:47:27 CEST

Assignee: shlomif => smelror
CC: (none) => smelror

Comment 2 Stig-Ørjan Smelror 2018-04-28 23:06:41 CEST
Advisory
========

A new, potential integer overflow security issue was discovered in Boost.Regex.

This update uses a patch from Boost that fixes this potential issue.


References
==========
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/thread/342ZTGQCOLK4EMJYROXHMDXITBWJISIU/
https://bugzilla.redhat.com/show_bug.cgi?id=1564252
https://svn.boost.org/trac10/ticket/13036


Files
=====

Uploaded to 6/core/updates_testing

boost-build-1.60.0-6.1.mga6
boost-devel-doc-1.60.0-6.1.mga6
boost-examples-1.60.0-6.1.mga6
boost-bjam-1.60.0-6.1.mga6
boost-debuginfo-1.60.0-6.1.mga6
boost-doctools-1.60.0-6.1.mga6
lib64boost_atomic1.60.0-1.60.0-6.1.mga6
lib64boost_chrono1.60.0-1.60.0-6.1.mga6
lib64boost_container1.60.0-1.60.0-6.1.mga6
lib64boost_context1.60.0-1.60.0-6.1.mga6
lib64boost_coroutine1.60.0-1.60.0-6.1.mga6
lib64boost_date_time1.60.0-1.60.0-6.1.mga6
lib64boost-devel-1.60.0-6.1.mga6
lib64boost_filesystem1.60.0-1.60.0-6.1.mga6
lib64boost_graph1.60.0-1.60.0-6.1.mga6
lib64boost-graph-mpi1.60.0-1.60.0-6.1.mga6
lib64boost-graph-mpich1.60.0-1.60.0-6.1.mga6
lib64boost_iostreams1.60.0-1.60.0-6.1.mga6
lib64boost_locale1.60.0-1.60.0-6.1.mga6
lib64boost_log1.60.0-1.60.0-6.1.mga6
lib64boost_math1.60.0-1.60.0-6.1.mga6
lib64boost-mpich1.60.0-1.60.0-6.1.mga6
lib64boost-mpich-devel-1.60.0-6.1.mga6
lib64boost-mpich-python1.60.0-1.60.0-6.1.mga6
lib64boost-mpi-python1.60.0-1.60.0-6.1.mga6
lib64boost-openmpi1.60.0-1.60.0-6.1.mga6
lib64boost-openmpi-devel-1.60.0-6.1.mga6
lib64boost_prg_exec_monitor1.60.0-1.60.0-6.1.mga6
lib64boost_program_options1.60.0-1.60.0-6.1.mga6
lib64boost_python1.60.0-1.60.0-6.1.mga6
lib64boost-python3_1.60.0-1.60.0-6.1.mga6
lib64boost_random1.60.0-1.60.0-6.1.mga6
lib64boost_regex1.60.0-1.60.0-6.1.mga6
lib64boost_serialization1.60.0-1.60.0-6.1.mga6
lib64boost_signals1.60.0-1.60.0-6.1.mga6
lib64boost-static-devel-1.60.0-6.1.mga6
lib64boost_system1.60.0-1.60.0-6.1.mga6
lib64boost_thread1.60.0-1.60.0-6.1.mga6
lib64boost_timer1.60.0-1.60.0-6.1.mga6
lib64boost_type_erasure1.60.0-1.60.0-6.1.mga6
lib64boost_unit_test_framework1.60.0-1.60.0-6.1.mga6
lib64boost_wave1.60.0-1.60.0-6.1.mga6
lib64boost_wserialization1.60.0-1.60.0-6.1.mga6

from boost-1.60.0-6.1.src.rpm

Assignee: smelror => qa-bugs

Comment 3 Len Lawrence 2018-04-30 03:07:32 CEST
Mageia 6, x86_64

Several boost 1.60 packages already installed.  Added those that were missing to ensure all files were in place before updating.

The howto documentation at https://www.boost.org/doc/libs/1_64_0/more/getting_started/unix-variants.html looks pretty clear so I shall check the completeness of the installation and try out the simple starter examples then update.

There are reproducers from RedHat (Cuda 9) and the Boost site for two issues.
@Stig: If I read this correctly the update addresses the second one only.  Is that correct?

Continuing later.

CC: (none) => tarazed25

Comment 4 Stig-Ørjan Smelror 2018-04-30 07:02:56 CEST
Len,

Yes, this update only contains the fix for the integer overflow and not the fix for CUDA.

Cheers,
Stig
Comment 5 Len Lawrence 2018-04-30 10:59:18 CEST
Thanks Stig.

Google quote:
"Boost is a set of libraries for the C++ programming language that provide support for tasks and structures such as linear algebra, pseudorandom number generation, multithreading, image processing, regular expressions, and unit testing. It contains over eighty individual libraries."

*Tests before updating*

PoC at https://svn.boost.org/trac10/ticket/13036#no1
bug_13036.cc

$ g++ -I/usr/include/boost bug_13036.cc -o bug
/tmp/ccyIIzRq.o: In function `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int)':
bug_13036.cc:(.text._ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_tr
...........
collect2: error: ld returned 1 exit status

Example from the "getting started" site:
$ g++ -I/usr/include/boost test1.cc -o test1
$ echo 1 2 3 | ./test1
3 6 9

Running a similar command on the subject.cc file from the attached tarball results in regex errors as with the PoC file.
Comment 6 Len Lawrence 2018-04-30 11:01:45 CEST
Created attachment 10108 [details]
PoC to demonstrate regex integer overflow

$ g++ -I /usr/include/boost bug_13036.cc -o bug
Comment 7 Len Lawrence 2018-04-30 11:03:29 CEST
Created attachment 10109 [details]
Two simple utility test files
Comment 8 Len Lawrence 2018-04-30 11:13:29 CEST
Note that boost comes with a large set of examples, some of which are copyrighted under the Boost Software Licence.  Shall have a look at those later.
Comment 9 Len Lawrence 2018-04-30 12:14:10 CEST
Updated  all the boost packages and tried the bug_13036.cc reproducer and saw exactly the same error message and the same with the other regex test.

Help!
Comment 10 Stig-Ørjan Smelror 2018-04-30 12:32:18 CEST
I had to double check to see if the patch was actually applied and it is.

Have no idea why the reproducer shows the same behaviour. It states it was compiled with an older version of GCC. Don't know if that has anything to do with it.

Cheers,
Stig
Comment 11 Len Lawrence 2018-04-30 13:18:19 CEST
Thanks for checking Stig.  If our gcc suite is more up-to-date it is hard to see how the version could matter.  There is no confusion is there, between patches I mean?  It looks like the first responder to the bug was using a 32-bit system.  His patch was rejected by John Maddock and replaced because he did not like the use of unsigned integers.  Presumably it is his patch which was used (no offence intended - just clutching at straws).

I tried a different partition and reinstalled everything from scratch and updated again.  Still the same failure.  We may have to reach out to upstream, or fix it ourselves.
Comment 12 Len Lawrence 2018-04-30 20:39:53 CEST
@Stig: Apologies for that silly remark in comment 11.  Delving into the bowels of boost I did see the applied patch in /usr/include/boost/regex/v4/perl_matcher_common.hpp.
And looking at the error stack from the PoC test I do not think the failure has anything to do with this section of code.  What stands out is

undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char>

which implies perhaps that I am not using boost in the correct way.  Something missing in the environment perhaps?

The subject.cc file from the tutorial produces a huge error stack as well with:

undefined reference to `boost::re_detail_106000::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>

"undefined reference" usually implies a missing include file I think, or is it a namespace problem (shrug).
Comment 13 Len Lawrence 2018-04-30 21:34:06 CEST
Tried playing around with include files, to no avail - bull in a china shop stuff.
Comment 14 Len Lawrence 2018-05-01 13:24:25 CEST
So what if the documentation is misleading, or just plain wrong or maybe I misread it?
How would one go about compiling something normally?
If all the includes are in place then maybe the compiler cannot find the libraries?

$ g++ -I/usr/include/boost -lboost_regex bug_13036.cc -o bug
$
 <bingo!>
$ g++ -I/usr/include/boost -lboost_regex subject.cc -o subject
$ file subject
subject: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=fb758ba893bc41706cd2e7ec2f737025b5284dec, not stripped
$ ./subject < testmessage
Will Success Spoil Rock Hunter?
Comment 15 David Walser 2018-05-01 17:27:15 CEST
I was about to say that you forgot to do the -lfoo to link to the library, glad to see you figured that out.  That's normal.
Comment 16 Len Lawrence 2018-05-02 00:29:55 CEST
Tried the PoC on a pre-updated system again but could not get the compiled program to fail.  However, taking note of the modification suggested for 64-bit systems the executable hogged one of the cpus at 100% for several seconds then failed.

The edit was
boost::regex expr(std::string(3037000500, '.')); // force overflow;

$ ./bug
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted (core dumped)

On an updated system the behaviour of the recompiled script is the same, so we cannot conclude anything from that test but at least we know that the patch has been applied.
Comment 17 Len Lawrence 2018-05-02 15:03:37 CEST
This is about as far as I am likely to go with boost.  It should get the OK.  And, after a second look at the documentation I have to confess that I did misread it or missed a bit.  It is all quite clear.

Whiteboard: (none) => MGA6-64-OK

Lewis Smith 2018-05-04 11:11:22 CEST

Keywords: (none) => advisory, validated_update
CC: (none) => sysadmin-bugs

Comment 18 Mageia Robot 2018-05-04 19:30:28 CEST
An update for this issue has been pushed to the Mageia Updates repository.

https://advisories.mageia.org/MGASA-2018-0220.html

Status: NEW => RESOLVED
Resolution: (none) => FIXED


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