Bug 1868971

Summary: Receptor installation job doesn't properly escape data it puts into receptor.conf
Product: Red Hat Satellite Reporter: Jessica Hanley <jhanley>
Component: RH Cloud - Cloud ConnectorAssignee: Adam Ruzicka <aruzicka>
Status: CLOSED ERRATA QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.7.0CC: aruzicka, lhellebr, pcreech
Target Milestone: 6.8.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: ansiblerole-satellite-receptor-installer-0.6.13 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-10-27 13:05:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jessica Hanley 2020-08-14 17:45:26 UTC
Description of problem:

When there is an issue with the password listed in file "/etc/receptor/rh_656223/receptor.conf", the output of "systemctl status receptor@rh_656223" shows the password in plain text.


Version-Release number of selected component (if applicable):

Satellite 6.7


How reproducible:

always


Steps to Reproduce:
1.  install the cloud connector using our documentation here:  https://access.redhat.com/documentation/en-us/red_hat_insights/2020-04/html-single/remediating_issues_across_your_red_hat_satellite_infrastructure_using_red_hat_insights/index#configuring-cloud-connector-on-satellite-server_remediating-satellite
2.  If the password in file "/etc/receptor/rh_656223/receptor.conf" contains a percent sign character, attempting to start the receptor service will result in a status of "failed".  Running the command "systemctl status receptor@rh_656223" shows the password in plain text.

Actual results:

Failure message in the output of "systemctl status receptor@rh_656223" (where "MYPASSWORD" is the customer's password):

'%' must be followed by '%' or '(', found: MYPASSWORD


Expected results:

The password should not be printed in plain text in system error messages.

Comment 1 Adam Ruzicka 2020-08-17 07:23:58 UTC
*** Bug 1868969 has been marked as a duplicate of this bug. ***

Comment 2 Adam Ruzicka 2020-08-25 12:26:46 UTC
Merged and released in upstream, moving to modified

Comment 3 Lukáš Hellebrandt 2020-09-16 15:20:33 UTC
FailedQA with Sat 6.8 snap 14.

# grep password /etc/receptor/rh_<ID>/receptor.conf 
password=change%me
# systemctl status 'receptor@*' | grep followed
Sep 16 17:14:19 <FQDN>[31952]: '%' must be followed by '%' or '(', found: '%me'

=> Part of the password after '%' is still shown in log.

Note that:
# grep username /usr/share/ansible/roles/project-receptor.satellite_receptor_installer/templates/receptor.conf.j2
username={{ satellite_user | regex_replace('%', '%%') }}

Comment 4 Adam Ruzicka 2020-09-17 06:08:08 UTC
The installer playbook should escape all the percent signs. How did you manage to get a single percent sign in that config file?

Comment 5 Lukáš Hellebrandt 2020-09-17 08:32:56 UTC
I just edited the config file... because why not? I suppose that's what a user would do when e.g. password changed.

Comment 6 Adam Ruzicka 2020-09-17 08:43:19 UTC
We take the credentials from the user and render the config file. Receptor parses the config file (receptor itself, not our plugin) and if it contains something with a percent sign, it fails because it cannot parse the file. When doing so, it logs the offending value. Since we cannot control the parsing, we must solve it from the other side. We can escape the values before rendering the file and thus making sure the file can be parsed by receptor.

If the users change the config by hand, then they have to respect the specifics of the config file format.

Comment 7 Lukáš Hellebrandt 2020-09-17 09:20:05 UTC
After conversation with Adam, I think this BZ needs to be rewritten. The bug is that the installation job doesn't properly escape contents of the configuration file.

The fact that the password is shown in the log is caused by Receptor (not Satellite) being unable to parse the input and showing the offending data - which incidentally contains password.

=> Changing this BZ to track the config file generation. If the user changes the config file manually and Receptor can't parse it, it's not an issue in the Satellie or the installation job.

Do you agree, Adam?

Comment 8 Adam Ruzicka 2020-09-17 09:47:46 UTC
Yes, that is correct.

Comment 9 Lukáš Hellebrandt 2020-09-17 10:08:55 UTC
Verified with Sat 6.8 snap 14.

The password (and other data) is now correctly escaped (% => %%) in the receptor installation playbook, leading to a correct receptor.conf format.

Comment 12 errata-xmlrpc 2020-10-27 13:05:24 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 (Important: Satellite 6.8 release), 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/RHSA-2020:4366

Comment 13 errata-xmlrpc 2020-10-27 13:08:30 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 (Important: Satellite 6.8 release), 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/RHSA-2020:4366