RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1158891 - Wrong access rights to sos report after rebase to 3.2
Summary: Wrong access rights to sos report after rebase to 3.2
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: sos
Version: 7.1
Hardware: All
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Bryn M. Reeves
QA Contact: David Kutálek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-30 13:10 UTC by Miroslav Hradílek
Modified: 2015-03-05 11:24 UTC (History)
2 users (show)

Fixed In Version: sos-3.2-7.el7
Doc Type: Bug Fix
Doc Text:
Cause: A regression in the handling of the process umask caused sosreport archives to be created with incorrect permissions. Consequence: Unprivileged local users could read the report archive. Fix: The correct umask is now set prior to creating the archive resulting in the intended "rw for owner only" file mode (0600). Result: Only the local root user can access the report content.
Clone Of:
Environment:
Last Closed: 2015-03-05 11:24:00 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:0532 0 normal SHIPPED_LIVE sos bug fix and enhancement update 2015-03-05 16:12:44 UTC

Description Miroslav Hradílek 2014-10-30 13:10:10 UTC
Description of problem:
Prior to the rebase to 3.2 the generated sosreports had access rights defined like so
-rw-------. 1 root root

after rebase it is
-rw-r--r--. 1 root root

I think only root should be able to access sosreport.

Version-Release number of selected component (if applicable):
sos-3.2-4.el7.noarch

How reproducible:
100%

Comment 2 Bryn M. Reeves 2014-10-30 15:31:01 UTC
This is a regression due to commit commit 8d25777:

8d2577786cce6fcc915836108e405dbf5025dec8
Author: Bryn M. Reeves <bmr>
Date:   Tue Apr 29 19:02:43 2014 +0100

    Drop cwd/umask shenanigans from TarFileArchive::finalize()
    

Although the cwd manipulations are no longer needed the umask modification is - I run my systems with a umask of 077 for root (which gives the expected behaviour even after the above commit). However as the default root umask for Red Hat distros has always been 022 we fail to drop group and other read privileges for the archive in the default install case.

Reverting the two umask lines from the above patch obviously fixes the problem but don't think this is the best approach for 7.1; one of the motivations for removing this code is that the archive classes in sos explicitly do not handle exceptions (it's handled in the main sosreport class that calls the archive methods).

Fiddling with the umask in the archive complicates this because it's unclear when an exception occurs within Archive.finalize() whether or not the umask needs to be reset or not.

I think it's better to deal with  this by moving the umask manipulation up to SoSReport; that way the umask cleanup happens under a 'finally' block and doesn't need any special treatment to avoid leaking changes to the mask on error.

Comment 3 Bryn M. Reeves 2014-10-30 15:31:25 UTC
--- /root/src/git/sos/sos/sosreport.py  2014-09-19 15:33:07.872321514 +0100
+++ /usr/lib/python2.7/site-packages/sos/sosreport.py   2014-10-30 17:03:44.216321514 +0000
@@ -1327,6 +1327,7 @@ class SoSReport(object):
         self._finish_logging()
         # package up the results for the support organization
         if not self.opts.build:
+            old_umask = os.umask(0o077)
             if not self.opts.quiet:
                 print(_("Creating compressed archive..."))
             # compression could fail for a number of reasons
@@ -1345,6 +1346,8 @@ class SoSReport(object):
                     raise
                 else:
                     return False
+            finally:
+                os.umask(old_umask)
         else:
             final_filename = self.archive.get_archive_path()
         self.policy.display_results(final_filename, build=self.opts.build)

Comment 4 Bryn M. Reeves 2014-10-30 16:57:21 UTC
Fixed upstream:

commit d7759d3ddae5fe99a340c88a1d370d65cfa73fd6
Author: Bryn M. Reeves <bmr>
Date:   Thu Oct 30 16:46:01 2014 +0000

    [sosreport] fix archive permissions regression
    
    Restore the umask save/restore around archive creation and ensure
    the effective umask is 077 at the time of archive creation.
    
    Fixes #425.
    
    Signed-off-by: Bryn M. Reeves <bmr>

Comment 8 errata-xmlrpc 2015-03-05 11:24:00 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-0532.html


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