Bug 1874403 - Guest templates contain hard coded passwords
Summary: Guest templates contain hard coded passwords
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Container Native Virtualization (CNV)
Classification: Red Hat
Component: SSP
Version: 2.4.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: 2.5.0
Assignee: Vatsal Parekh
QA Contact: Israel Pinto
URL:
Whiteboard:
Depends On: 1876440 1879054
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-09-01 10:02 UTC by Fabian Deutsch
Modified: 2020-12-07 09:51 UTC (History)
7 users (show)

Fixed In Version: 2.5.0
Doc Type: Enhancement
Doc Text:
Feature: Default cloud-user password is not auto-generated for VMs processed from templates Reason: To prevent identical hard-coded password for VMs of the same type Result: Each VM has its own auto-generated password
Clone Of:
Environment:
Last Closed: 2020-12-07 09:51:56 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github kubevirt common-templates issues 187 0 None closed Remove hardcoded passwords from templates 2021-01-11 12:59:00 UTC

Description Fabian Deutsch 2020-09-01 10:02:04 UTC
Description of problem:
The guest templates contain hard coded passwords.
This is a security issue.

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

How reproducible:
always

Steps to Reproduce:
1. Create a VM
2. Login with default password
3.

Actual results:
Can login with default

Expected results:
Per instance password is generated

Additional info:
Instead of hard coding the passwords we can rather generate them upon VM creation.

We should at least remove them

Comment 2 Fabian Deutsch 2020-09-07 09:30:02 UTC
The idea is to replace the hard coded password with an auto generated one using the generation scheme of templates like:

```
parameters:
- description: The cloud user password to be used
  from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}'
  generate: expression
  name: CLOUD_USER_PASSWORD
```

This will generate a unique password for every VM.

Comment 3 Fabian Deutsch 2020-09-07 12:19:26 UTC
Realtes to bug #1876440

Comment 4 Tomas Jelinek 2020-09-15 12:06:31 UTC
Is this relying on the generation on "oc process" or after submitting to the api? Because UI does not call the oc process since the UI needs to allow to do "anything" with the VM - e.g. before submitting it the user can remove the cloud init completely or add / remove disks etc. So what the UI does it just takes the template, fills the wizard by it and than submits the resulting vm yaml. But does not call oc process in the middle.

Comment 5 Fabian Deutsch 2020-09-15 12:16:26 UTC
Good that you mention it: Yes, it depends on OCP Templates processing functionality.

Comment 6 Fabian Deutsch 2020-09-15 13:03:56 UTC
In the worst case the UI can generate a password and replace the relevant parameter.

In general I'd recommend the UI to assume that we'll be leveraging all of the template features.

Comment 7 Tomas Jelinek 2020-09-16 08:23:03 UTC
(In reply to Fabian Deutsch from comment #6)
> In the worst case the UI can generate a password and replace the relevant
> parameter.

Im a little afraid to try to get this in for 4.6 though

> 
> In general I'd recommend the UI to assume that we'll be leveraging all of
> the template features.

Comment 8 Fabian Deutsch 2020-09-16 09:02:28 UTC
Ok - I think it's not mandatory for 4.6, but would have been nice.
As we will have to fix this bug for 4.6/2.5.

Comment 9 Tomas Jelinek 2020-09-16 09:15:24 UTC
(In reply to Fabian Deutsch from comment #8)
> Ok - I think it's not mandatory for 4.6, but would have been nice.

I know it would have been nice but it came very late in the game...

> As we will have to fix this bug for 4.6/2.5.

can you please move it out of 2.5 to avoid accidentally do it and break the ui?

Comment 10 Fabian Deutsch 2020-09-17 09:54:40 UTC
After discussing this offline:

The template will include

        - cloudInitNoCloud:
            userData: |-
              #cloud-config
              password: ${CLOUD_USER_PASSWORD}
              chpasswd: { expire: False }
          name: cloudinitdisk

Where CLOUD_USER_PASSWORD will be following the scheme xxxx-xxxx-xxxx.
Where x are random characters from the set [a-zA-Z0-9]

The agreement is that for 2.5.0 the UI will replace the value of the `password:` line in the cloud init stanza.

Comment 11 Vatsal Parekh 2020-09-17 15:13:04 UTC
The common-templates part got merged upstream https://github.com/kubevirt/common-templates/pull/213

Comment 12 Ruth Netser 2020-10-05 13:04:26 UTC
Tested with kubevirt-ssp-operator-container-v2.5.0-50, fedora has a wrong user in the description:

- description: Randomized password for cloud-user
  from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}'
  generate: expression
  name: CLOUD_USER_PASSWORD

Comment 13 Vatsal Parekh 2020-10-08 06:03:05 UTC
(In reply to Ruth Netser from comment #12)
> Tested with kubevirt-ssp-operator-container-v2.5.0-50, fedora has a wrong
> user in the description:
> 
> - description: Randomized password for cloud-user
>   from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}'
>   generate: expression
>   name: CLOUD_USER_PASSWORD

That's not a bug here, but a confusing typo
Fix: https://github.com/kubevirt/common-templates/pull/247

Comment 14 Ruth Netser 2020-10-25 14:28:16 UTC
Verified with kubevirt-ssp-operator-container-v2.5.0-55:

Fedora:
- description: Randomized password for the cloud-init user fedora
  from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}'
  generate: expression
  name: CLOUD_USER_PASSWORD

In UI:
#cloud-config
user: fedora
password: a0ji-1bl4-6az5
chpasswd:
  expire: false

RHEL:
- description: Randomized password for the cloud-init user cloud-user
  from: '[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}'
  generate: expression
  name: CLOUD_USER_PASSWORD

In UI:
#cloud-config
user: cloud-user
password: l1bi-fvza-pjih
chpasswd:
  expire: false

Comment 17 Shikha Jhala 2020-11-04 18:06:29 UTC
Release notes PR is now merged: https://github.com/openshift/openshift-docs/pull/26998


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