Repository navigation
Windows password: never in SSM, sealed to a one-time key (#1587) - #1617
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Nov 13, 2026
Contributor
Author
|
Live check (dev, 2026-11-13; Windows Server 2022 on m7i.large):
Instance terminated; leak check clean. Two UX notes from the run: |
spawn connect --rdp interpolated the generated Administrator password into an AWS-RunPowerShellScript command, which SSM keeps for ~30 days, readable with ssm:ListCommands. Now, as GetPasswordData does, the instance generates the password, sets it, and prints it RSA-OAEP-SHA256 encrypted to a 3072-bit key spawn makes per call in memory; the command carries only the public key. A test runs the script in a real PowerShell (Windows PowerShell on the Windows runner, pwsh elsewhere) and opens what it prints.
scttfrdmn
marked this pull request as ready for review
November 13, 2026 23:34
scttfrdmn
force-pushed
the
fix/1587-windows-password-ssm
branch
from
November 13, 2026 23:34
f42112c to
45b5f7b
Compare
This was referenced Nov 14, 2026
Merged
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.
Fixes #1587
What
SetWindowsAdminPasswordViaSSM, the default path ofspawn connect --rdp, used to generate the password on the CLI. It then put it in thecommandsparameter ofAWS-RunPowerShellScript(ConvertTo-SecureString "<pw>"). SSM keeps that parameter for about 30 days, and anyone withssm:ListCommandscan read it.It now uses the scheme EC2
GetPasswordDatauses:RandomNumberGenerator. It uses the same four character classes asGenerateWindowsPassword, one of each guaranteed, with no modulo bias, Fisher-Yates shuffled. It then sets the password, sets never-expire, and enables the account as before.SPAWN-SEALED-PASSWORD:<base64 RSA-OAEP-SHA256 ciphertext>. It usesRSACng, which is in .NET Framework 4.6.2+, i.e. every supported Windows Server, and falls back toRSA.Create()for .NET on other platforms.The SSM history now holds a public key and ciphertext. A Windows whose .NET cannot run the script fails the command, and connect's existing fallback to
GetPasswordDataapplies.GenerateWindowsPasswordstays exported, becausepkg/awsis public surface, so the API is unchanged.Tests
TestWindowsSetAdminPasswordScript: the script carries the public key and no password literal, and is identical across calls with one key.TestOpenSealedWindowsPassword: round-trips the reply, refuses a reply with no marker, and refuses a reply sealed to another key.TestWindowsPasswordScriptRunsInPowerShellruns the real script, with the two account cmdlets stubbed, in Windows PowerShell 5.1 on theTest (Windows)CI job (the RSACng path) and in pwsh where installed (it passed locally with pwsh on macOS). It checks that the reply decrypts, the password meets the complexity rule, and the password is never printed in clear. I watched it fail when I made the script echo$pw.There is no IAM, user-data or spored change.
Live checks needed before merge (owner)
Run in 435415984226, with
--ttl 30m.spawn launch --os windows --ttl 30m.spawn connect <name> --rdp. It should print an Administrator password, and RDP (--via-ssm) should log in with it.aws ssm list-commands --instance-id <id> --region us-east-1 --query 'Commands[].Parameters.commands'should showRSAEncryptionPaddingand a base64 modulus, and noConvertTo-SecureString ".aws ssm get-command-invocation --command-id <id> --instance-id <id> --region us-east-1 --query StandardOutputContentshould show only theSPAWN-SEALED-PASSWORD:ciphertext.