Improve password posture#165
Conversation
| | ForEach-Object{ $_ -replace ".*AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys.*", "#$&" } ` | ||
| | ForEach-Object{ $_ -replace "#RekeyLimit default none", "$&`r`n# Disable cipher to mitigate CVE-2023-48795`r`nCiphers -chacha20-poly1305@openssh.com`r`n" } | ||
| | ForEach-Object{ $_ -replace "#RekeyLimit default none", "$&`r`n# Disable cipher to mitigate CVE-2023-48795`r`nCiphers -chacha20-poly1305@openssh.com`r`n" } ` | ||
| | ForEach-Object{ $_ -replace "^#?PasswordAuthentication.*", "PasswordAuthentication no" } |
There was a problem hiding this comment.
I don't believe this would be considered a breaking change since users should use bosh ssh for SSH rather than direct password auth.
There was a problem hiding this comment.
I think this does break using extensions which enable password auth for ssh like os-conf/windows-utilities which has an enable_ssh job
e76091c to
6e9d979
Compare
There was a problem hiding this comment.
Pull request overview
Improves the password-generation implementation in the stemcell automation PowerShell module by switching to a cryptographically secure RNG and updates Pester tests accordingly.
Changes:
- Replaced
Get-Random-based password generation withSystem.Security.Cryptography.RandomNumberGeneratorand reused the byte buffer across attempts. - Updated Pester tests to stop mocking the generated password and to add basic length/uniqueness assertions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
stembuild/stemcell-automation/AutomationHelpers.psm1 |
Uses a crypto RNG + byte buffer to generate 24-char passwords in the retry loop. |
stembuild/stemcell-automation/AutomationHelpers.Tests.ps1 |
Adjusts tests for the new generation approach; adds length and uniqueness checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6e9d979 to
ec5ff76
Compare
Rev 2
Realized there might be backwards compatibility issues if we remove password auth entirely; going to remove that change since the new password should be very secure anyway.
Password Generation Enhancements (
AutomationHelpers.psm1)Get-Randommethod to[System.Security.Cryptography.RandomNumberGenerator]::Create()for a more robust and modern source of entropy.whileloop, reducing unnecessary garbage collector pressure.SSH Configuration Updates (
BOSH.SSH.psm1)Edit-DefaultOpenSSHConfigwith a regex replacement to ensurePasswordAuthenticationis explicitly set tono.Test Suite Improvements (
AutomationHelpers.Tests.ps1&BOSH.SSH.Tests.ps1)'changeMe123!') with dynamic evaluations of the actual generated output.Valid-Passwordhelper.Verification
Made-with: Cursor