Skip to content

fix: escape and mask the SA password - #348

Draft
dhensby wants to merge 3 commits into
tediousjs:masterfrom
dhensby:fix/sa-password-quoting
Draft

dhensby wants to merge 3 commits into
tediousjs:masterfrom
dhensby:fix/sa-password-quoting

Conversation

@dhensby

@dhensby dhensby commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

The action runs SQL Server setup with windowsVerbatimArguments, so @actions/exec adds no quoting, and it wrapped the password as /SAPWD="${password}" without escaping. A double quote in sa-password, or a backslash at the end of it, changed how setup split its command line. Setup then lost the licence switch and the later arguments, or set a different password from the one in the sa-password output. The password was also never masked, so the setup command line and every sqlcmd readiness attempt printed it in clear when it didn't come from a secret.

  • Escaping. A new quoteWindowsArgument() quotes a value with the standard Windows quoting rules: it escapes each double quote, and doubles only the backslashes that come before a double quote or the closing quote. The action uses it for the values it adds itself: /SAPWD, /SQLCOLLATION and /UpdateSource. Plain values give the same command line as before. The user's install-arguments are still passed as given. A unit test splits the command line the way the Windows C runtime does, and checks that every string of up to four characters from a " \ space tab % ^ ! comes back unchanged, with the later switches intact.
  • Masking. gatherInputs() registers the password with core.setSecret, and also its escaped form, which is what the command lines show when the password needs escaping. This includes the public default password. GitHub leaves out job outputs that contain a masked value, so a workflow that passes sa-password on as a job output loses it. Step outputs still work. The README says this, and also that GitHub still prints the inputs in the step header before the action starts.
  • CI. A new runaction job installs SQL Server 2025 with the password Str0ng"Pa ss%^!\, which contains a double quote, a space, characters that cmd.exe treats specially and a trailing backslash. The check step from ci: check that the installed instance works in runaction #344 logs in over TCP with the sa-password output, so the job passes only if setup set exactly that password. 2025 exits with 3010 in CI, so the action's own readiness check must also log in with it.

Closes #324

🤖 Generated with Claude Code

dhensby and others added 3 commits November 20, 2026 23:19
The action runs SQL Server setup with windowsVerbatimArguments, where
@actions/exec adds no quoting, and it wrapped the password as
`/SAPWD="${password}"` without escaping. A double quote in the
password, or a backslash at the end of it, therefore changed how setup
split its command line. Setup then lost the licence switch and every
later argument, or set a different password from the one in the
sa-password output, so later logins failed.

Quote the values that the action adds to the command line itself
(/SAPWD, /SQLCOLLATION and /UpdateSource) with the standard Windows
quoting rules, which escape each double quote and double the
backslashes that come before a double quote or the closing quote.
Plain values give the same command line as before. The user's
install-arguments are still passed as they are given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The action never registered the password as a secret. @actions/exec
prints each command line before it runs it, so the setup command line
and every sqlcmd readiness attempt showed the password in clear when it
didn't come from a secret, and so did later steps that printed it.

Register the password with core.setSecret before anything can log it,
and also its escaped form, which is what the command lines show when
the password needs escaping. The README now says what masking covers:
GitHub still shows the input in the step header before the action
starts, and it leaves out job outputs that contain a masked value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a runaction job that installs SQL Server 2025 with an SA password
that contains a double quote, a space, characters that cmd.exe treats
specially and a trailing backslash. The check step logs in over TCP
with the sa-password output, so the job passes only if setup set
exactly that password. 2025 exits with 3010 in CI, so the action's own
readiness check must also log in with it. The other jobs keep the
action's default password.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

sa-password values with a double quote or a trailing backslash break the setup command line

1 participant