Skip to content

fix!: redact agent environment variable values in API responses - #31932

Merged
deansheather merged 1 commit into
mainfrom
dean/eng-1505-workspace-api-returns-environment-variables
Nov 11, 2026
Merged

deansheather merged 1 commit into
mainfrom
dean/eng-1505-workspace-api-returns-environment-variables

Conversation

@deansheather

@deansheather deansheather commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Workspace, build, and agent API responses (/workspaces, /workspacebuilds/{id}, /workspaceagents/{id}, and so on) returned agent environment variable values in plain text. Template authors often pass credentials such as API tokens through coder_env, so anyone who could read the workspace could read those secrets.

db2sdk.WorkspaceAgent now replaces every non-empty value with ***REDACTED*** and keeps the keys. This is the same marker the support bundle (sanitizeEnv) and the agent /debug/manifest endpoint already use. The agent still gets the real values through its manifest (db2sdk.WorkspaceAgentEnvironment), and nothing in the CLI or frontend reads these values from the API.

Every value is redacted because neither coder_env nor coder_agent.env in the Terraform provider has a sensitive flag, and proto.Env has no field to carry one. Selective redaction would need changes to the provider, the proto, and the database.

For changelog

  • Agent environment variable values are redacted in API responses (fix!: redact agent environment variable values in API responses #31932)

    Workspace, workspace build, workspace agent, and template version API responses now return ***REDACTED*** for every non-empty agent environment_variables value. Keys and empty values are unchanged. The agent still receives the real values, so workspaces behave as before.

    Migration: Update scripts and integrations that read agent environment variable values from the API or from coder list -o json. Read the values inside the workspace instead.

Closes ENG-1505 (coder/security#51)

Decision log
  • Confirmed the leak on main (e1c3a21): db2sdk.WorkspaceAgent copied dbAgent.EnvironmentVariables straight into codersdk.WorkspaceAgent.EnvironmentVariables. Every API path that returns an agent goes through this function.
  • Redact all non-empty values, not just some. There is no secret or non-secret marker in terraform-provider-coder v2.20.0 (coder_env has only agent_id, name, value, merge_strategy; coder_agent.env is a plain map), and name heuristics fail in both directions.
  • Use ***REDACTED*** to match the existing support bundle and /debug/manifest redaction. Empty values are kept, which also matches existing behavior.
  • Redact in the SDK converter only, so the agent manifest path is unaffected.
  • Regression test TestWorkspaceAgent/RedactsEnvironmentVariables covers the workspace, workspace agent, and workspace build endpoints. It fails without the fix.

Generated by Coder Agents on behalf of @deansheather.

Workspace, build, and agent API responses returned agent environment
variable values verbatim. Template authors commonly pass credentials
through coder_env, and there is no way to tell which values are
sensitive, so redact every non-empty value with ***REDACTED***, matching
the support bundle and the agent debug manifest. Keys are preserved.

The agent still receives the real values through its manifest.
@deansheather

Copy link
Copy Markdown
Collaborator Author

@codex review

@deansheather

Copy link
Copy Markdown
Collaborator Author

@codex security review

@linear-code

linear-code Bot commented Nov 9, 2026

Copy link
Copy Markdown

ENG-1505

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T16:19:49.235619Z fafb1dd Manual request
🔒 Security Review ✅ Completed 2026-11-09T16:20:14.680678Z fafb1dd Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: fafb1ddcd3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: fafb1ddcd3

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@deansheather
deansheather marked this pull request as ready for review November 9, 2026 16:41

@ethanndickson ethanndickson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be labelled a breaking change?

@deansheather

Copy link
Copy Markdown
Collaborator Author

I guess that's true, I'll label it properly

@deansheather deansheather changed the title fix: redact agent environment variable values in API responses fix!: redact agent environment variable values in API responses Nov 10, 2026
@deansheather deansheather added the release/breaking This label is applied to PRs to detect breaking changes as part of the release process label Nov 10, 2026
@deansheather
deansheather temporarily deployed to main November 10, 2026 16:31 — with GitHub Actions Inactive
@deansheather
deansheather temporarily deployed to main November 10, 2026 16:31 — with GitHub Actions Inactive
@ethanndickson
ethanndickson temporarily deployed to main November 11, 2026 05:19 — with GitHub Actions Inactive
@ethanndickson
ethanndickson temporarily deployed to main November 11, 2026 05:19 — with GitHub Actions Inactive
@deansheather
deansheather merged commit fb12d60 into main Nov 11, 2026
69 of 71 checks passed
@deansheather
deansheather deleted the dean/eng-1505-workspace-api-returns-environment-variables branch November 11, 2026 05:51
@deansheather
deansheather temporarily deployed to main November 11, 2026 05:51 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 11, 2026

This branch was previously deployed

1 inactive deployment
main — fafb1ddc Deployed Nov 11, 2026 by deansheather via cla #253810
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release/breaking This label is applied to PRs to detect breaking changes as part of the release process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants