Repository navigation
fix(security): restrict node secret file perms and avoid logging AD realm password - #9776
Open
Calvin S. (calvin197) wants to merge 1 commit into
Open
Calvin S. (calvin197) wants to merge 1 commit into
Calvin S. (calvin197) wants to merge 1 commit into
Conversation
…ealm password Addresses Mythos findings tracked under ADO 37518878: - 37518906/911/915: bootstrap-kubeconfig embeds the TLS bootstrap token but was written world-readable (chmod 0644). Restrict to 0600 so unprivileged local users can't read the token. - 37518920/916: the kubelet client private key (/etc/kubernetes/certs/client.key) was written with no explicit mode (umask-dependent, typically 0644). touch + chmod 0600 before writing so it's never world-readable. - 37518908: setup-custom-search-domains.sh runs under `set -x`, echoing the AD realm join password into provisioning logs. Wrap the realm join in `set +x` / `set -x`. Verified: go test ./pkg/agent/... and aks-node-controller ./parser/... pass; bash -n on all three scripts; no ShellSpec assertions reference the changed lines. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 350c2577-7031-4d0d-adc1-e99d053fc981
Contributor
Windows Unit Test Results 3 files 18 suites 1m 24s ⏱️ Results for commit 5d3b920. |
Contributor
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Restoring tracing masks realm-join failures, and the new security invariants lack required ShellSpec coverage.
3 open findings
What changed in this PR
Hardens Linux node provisioning against secret exposure.
Changes:
- Restricts kubelet private key and bootstrap kubeconfig permissions.
- Suppresses tracing while passing the AD realm password.
| File | Description |
|---|---|
setup-custom-search-domains.sh |
Disables tracing around realm join. |
cse_config.sh |
Sets client key permissions to 0600. |
cse_config_kubelet.sh |
Sets bootstrap kubeconfig permissions to 0600. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # disable command tracing so the realm password isn't written to provisioning logs | ||
| set +x | ||
| echo "${CUSTOM_SEARCH_REALM_PASSWORD}" | realm join -U ${CUSTOM_SEARCH_REALM_USER}@$(echo "${CUSTOM_SEARCH_DOMAIN_NAME}" | tr /a-z/ /A-Z/) $(echo "${CUSTOM_SEARCH_DOMAIN_NAME}" | tr /a-z/ /A-Z/) | ||
| set -x |
Comment on lines
+509
to
+511
| # client.key is the kubelet client private key; restrict to root before writing | ||
| touch /etc/kubernetes/certs/client.key | ||
| chmod 0600 /etc/kubernetes/certs/client.key |
Comment on lines
+309
to
+310
| # bootstrap-kubeconfig embeds the TLS bootstrap token; restrict to root only | ||
| chmod 0600 "${BOOTSTRAP_KUBECONFIG_FILE}" |
Contributor
|
Contributor
| touch "${BOOTSTRAP_KUBECONFIG_FILE}" | ||
| chmod 0644 "${BOOTSTRAP_KUBECONFIG_FILE}" | ||
| # bootstrap-kubeconfig embeds the TLS bootstrap token; restrict to root only | ||
| chmod 0600 "${BOOTSTRAP_KUBECONFIG_FILE}" |
Contributor
There was a problem hiding this comment.
Calvin S. (@calvin197) you can drop this change, addressing it here: #9797
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


What this PR does / why we need it:
Hardens three node-provisioning scripts so secrets aren't exposed via file permissions or provisioning logs. Addresses Mythos security findings (tracked under ADO 37518878):
• bootstrap-kubeconfig (ADO 37518906/911/915) — /var/lib/kubelet/bootstrap-kubeconfig embeds the TLS bootstrap token but was written world-readable ( chmod 0644 ). Tightened to chmod 0600 so unprivileged local users can't read the token.
• kubelet client key (ADO 37518920/916) — /etc/kubernetes/certs/client.key (kubelet client private key) was written with no explicit mode (umask-dependent, typically 0644). Now touch + chmod 0600 before writing, so there's never a world-readable window.
• AD realm password in logs (ADO 37518908) — setup-custom-search-domains.sh runs under set -x , which echoed the AD realm-join password into provisioning logs. Wrapped the realm join in set +x / set -x .
No functional behavior change — only file modes and log-tracing scope. Validated with go test ./pkg/agent/... and aks-node-controller ./parser/... (both pass), bash -n on all three scripts, and confirmed no ShellSpec assertions reference the changed lines.
Which issue(s) this PR fixes:
Fixes #