fix: pin workspace agent API client to intended agent (#26600) - #26622
Merged
Conversation
Backport of #26600 to release/2.29. The workspace agent API client followed HTTP redirects and trusted the redirected host, letting a malicious agent bounce a coderd request onto a different agent's unauthenticated port-4 API (cross-tenant file read/write and RCE). apiClient now refuses redirects and pins every dial to the intended agent address, and the task app / scaletest clients share AppHTTPClient, which blocks redirects too. The upstream change was built on a separate request-context refactor of apiClient that is not present on this release branch, so the redirect block and agent-address pinning are applied to the existing apiClient() here and the request-context-bounded dial test is omitted. The generated agent-conn mock also needed its net/http import for the new AppHTTPClient method. (cherry picked from commit eeb2624)
ethanndickson
force-pushed
the
backport/26600-to-2.29
branch
from
June 23, 2026 14:31
ad78e3e to
4a5d9aa
Compare
f0ssel
approved these changes
Jun 27, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Backport of #26600 to
release/2.29.Original PR: #26600 - fix: pin workspace agent API client to intended agent
Merge commit: eeb2624
Requested by: @ethanndickson
What this fixes
The workspace agent API client followed HTTP redirects and trusted the redirected host, letting a malicious agent bounce a coderd request onto a different agent's unauthenticated port-4 API (cross-tenant file read/write and RCE, Cure53 CODAGT-668).
apiClientnow refuses redirects and pins every dial to the intended agent address, and the task-app / scaletest clients shareAppHTTPClient, which blocks redirects too.Conflict resolution
This 2.29 ESR backport was resolved using the existing
release/2.32backport (#26612) as a reference; that resolution applies cleanly here. #26600 was built on a separate request-context refactor ofapiClientthat is not present on this release branch, so the redirect block and agent-address pinning are applied to the existingapiClient(), and the request-context-bounded dial test (which depends on that refactor) is omitted. This branch had noagentconn_test.go, so the redirect regression tests are added as a newagentconn_test.go. The generated agent-conn mock additionally required itsnet/httpimport for the newAppHTTPClientmethod.