Bug 1287695 (CVE-2015-8393)

Summary: CVE-2015-8393 pcre: pcregrep -q is not always quiet (8.38/28)
Product: [Other] Security Response Reporter: Adam Mariš <amaris>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED NOTABUG QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: adam.stokes, andrew, carnil, erik-fedora, jgrulich, jorton, lkundrak, mclasen, mmaslano, pmyers, ppisar, rcollet, rmeggins, sardella, slawomir, walters, webstack-team
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: pcre 8.38 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-18 13:58:23 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1287697, 1287698, 1287699, 1287700    
Bug Blocks: 1287727    

Description Adam Mariš 2015-12-02 14:05:21 UTC
It was discovered that pcregrep in PCRE before 8.38 mishandles the -q option for binary files or when used with -c or -l options, incorrectly writing output to stdout, which might allow remote attackers to obtain sensitive information via a crafted file.

Comment 1 Adam Mariš 2015-12-02 14:06:08 UTC
Created pcre tracking bugs for this issue:

Affects: fedora-all [bug 1287697]

Comment 2 Adam Mariš 2015-12-02 14:06:16 UTC
Created glib2 tracking bugs for this issue:

Affects: fedora-all [bug 1287699]

Comment 3 Adam Mariš 2015-12-02 14:06:25 UTC
Created mingw-pcre tracking bugs for this issue:

Affects: fedora-all [bug 1287698]
Affects: epel-7 [bug 1287700]

Comment 4 Adam Mariš 2015-12-02 15:24:39 UTC
Corresponds to item 28 in http://vcs.pcre.org/pcre/code/trunk/ChangeLog?view=markup

Comment 5 Petr Pisar 2015-12-02 16:11:26 UTC
Fixed in upstream with:

commit 8dda766e48f3bd16df6d8af870e9df4551b6216d
Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date:   Wed Aug 5 17:43:19 2015 +0000

    Make pcregrep -q override -l and -c for compatibility with other greps.
    
    
    git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1586 2f5784b3-3f2a-0410-8824-
cb99058d5e15

Comment 6 Fedora Update System 2016-01-04 19:55:05 UTC
pcre-8.38-1.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.

Comment 7 Tomas Hoger 2016-02-18 13:47:03 UTC
(In reply to Petr Pisar from comment #5)
> Fixed in upstream with:
> 
> commit 8dda766e48f3bd16df6d8af870e9df4551b6216d
> Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
> Date:   Wed Aug 5 17:43:19 2015 +0000
> 
> Make pcregrep -q override -l and -c for compatibility with other greps.

Upstream commit link:

http://vcs.pcre.org/pcre?view=revision&revision=1586

Comment 8 Tomas Hoger 2016-02-18 13:58:23 UTC
Upstream fix corrects two problems:

- When pcregrep is run with both -q (--quiet) and one of -c (--count) and -l (--files-with-matches) it still generates output unlike other grep implementations.  As these options are conflicting, this may be considered bug, but not a security issue.

- When pcregrep is rung with -q and the file being grepped is binary, it prints a message as: "Binary file filname matches".  Reportedly, this is an information leak issue (where leaked information is the name of file being grepped).  Leak can only happen in very specific circumstances, and I don't think this is really worth calling security given the minimal impact.

This second problem was only introduced in version 8.31, when pcregrep got support for binary files:

http://vcs.pcre.org/pcre?view=revision&revision=947

This bug also does not affect various packages that embed PCRE library, as it's not in the library itself, but in the pcregrep tool.