Repository navigation
fix(security): use random build/test VM passwords and keep them out o… - #9791
Cameron Meissner (cameronmeissner) merged 4 commits into
Conversation
…f CI logs Addresses Mythos findings tracked under ADO 37518878: - 37518912: vhd-scanning.sh set SCAN_VM_ADMIN_PASSWORD to the deterministic "ScanVM@$CURRENT_TIME" (epoch timestamp, trivially guessable). Generate a random password instead. The "ScanVM@" prefix guarantees upper/lower/special so Azure VM password-complexity rules are still satisfied. - 37518914: run-test.sh set TEST_VM_ADMIN_PASSWORD to the deterministic "TestVM@$(date +%s)" AND echoed it verbatim to the build log; the `az vm create --admin-password` calls also ran under `set -x`, so the value was traced into the ADO log. Randomize the password, wrap the `az vm create` calls in `set +x`/`set -x`, and drop the password from the final echo (username only). No functional change to provisioning/build output beyond credential generation and log hygiene. Validated with bash -n on both scripts; the run-test ShellSpec (spec/vhdbuilder/packer/test/run_test_spec.sh) only exercises the cleanup function and retry loop, neither of which is touched. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 350c2577-7031-4d0d-adc1-e99d053fc981
Windows Unit Test Results 3 files 18 suites 1m 10s ⏱️ Results for commit 3b6a8aa. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
🟡 Changes recommended
Windows VM creation still exposes the password through Azure CLI debug logging, and credential-log protections lack regression coverage.
2 open findings
What changed in this PR
Hardens temporary VM credentials in the VHD build and test pipeline.
Changes:
- Replaces timestamp-based passwords with randomly generated values.
- Disables shell tracing around test VM creation and removes passwords from the final status message.
| File | Description |
|---|---|
vhdbuilder/packer/vhd-scanning.sh |
Randomizes the scan VM password. |
vhdbuilder/packer/test/run-test.sh |
Randomizes the test VM password and reduces credential logging. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
AgentBaker Linux gate detectiveRun: 185891864 Detective summary: LocalDNS cold-start validation failed after CoreDNS reported plugin/loop fatal while testing empty-hosts cold-start and hosts-file reload behavior. Likely cause / signature: e2e-localdns-coldstart-empty-hosts-start-timeout. Confidence: High: failed test record, E2E log, timeline, and prior cold-start row all isolate LocalDNS cold-start behavior. Recommended owner/action: LocalDNS owner should inspect cold-start loop detection around testdomain456.com and hosts reload. Strongest alternative: PR-specific behavior in 9791, but the signature already recurred across unrelated PRs. Evidence: build run, failed test run 693091545, E2E task log 624, timeline, PR metadata, and wiki tracker. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: calvin197 <44663669+calvin197@users.noreply.github.com>
PR review caught that both password-generation pipelines
(openssl rand -base64 24 | tr -dc 'A-Za-z0-9') run under 'set -e' without
'pipefail'. A pipeline's exit status is that of its last command, so a
silent openssl failure would go undetected (tr succeeds on empty stdin),
leaving the script to continue with a fixed, publicly-visible password
('ScanVM@' / 'TestVM@' with no random suffix) instead of aborting.
Switch to openssl rand -hex 24, which needs no tr filtering (hex output is
already alphanumeric), removing the pipe entirely so 'set -e' correctly
aborts on an openssl failure. Verified empirically: a failing openssl now
aborts the script (exit 1) instead of silently continuing.
Also updates the ShellSpec test's openssl mock/assertions to match the new
unfiltered-hex-output behavior (no more tr-induced character stripping).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 350c2577-7031-4d0d-adc1-e99d053fc981
|


What this PR does / why we need it:
Hardens credential handling in two VHD build/test scripts that run in the AgentBaker VHD pipeline. Addresses Mythos security findings (tracked under ADO 37518878):
• Scan VM password (ADO 37518912) — vhdbuilder/packer/vhd-scanning.sh set the trivy-scan VM's admin password to ScanVM@$CURRENT_TIME (a Unix epoch timestamp), which is trivially guessable. Now generated randomly via openssl rand . The ScanVM@ prefix is kept so Azure VM password-complexity rules (upper/lower/special) are still satisfied.
• Test VM password (ADO 37518914) — vhdbuilder/packer/test/run-test.sh set the test VM's admin password to TestVM@$(date +%s) (predictable, CWE-330) and leaked it to the ADO build log in two ways: the az vm create --admin-password calls ran under set -x (xtrace), and a final echo printed it verbatim (CWE-532, not masked as a pipeline secret). Fix: randomize the password, wrap both az vm create calls in set +x / set -x , and drop the password from the echo (username only).
No functional change beyond credential generation and log hygiene. Validated with bash -n on both scripts; the run-test ShellSpec only exercises the cleanup() function and retry loop, neither of which is touched. openssl is standard on the ADO Ubuntu build agents.
Which issue(s) this PR fixes:
Fixes #
ADO work items (msazure/CloudNativeCompute): 37518912, 37518914 (parent: 37518878)