fix(coderd): prevent cross-tenant workspace app rebinding#26103
Draft
dylanhuff-at-coder wants to merge 1 commit into
Draft
fix(coderd): prevent cross-tenant workspace app rebinding#26103dylanhuff-at-coder wants to merge 1 commit into
dylanhuff-at-coder wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
UpsertWorkspaceApp'sON CONFLICT (id) DO UPDATErebound an app'sagent_idto 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.
insertAgentAppmaps the resultingsql.ErrNoRowsinto a clear cross-workspace rejection that fails the build.Tests
Added query-level and
provisionerdservercoverage for the cross-workspace rejection plus the allowed same-workspace and NULL-agent cases.Generated by Coder Agents on behalf of @dylanhuff-at-coder.