Skip to content

fix(api): escape template data in the rendered deploy-azure.sh (bicep/arm) #964

Closed

Description

@cristim

Problem

internal/api/handler_federation.go (around lines 558-562 on main) renders the bicep/ARM deploy-azure.sh script with the raw template data. It does not pass the data through the shell escaping (shellEscapeData) that the other rendered scripts get. A value that passes input validation but contains shell syntax is therefore interpolated into the script verbatim.

Found by the independent review of #955. The reviewer's example: a contact email with a valid quoted local part containing $(id) is accepted, and the command runs on the machine of whoever downloads and runs deploy-azure.sh.

Impact

The person who supplies the value is the one who downloads and runs the script, so this is a self-targeted injection with a narrow blast radius. It is still a correctness and safety gap: the generated script should never execute data. #952 (escape flag values per output format) asked for the server side to be confirmed, and this path is the remaining gap.

Repro (no real Azure needed)

  1. Request the bicep or ARM federation bundle with an email such as "a$(id)b"@example.com, or any field rendered into deploy-azure.sh that allows $(.
  2. Inspect the rendered deploy-azure.sh. The value appears unquoted or unescaped inside a double-quoted shell context.
  3. Run bash -n on the file to see that it parses, then run it in a sandbox with az stubbed: id executes.

Suggested fix

Render that template with shellEscapeData(data), as the other script paths do. Add a test that renders deploy-azure.sh with a $(...) payload and asserts the output contains no unescaped command substitution.

Activity

  1. cristim commented on Oct 16, 2026

    @cristim
    MemberAuthor

    Already fixed on main by #963: the bicep/arm deploy-azure.sh render now goes through shellEscapeData (internal/api/handler_federation.go:561 on main). The remaining '}' and JSON-metacharacter handling for the contact email is in #992 (#991). Verified by the independent review of #992, which rendered 22 scripts with hostile emails and ran them with az stubbed: no command executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions