bhouse-nexthop opened a new pull request, #14918:
URL: https://github.com/apache/cloudstack/pull/14918
### Description
With a private registry, every CKS node ran its registry script as `bash -x
/opt/bin/setup-containerd`, so the
registry user name and password, in plain text and as the base64 auth
string, were written to
`/var/log/cloud-init-output.log` on every worker and control node. The URL,
user name and password were also
substituted into the cloud-config as plain text: a double quote, backslash,
`$` or newline broke the script or the
YAML, and `{{` or `{%` made cloud-init fail to render the control node
template (it is a Jinja template), so it
dropped the whole cloud-config and the control node was never set up.
Now:
- The script runs without `-x`. It prints its own progress lines, and the
credentials are the reason it exists, so
tracing it can't be made safe by turning tracing off around some lines.
- The URL and its endpoint go into the cloud-config base64-encoded and the
script decodes them. The user name and
password are no longer substituted at all: containerd gets only `auth =
"<base64 of user:password>"`, which it
reads the same way as the `username`/`password` pair. No character in the
values can change the cloud-config, the
Jinja template or the script.
- `/opt/bin/setup-containerd` is 0700 and `/etc/containerd/config.toml`
0600, as both hold the auth string.
- `createKubernetesCluster` refuses a registry URL that is not a valid URI
(double quotes, backslashes, whitespace),
which would break the containerd config. `new URL()` accepted them.
Other secrets in the same templates, checked: the kubeadm join token and
certificate keys are generated values with
safe characters and their scripts are not traced; the API server key is
written 0600. Not changed.
Not changed here: on 4.22 the control node template only writes the registry
script under
`{% if registry is defined %}`, which is never true, so the control node
gets no registry (#14408 fixes that).
Fixes: #14917
### Types of changes
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] Enhancement (improves an existing feature and functionality)
- [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
- [ ] Build/CI
- [ ] Test (unit or integration test code)
### Feature/Enhancement Scale or Bug Severity
#### Feature/Enhancement Scale
- [ ] Major
- [ ] Minor
#### Bug Severity
- [ ] BLOCKER
- [ ] Critical
- [x] Major
- [ ] Minor
- [ ] Trivial
### Screenshots (if appropriate):
### How Has This Been Tested?
Unit tests in `KubernetesClusterActionWorkerTest`, for the worker, control
and added control node templates, with a
password containing `{{`, `{%`, quotes, a backslash, `$(...)` and a newline
and a URL with `'`, `$(...)` and `&`: no
plain value is left in the rendered cloud-config, the URL, endpoint and auth
are there base64-encoded, the runcmd is
`bash /opt/bin/setup-containerd` without `-x`, and the script is 0700.
`KubernetesClusterManagerImplTest`: the URL
check refuses a double quote, a newline and a missing scheme. `mvn -pl
plugins/integrations/kubernetes-service -am
test`: all tests pass.
The rendered worker script was also run against a containerd 1.7 default
config with those values: the resulting
config parses as TOML, the auth string decodes to the original user name and
password, and the config is 0600.
A lab test on a KVM zone follows in a comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]