Skip to content

fix(coderd): prevent cross-tenant workspace app rebinding#26103

Draft
dylanhuff-at-coder wants to merge 3 commits into
mainfrom
dylan/plat-262-cross-tenant-app-rebinding
Draft

fix(coderd): prevent cross-tenant workspace app rebinding#26103
dylanhuff-at-coder wants to merge 3 commits into
mainfrom
dylan/plat-262-cross-tenant-app-rebinding

Conversation

@dylanhuff-at-coder
Copy link
Copy Markdown
Contributor

Problem

UpsertWorkspaceApp's ON CONFLICT (id) DO UPDATE rebound an app's agent_id to any incoming agent, keyed only on the app id. A malicious build could reuse a victim's app id and point it at the attacker's agent, proxying the victim's app traffic across tenants (SEC-91 / PLAT-262).

Fix

Scope the SQL update so an app only rebinds when the existing and incoming agents resolve to the same owning workspace. NULL on either side (e.g. template-import-job agents) is permitted. insertAgentApp maps the resulting sql.ErrNoRows into a clear cross-workspace rejection that fails the build.

Tests

Added query-level and provisionerdserver coverage for the cross-workspace rejection plus the allowed same-workspace and NULL-agent cases.


Generated by Coder Agents on behalf of @dylanhuff-at-coder.

UpsertWorkspaceApp's ON CONFLICT (id) DO UPDATE rebound an existing app's
agent_id to any incoming agent, keyed only on the app id. A malicious build
could reuse a victim's app id and point it at the attacker's agent, proxying
the victim's app traffic across tenants (SEC-91/PLAT-262).

Guard the update in SQL so an app only rebinds when the existing and incoming
agents resolve to the same owning workspace. NULL on either side (e.g.
template-import-job agents) is permitted, since those rows are not a
cross-tenant victim. insertAgentApp translates the resulting sql.ErrNoRows
into a clear cross-workspace rejection that fails the build, blocking any
rebind attempted through an unowned agent.
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Jun 5, 2026

PLAT-262

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant