Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 1360743 - (CVE-2016-6354) CVE-2016-6354 flex: buffer overflow in generated code (yy_get_next_buffer)
CVE-2016-6354 flex: buffer overflow in generated code (yy_get_next_buffer)
Status: CLOSED WONTFIX
Product: Security Response
Classification: Other
Component: vulnerability (Show other bugs)
unspecified
All Linux
medium Severity medium
: ---
: ---
Assigned To: Red Hat Product Security
impact=moderate,public=20160718,repor...
: Security
Depends On: 1360744
Blocks: 1360746
  Show dependency treegraph
 
Reported: 2016-07-27 07:46 EDT by Martin Prpič
Modified: 2017-12-14 00:56 EST (History)
4 users (show)

See Also:
Fixed In Version: flex 2.6.1
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-12-14 00:56:04 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Martin Prpič 2016-07-27 07:46:07 EDT
It was found that flex incorrectly resized the num_to_read variable in yy_get_next_buffer. The buffer is resized if this value is less or equal to zero.

With special crafted input it is possible, that the buffer is not resized if the input is larger than the default buffer size of 16k. This allows a heap buffer overflow.

It may be possible to exploit this remotely, depending on the application that is build using flex.

References:

http://seclists.org/oss-sec/2016/q3/97

Upstream patch:

https://github.com/westes/flex/commit/a5cbe929ac3255d371e698f62dc256afe7006466
Comment 1 Martin Prpič 2016-07-27 07:46:22 EDT
Created flex tracking bugs for this issue:

Affects: fedora-all [bug 1360744]
Comment 2 Fedora Update System 2016-08-08 16:28:03 EDT
flex-2.6.0-2.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.
Comment 3 Doran Moppert 2016-08-22 22:16:21 EDT
This flaw was introduced in flex-2.5.36, fixed in 2.6.1.
Comment 4 Doran Moppert 2016-08-22 22:29:25 EDT
Testing with flex-2.5.37 on rhel-7 and using a simple lexer that consumes
arbitrarily long tokens, I have been unable to cause a segmentation
fault or oob read (using valgrind and clang/asan).

Instrumenting the generated lex.yy.c to track yyalloc()/yyrealloc(), the
lexer's behaviour seems to be safe.  I think the potential security impact
is mitigated by the following code immediately after the affected loop,
which constrains the max number of bytes read to 8192:

    if ( num_to_read > YY_READ_BUF_SIZE )
        num_to_read = YY_READ_BUF_SIZE;

Once num_to_read reaches 0, the buffer is reallocated correctly and filled
in 8192-byte (or smaller) chunks.

Looks like this may not be a security flaw at all, though this analysis
should be confirmed with upstream.

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