Skip to content

Keyvault references break if the secret value contains two percent symbols  #4

@joshschmitter

Description

@joshschmitter

In teamcity, variables are denoted by an opening and closing percent symbol: %my_var%

If a keyvault secret value contains two percent symbols (e.g., my%keyvault%secretValue), the plugin fails to evaluate the secret value and returns the name of the parameter instead. It seems that the secret value is somehow being interpolated by teamcity as containing a variable name.

Moreover, the variable interpolation seems to happen twice before being returned. Variables can be escaped by being duplicated %%. So I tried setting my secret value as my%%keyvault%%secretValue, but this still failed. When I quadrupled each % symbol, it evaluated correctly. my%%%%keyvault%%%%secretValue evaluates to my desired result of my%keyvault%secretValue.

To reproduce:

  1. create a keyvault secret with value of my%keyvault%secretValue

  2. add a parameter myparameter in a teamcity build referencing the keyvault secret.
    Value should look like: %keyvault:my-kv/my-secret-name%

  3. create a teamcity build step with a powershell (or other cli) runner to echo the parameter: echo '%myparameter%'

  4. the build log will contain a line showing the parameter name where there should be a mask for the secret value:

    [20:58:12] [Step 1/1] %myparameter%

  5. change the keyvault secret value to my%%%%keyvault%%%%secretValue.

  6. run the build step again. Output should look something like this:

    [20:58:12] [Step 1/1] ***********

The mask shows that the secret is being retrieved and evaluated successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions