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 1857396 - SELinux issue when using secure communication to remote pmcd
Summary: SELinux issue when using secure communication to remote pmcd
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: pcp
Version: 8.3
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: 8.4
Assignee: Mark Goodwin
QA Contact: Jan Kurik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-07-15 19:23 UTC by Jan Kurik
Modified: 2021-09-17 12:44 UTC (History)
6 users (show)

Fixed In Version: pcp-5.2.2-1.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-18 15:19:32 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Audit log containing the AVC records generated by pmcd (1.59 KB, text/plain)
2020-07-15 19:31 UTC, Jan Kurik
no flags Details

Description Jan Kurik 2020-07-15 19:23:17 UTC
Description of problem:
This is a follow-up of bz1826047

When communication to a remote pmcd is secured as described in https://pcp.io/docs/lab.secureclient.html , the pmcd on the remote host generates AVC records.

Version-Release number of selected component (if applicable):
This is reproducible on pcp <= 5.1.1-3.el8 (including pcp ~ 4.x)

How reproducible:
Always

Steps to Reproduce:
1. Install pcp and other required packages on a fresh RHEL system
# yum install -y nss-tools openssl pcp pcp-system-tools /usr/sbin/semanage

2. Configure the secure communication as described in https://pcp.io/docs/lab.secureclient.html

3. Test if the secure communication works

# PCP_SECURE_SOCKETS=enforce PCP_ALLOW_BAD_CERT_DOMAIN=1 \
PCP_ALLOW_SERVER_SELF_CERT=1 PCP_SECURE_DB_PATH=/etc/pcp/nssdb \
pminfo -h remote-host -f kernel.uname.nodename

kernel.uname.nodename
    value "remote.host"

Actual results:
The pminfo works as expected, however the remote pmcd generates AVC records.


Expected results:
No AVC records are generated


Additional info:
The suspicious part of the code is in src/libpcp/src/secureserver.c
Function "__pmIsSecureserverLock()" is calling "NSS_InitReadWrite()" and there is a fallback to "NSS_Init()" if "NSS_InitReadWrite()" fails.
IMO the "NSS_InitReadWrite()" should be removed from the code as there is no reason why pmcd needs to write to the NSS database.

Comment 1 Jan Kurik 2020-07-15 19:31:23 UTC
Created attachment 1701293 [details]
Audit log containing the AVC records generated by pmcd

Comment 7 Mark Goodwin 2020-07-23 10:52:52 UTC
In pmproxy/src/deprecated.c: VerifyClient() .. __pmSecureServerHandshake() .. __pmSecureServerIPCFlags() .. __pmSecureServerInit() .. NSS_InitReadWrite()

So pmproxy's use of NSS_InitReadWrite() is deprecated. The only other caller is pmcd, which does not require RW. But if you think pmproxy's use might be resurrected one day, then we could allow RW access to the db via an SELinux policy update. The usual recommendation is not to grant access unless it's actually required but afaict we have no clients needing RW access to the cert db.

Comment 9 Mark Goodwin 2020-07-24 02:38:00 UTC
hmm. well in that case 'deprecated' is a misnomer because it isn't. So we need to fix the selinux issue too. So I think 'deprecated' mode should call a new libpcp function to open in RW mode. It would be preferable for pmcd to open in RO mode (as per the current patch).

I'll update the deprecated code in pmproxy, add the new function to libpcp and fix the selinux issue. unless anyone has a better suggestion ... like are the UOB people really still likely to be using this? (minnus (name?) has moved on hasn't he?)

Comment 12 Mark Goodwin 2020-10-09 07:44:07 UTC
I have a new patch for this BZ that does not require an SELinux policy update - basically I don't think we should add a rule for pmcd like "allow [pcp_pmcd_t] [etc_t] : [file] { write };" unnecessarily. Instead my new patch changes  __pmSecureServerInit() in libpcp to check an environment variable and if set, only call NSS_Init() rather than NSS_InitReadWrite(). pmcd would set this environment variable (because it only requires read-only access to the NSS db), but pmproxy would not set it. The default behaviour (when the envar is not set) remains unchanged, so no changes needed for pmproxy or any other libpcp apps.

Comment 13 Mark Goodwin 2020-10-13 00:16:07 UTC
Fixed upstream for pcp-5.2.2. This avoid the AVC and also changes pmcd to initialize NSS read-only instead of read-write when using secure connections.

commit c85528b1865336ad108a211a87f24132cf45d554
Author: Mark Goodwin <mgoodwin>
Date:   Tue Oct 13 10:58:49 2020 +1100

    pmcd/libpcp: pmcd init NSS read-only when using secure connections
    
    Use an environment variable to specify whether to initialize NSS in
    read-only or read-write mode in libpcp:__pmSecureServerInit(),
    defaulting to read-write if not set (i.e. no change for existing apps
    that do not set the variable).
    
    For pmcd, set PCP_NSS_INIT_MODE=readonly in $PCP_SYSCONFIG_DIR/pmcd
    because pmcd does not need read-write access to the NSS certificate
    database (though some future DSO/PMDA might).
    
    New test qa/1876 checks pmcd's environment. Document the new variable
    in PCPINTRO(1).
    
    Resolves: RHBZ#1857396

Comment 19 errata-xmlrpc 2021-05-18 15:19:32 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 (pcp bug fix and enhancement update), 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://access.redhat.com/errata/RHBA-2021:1754


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