Bug 1039811 (CVE-2013-6435)

Summary: CVE-2013-6435 rpm: race condition during the installation process
Product: [Other] Security Response Reporter: Murray McAllister <mmcallis>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: carnil, ffesti, fweimer, jkurik, jrusnack, ksrot, pfrields, pmatilai, security-response-team, thomas.jarosch, vdanen
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
It was found that RPM wrote file contents to the target installation directory under a temporary name, and verified its cryptographic signature only after the temporary file has been written completely. Under certain conditions, the system interprets the unverified temporary file contents and extracts commands from it. This could allow an attacker to modify signed RPM files in such a way that they would execute code chosen by the attacker during package installation.
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-12-19 04:48:19 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On: 1163052, 1163053, 1163054, 1163055, 1163056, 1163057, 1163058, 1163059, 1163060, 1163061, 1172125    
Bug Blocks: 1039813    
Attachments:
Description Flags
rpm-4.8.0-CVE-2013-6435.patch (version without umask)
none
rpm-4.8.0-CVE-2013-6435.patch (version with umask) none

Description Murray McAllister 2013-12-10 04:12:37 UTC
IssueDescription:

It was found that RPM wrote file contents to the target installation directory under a temporary name, and verified its cryptographic signature only after the temporary file has been written completely. Under certain conditions, the system interprets the unverified temporary file contents and extracts commands from it. This could allow an attacker to modify signed RPM files in such a way that they would execute code chosen by the attacker during package installation.

Acknowledgements:

This issue was discovered by Florian Weimer of the Red Hat Product Security Team.

Comment 17 Florian Weimer 2014-11-11 10:17:21 UTC
Created attachment 956207 [details]
rpm-4.8.0-CVE-2013-6435.patch (version without umask)

Proposed patch for RPM 4.8.

This is based on Panu's suggestion in comment #8, but creates the file with mode 0 instead, instead of using chmod afterwards, closing yet another race.

Comment 24 Florian Weimer 2014-11-11 12:23:40 UTC
Created attachment 956268 [details]
rpm-4.8.0-CVE-2013-6435.patch (version with umask)

This variant of the patch is smaller than the previous one.  The RPM transaction code is not thread-safe already, so another umask call should not be a problem.

Comment 25 Panu Matilainen 2014-11-11 12:46:09 UTC
Yeah, that is short and sweet, and trivial to backport. 

Except that there is no rpmfiFSizeIndex() in < 4.8.x versions, but should be easy enough to replace with direct struct access.

Comment 29 Huzaifa S. Sidhpurwala 2014-12-09 12:50:40 UTC
Created rpm tracking bugs for this issue:

Affects: fedora-all [bug 1172125]

Comment 30 errata-xmlrpc 2014-12-09 18:08:00 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 6.5 EUS - Server and Compute Node Only
  Red Hat Enterprise Linux 6.4 EUS - Server and Compute Node Only
  Red Hat Enterprise Linux 5.6 Long Life
  Red Hat Enterprise Linux 5.9 EUS - Server Only
  Red Hat Enterprise Linux 6.2 AUS

Via RHSA-2014:1975 https://rhn.redhat.com/errata/RHSA-2014-1975.html

Comment 31 errata-xmlrpc 2014-12-09 18:08:17 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 6
  Red Hat Enterprise Linux 5

Via RHSA-2014:1974 https://rhn.redhat.com/errata/RHSA-2014-1974.html

Comment 32 errata-xmlrpc 2014-12-09 19:50:55 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2014:1976 https://rhn.redhat.com/errata/RHSA-2014-1976.html

Comment 33 Fedora Update System 2014-12-17 04:46:12 UTC
rpm-4.12.0.1-4.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 34 Fedora Update System 2014-12-29 09:57:21 UTC
rpm-4.11.3-2.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 35 Thomas Jarosch 2015-01-22 11:37:40 UTC
Is it intentional that the fix for fc22 as in "rpm-4.12.0.1-6.fc22.src.rpm"

does not contain the line

+    rpm_loff_t left = rpmfiFSizeIndex(fsmGetFi(fsm), fsm->ix);

from Florian's patch?

Comment 36 Karel Srot 2015-03-18 07:55:53 UTC
Hi Florian, 
could you please take a look at #c35?

Comment 37 Panu Matilainen 2015-03-18 08:18:18 UTC
It is intentional, rpm 4.12 code already does that for other reasons.