fix(amazon-dcv-windows): escape special characters in DCV credentials - #1036
fix(amazon-dcv-windows): escape special characters in DCV credentials#1036Edd88-pixel wants to merge 1 commit into
Conversation
|
@Edd88-pixel, have you tested the module end-to-end in a real Windows template on AWS? |
There was a problem hiding this comment.
Pull request overview
This PR fixes credential escaping bugs in the amazon-dcv-windows module by applying destination-appropriate encoding for the Windows administrator password in the rendered PowerShell install script and in the Web DCV app URL query parameters, preventing special characters from altering parsing or decoded values.
Changes:
- Render
admin_passwordinto PowerShell as a single-quoted literal and escape'by doubling it (''). - URL-encode the Web DCV
usernameandpasswordquery parameters independently usingurlencode(). - Add Terraform (
.tftest.hcl) and Bun/TypeScript regression tests covering defaults, required-variable contract, and special-character round-trips; update the README usage example version.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| registry/coder/modules/amazon-dcv-windows/README.md | Updates the usage example to reference module version 1.1.2. |
| registry/coder/modules/amazon-dcv-windows/main.tf | Escapes the password for the PowerShell boundary and URL-encodes Web DCV credential query parameters. |
| registry/coder/modules/amazon-dcv-windows/install-dcv.ps1 | Switches the password assignment to a PowerShell single-quoted string literal to prevent interpolation. |
| registry/coder/modules/amazon-dcv-windows/main.test.ts | Adds Bun/TS tests validating exact credential preservation through both script rendering and URL decoding. |
| registry/coder/modules/amazon-dcv-windows/amazon-dcv-windows.tftest.hcl | Adds Terraform plan-time assertions to prevent regressions in URL encoding and PowerShell escaping. |
|
Yes I just provisioned a real Windows instance on AWS and tested the module E2E. The workspace provisioned successfully, and I was able to log in through Web DCV with the configured administrator credentials, including special characters. Everything worked as expected. |
Why
admin_passwordcrossed two syntax boundaries without destination-specific escaping:$, backticks, and"could alter the password or break parsing;&,#,%, and+could change parameter structure or decoded values.Changes
urlencode()separately to the Web DCV username and password query parameters.\ " ' ` $ & < > | # % +.amazon-dcv-windowsfrom1.1.1to1.1.2with the repository version-bump script.Problem
The Windows account password and the password decoded from the DCV app URL could differ from the Terraform input because PowerShell interpolation and URL query parsing interpreted special characters.
Fix
The PowerShell boundary now uses a single-quoted literal with
'escaped as''. The URL boundary encodesusernameandpasswordindividually exactly once.Testing & Validation
bun test --timeout 30000 registry/coder/modules/amazon-dcv-windows/main.test.ts— 5 passed.terraform init -upgrade— passed.terraform validate— passed.terraform test -verbose— 2 passed../scripts/terraform_validate.shwith the changed-module CI inputs — passed../scripts/terraform_test_all.shwith the changed-module CI inputs — 2 passed../scripts/ts_test_auto.shwith the changed-module CI inputs — 5 passed.terraform fmt -check, andbun x tsc --noEmit— passed.bun run fmt:ci— the touched files passed after targeted formatting; the repository-wide command still reports pre-existing formatting findings outside this module and a Windows plugin panic.bun run tftestandbun run tstestwrappers cannot launch their.shscripts under Bun on Windows; the same scripts passed directly through Git Bash as listed above.Regression coverage
The rendered Terraform state is inspected to verify that PowerShell
''decodes back to'and thatURL.searchParamsrestores the exact original username and password, including\ " ' ` $ & < > | # % +. Test failure messages do not print credential values.Type of Change
Module Information
Path:
registry/coder/modules/amazon-dcv-windowsNew version:
v1.1.2Breaking change: [ ] Yes [x] No
Closes #1035