Skip to content

feat: add sensitive attribute to coder_parameter and redact values - #29739

Closed
Emyrk wants to merge 1 commit into
mainfrom
steven/relay-7-sensitive-parameters
Closed

Emyrk wants to merge 1 commit into
mainfrom
steven/relay-7-sensitive-parameters

Conversation

@Emyrk

@Emyrk Emyrk commented Sep 22, 2026

Copy link
Copy Markdown
Member

Refs RELAY-7.

Adds a sensitive attribute to coder_parameter so Coder redacts the value wherever it is displayed, logged, or exported.

  • Sensitive values come back as *redacted* from the build parameters API, provisioner debug logs, workspace notifications, and CLI output, and render masked in the dashboard.
  • Sensitive parameters are excluded from template insights, the coderd_insights_parameters Prometheus metric, and autofill suggestions.
  • Submitting *redacted* back for a sensitive parameter keeps the previous build's value, so clients can round-trip build parameters unchanged.
  • Default behavior is unchanged; values are still stored in the database and in Terraform state, same as sensitive template variables.

Note

This PR lands first so the shape can be reviewed. The coder/preview and terraform-provider-coder changes follow; the two seams that depend on them are marked TODO(preview) and TODO(provider). Until then, a template cannot set sensitive = true and dynamic-parameter responses do not yet carry the flag.

Plan and decision log

Contract

Mirrors Terraform variables and template_version_variables.sensitive: redacted where Coder displays, logs, or exports; still plaintext in the database and Terraform state. A build-scoped secret transport was considered and deferred; this is the hygiene layer that protects any template using a parameter as a credential today.

Decisions

  • Name sensitive, matching Terraform and TemplateVariable.sensitive.
  • One sentinel, *redacted*, defined once in provisionersdk/proto and aliased as codersdk.RedactedValue and the generated TS RedactedValue. The existing variables path now uses the same constant.
  • Sentinel on submit keeps the previous value. Rejected with 400 only when there is no previous value (new workspace), which also catches duplicated workspaces copying a redacted value.
  • Aggregates exclude sensitive parameters rather than redacting, since a *redacted* bucket is noise.
  • Redaction is definition-driven: external reads join template_version_parameters.sensitive via db2sdk.RedactedWorkspaceBuildParameters. The raw converter is documented as internal-only for wsbuilder.
  • The provisioner path denormalizes onto RichParameterValue.sensitive (proto field 3), mirroring VariableValue.sensitive, so the daemon can redact logs without definitions.
  • Provider value schema is left alone. Terraform sensitivity is schema-wide in SDKv2, so per-instance marking is not possible; docs recommend sensitive(data.coder_parameter.x.value) in HCL.
  • The build parameters handler reads definitions as system so redaction does not require template read.

Touchpoints

  • Proto: RichParameter.sensitive = 19, RichParameterValue.sensitive = 3, proto.Redact*Values helpers.
  • DB: migration 000599_sensitive_parameters; insert query; tvp.sensitive = false filters in GetTemplateParameterInsights and GetUserWorkspaceBuildParameters.
  • provisioner/terraform/resources.go: terraformParameter wrapper decodes sensitive from state ahead of the provider release.
  • provisionerdserver: inserts the flag and sets it on outgoing values for builds and dry runs.
  • wsbuilder.stripRedactedSensitiveValues: sentinel guard.
  • Notifications: shared redactedNotificationParameters for workspace created and manually updated.
  • CLI: Secret: true prompt, no default echo, preset and auto-default echo redacted, --copy-parameters-from skips sensitive and sentinel values.
  • Frontend: forced mask without reveal, Sensitive badge, validation messages omit values, duplication URL and template embed skip sensitive, URL autofill drops the sentinel, consent dialog masks known-sensitive values.
  • Docs: "Sensitive parameters" section in parameters.md.

Follow-ups

  • coder/preview: ParameterData.Sensitive, extract from HCL block and state.
  • terraform-provider-coder: Parameter.Sensitive and schema attribute.
  • Here, after both release: bump go.mod, remove the two TODO seams, add a dynamic-response redaction test.

Known gaps

  • Preset values for a sensitive parameter are template-authored and still returned raw by the presets API; the CLI redacts them on display.
  • /workspacebuilds/{id}/state and cached_plan contain values by design.
  • --debug-http body logging is opt-in and unfiltered.

Coder Agents on behalf of @Emyrk.

Template authors can mark a coder_parameter as sensitive so Coder redacts
its value wherever it is displayed, logged, or exported. The contract
mirrors template variables: redacted in the API, provisioner logs,
notifications, CLI, and dashboard; excluded from insights, the Prometheus
insights collector, and autofill; still stored in the database and in
Terraform state.

Submitting the redacted sentinel back for a sensitive parameter keeps the
previous build's value so clients can round-trip build parameters.

The preview and terraform-provider-coder changes land separately; the
seams that depend on them are marked TODO(preview) and TODO(provider).
@linear-code

linear-code Bot commented Sep 22, 2026

Copy link
Copy Markdown

RELAY-7

@github-actions

Copy link
Copy Markdown
Contributor

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

@Emyrk Emyrk closed this Sep 23, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant