canonical / canonical/cloud-init
[enhancement]: azure password hashing
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 18
Description
#### Request
It may be possible for cloud-init to avoid manually hashing passwords (which would be good for many reasons) by passing the unencrypted password directly to `chpasswd` to be hashed by PAM. For this to happen, two things would have to occur to ensure that cloud-init doesn't write passwords to disk unhashed:
1) cloud-init would have to redact unhashed passwords from instance-data.json / etc
2) cloud-init would need to no longer pickle configurations between stages (there is an effort currently to make cloud-init a single process for performance reasons, which would also make this possible)
Note: cloud-init's persistant storage is root-readonly, yet currently unhashed passwords are never even available to the root user, so while this would not escalate user permissions, it _would_ give a root/sudo user access to something that they didn't have access to before, so out of caution it is preferred not to change this.
#### Context on azure password use:
User passwords are provided by OVF to cloud-init during early boot. These passwords are unencrypted, and cloud-init [encrypts them prior to storing them](https://github.com/canonical/cloud-init/blob/a22d8533305e3f69d2142a0f6ad716916b8ef432/cloudinit/sources/DataSourceAzure.py#L1857), for users to be [later created in the users_groups module]().
To avoid unhashed passwords, users can provide their own hashed password to cloud-init. Users also have the option of passing unhashed passwords, and on Linux these use `chpasswd` (which uses PAM to hash the password) to add the password to the user.
Contributor guide
Assessment
This issue has not been assessed yet.