Summary
Coder's Terraform-based dotfiles registry module previously passed unsanitized user-supplied values directly into shell commands, enabling command injection inside provisioned workspaces.
By crafting a malicious dotfiles_uri and abusing auto-provisioning deep links, an attacker could cause arbitrary commands to run during workspace creation whenever a victim visited a single URL.
Affected context
The vulnerability occurs in Coder deployments that use the dotfiles registry module to bootstrap remote development workspaces via Terraform.
It is relevant when user-controlled parameters such as dotfiles_uri or related fields are interpolated into shell scripts that run as part of workspace provisioning.
Risk increases in environments that expose mode=auto deep links or similar one-click flows where parameterized URLs can silently drive workspace creation without explicit user review.
Exploit preconditions
- Attack surface: Web-based workspace creation flows that accept
dotfiles_urior similar parameters, including deep-linked Create Workspace pages usingmode=auto. - Required access: Ability to craft and deliver URLs or requests that set
param.dotfiles_uri(typically any authenticated user, or anyone who can trick a user into clicking a Coder deep link). - Trigger point: The provisioning phase of workspace creation, when the Terraform-driven dotfiles module executes shell commands using the supplied values.
- Why exploitation is possible: The module embedded unsanitized user input into shell commands using constructs like
eval/sh -c, allowing shell metacharacters and command substitution ($(...)) to be interpreted and executed.
Why this happens
The underlying bug class is command injection: user-provided strings were directly incorporated into shell commands without validation or escaping, so the shell treated parts of the input as executable syntax rather than data.
In this case, the dotfiles module used generic mechanisms such as eval and sh -c to process values like dotfiles_uri, implicitly trusting them as safe command fragments.
This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where an application assembles OS commands from untrusted input and relies on the shell to interpret them, enabling attackers to inject arbitrary commands during workspace provisioning.
Potential impact
- An attacker may execute arbitrary commands inside their own or a victim's newly created workspace.
- Workspace initialization scripts could be modified to install malware, backdoors, or data exfiltration tooling.
- Attackers could poison development environments, altering tooling or configuration to influence future code or builds.
- Compromise of secrets or credentials stored or loaded into the workspace environment could occur.
- In some deployments, privilege escalation or lateral movement to other infrastructure components may be possible, depending on workspace permissions and connectivity.
General mitigation guidance
Effective mitigation focuses on treating all user-controlled parameters as untrusted data and avoiding direct interpolation into shell commands.
Common defensive patterns include:
- Replacing dynamic shell invocations (
eval,sh -c) with explicit, parameterized APIs that do not invoke a shell, or with strongly typed configuration parsing. - Validating and constraining inputs such as URIs and usernames against strict allowlists, rejecting special characters, shell metacharacters, and unexpected schemes.
- Separating configuration data from execution logic, ensuring that provisioning scripts consume values as data (e.g., environment variables, structured configuration) rather than constructing command strings.
- Running provisioning steps with least-privilege accounts and minimal access to host resources, limiting the blast radius of any injected commands.
- Designing auto-provisioning or deep-link flows so any prefilled parameters are visibly surfaced and require explicit user confirmation before execution.
How teams detect issues like this
Organizations can detect similar issues by combining code-centric and operational checks:
- Static analysis rules that flag uses of
eval,sh -c, backticks, command substitution ($(...)), or other shell features in conjunction with user input. - Secure code review practices that pay attention to provisioning routines, Terraform modules, and bootstrap scripts, specifically looking for command assembly from parameters like URIs, paths, or usernames.
- Policy-based checks in CI/CD pipelines that disallow certain shell patterns or mandate validation functions for user-supplied configuration fields.
- Runtime logging and monitoring of workspace provisioning commands, alerting on anomalous arguments or unexpected shell syntax originating from user parameters.
- Periodic security assessments of template modules and registry components that are reused across many workspaces, since a single unsafe pattern there can propagate widely.

