Skip to content

fix(amazon-dcv-windows): escape special characters in DCV credentials - #1036

Open
Edd88-pixel wants to merge 1 commit into
coder:mainfrom
Edd88-pixel:fix/amazon-dcv-windows-password-escaping
Open

fix(amazon-dcv-windows): escape special characters in DCV credentials#1036
Edd88-pixel wants to merge 1 commit into
coder:mainfrom
Edd88-pixel:fix/amazon-dcv-windows-password-escaping

Conversation

@Edd88-pixel

@Edd88-pixel Edd88-pixel commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Why

admin_password crossed two syntax boundaries without destination-specific escaping:

  • the rendered PowerShell script used a double-quoted string, so $, backticks, and " could alter the password or break parsing;
  • the Web DCV query string interpolated credentials directly, so characters such as &, #, %, and + could change parameter structure or decoded values.

Changes

  • Render the administrator password as a PowerShell single-quoted string and double literal apostrophes.
  • Apply urlencode() separately to the Web DCV username and password query parameters.
  • Add Terraform and TypeScript regression coverage for default credentials, the existing required-variable contract, and exact round-trips of \ " ' ` $ & < > | # % +.
  • Bump amazon-dcv-windows from 1.1.1 to 1.1.2 with 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 encodes username and password individually 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.sh with the changed-module CI inputs — passed.
  • ./scripts/terraform_test_all.sh with the changed-module CI inputs — 2 passed.
  • ./scripts/ts_test_auto.sh with the changed-module CI inputs — 5 passed.
  • Targeted Prettier checks, terraform fmt -check, and bun 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.
  • The bun run tftest and bun run tstest wrappers cannot launch their .sh scripts 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 that URL.searchParams restores the exact original username and password, including \ " ' ` $ & < > | # % +. Test failure messages do not print credential values.

Type of Change

  • Bug fix

Module Information

Path: registry/coder/modules/amazon-dcv-windows
New version: v1.1.2
Breaking change: [ ] Yes [x] No

Closes #1035

@matifali

Copy link
Copy Markdown
Member

@Edd88-pixel, have you tested the module end-to-end in a real Windows template on AWS?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_password into PowerShell as a single-quoted literal and escape ' by doubling it ('').
  • URL-encode the Web DCV username and password query parameters independently using urlencode().
  • 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.

Edd88-pixel commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

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.

@matifali
matifali requested a review from 35C4n0r July 31, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: special characters in amazon-dcv-windows admin_password break DCV login

3 participants