Skip to content

fix!: validate workspace app URLs on the server - #31262

Merged
EhabY merged 3 commits into
mainfrom
fix/validate-workspace-app-urls
Oct 27, 2026
Merged

EhabY merged 3 commits into
mainfrom
fix/validate-workspace-app-urls

Conversation

@EhabY

@EhabY EhabY commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Validate workspace app URLs in coderd, not only in the provisioner.

  • ValidateExternalURL also rejects javascript, vbscript, data, blob, file and filesystem schemes, and control characters anywhere in the URL.
  • insertAgentApp runs it for external template apps, so builds from older or external provisioners get the same check.
  • CreateSubAgent strips $SESSION_TOKEN from app URLs (clients already never fill it in for sub-agent apps) and validates external URLs. A bad URL becomes a per-app url error; the sub-agent still starts.
  • UpdateAppStatus keeps only http, https and file URIs. Anything else is dropped and the status is still saved.
  • Docs: URL rules for dev container apps.

Breaking changes

  • Template builds and imports fail when an external coder_app URL uses one of the blocked schemes or contains control characters. With an older or external provisioner, URLs without a scheme or host now also fail in coderd.
  • Dev container (sub-agent) apps: $SESSION_TOKEN is removed from the stored URL, and external apps with an invalid URL are no longer created.
  • App status URIs other than http, https and file (for example vscode:// or n/a) are no longer stored.

Existing stored apps and statuses are unchanged.

Decision log
  • Blocklist, not allowlist, for app URLs: apps can target any desktop handler (zed://, coder://, new IDEs), so an allowlist can't be complete and would fail builds. Same approach as OAuth2 redirect URIs (codersdk/oauth2_validation.go). ftp is left out since browsers no longer open it.
  • Allowlist for status URIs: the dashboard only renders web links and shows file:// as text, so http, https, file is complete.
  • Strip $SESSION_TOKEN rather than reject: keeps existing devcontainer.json buttons working.
  • Fail the build for bad template URLs: matches the terraform parse step.
  • Drop, don't reject, bad status URIs: a status report shouldn't fail because of an optional field.

Generated with Coder Agents on behalf of @EhabY.

@github-actions

github-actions Bot commented Oct 26, 2026 •

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.

@EhabY EhabY changed the title fix: validate workspace app URLs on the server fix!: validate workspace app URLs on the server Oct 26, 2026
@github-actions github-actions Bot added the release/breaking This label is applied to PRs to detect breaking changes as part of the release process label Oct 26, 2026
@coder coder deleted a comment from linear-code Bot Oct 26, 2026
@EhabY
EhabY force-pushed the fix/validate-workspace-app-urls branch from 0c664b6 to 396b457 Compare October 26, 2026 11:39
@EhabY
EhabY marked this pull request as ready for review October 26, 2026 11:44
@EhabY
EhabY requested a review from nickvigilante as a code owner October 26, 2026 11:44
@EhabY
EhabY force-pushed the fix/validate-workspace-app-urls branch from 396b457 to 37fb1d8 Compare October 26, 2026 11:46

@nickvigilante nickvigilante left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

My agent found a few things worth considering, but overall, docs LGTM

Comment thread coderd/agentapi/apps.go Resolved
EhabY and others added 2 commits October 27, 2026 14:05
Reject external app URLs with script, data, blob, or file schemes, or
with control characters, in coderd for both template and sub-agent apps.
Strip the $SESSION_TOKEN placeholder from sub-agent app URLs, and drop
app status URIs that aren't http, https, or file links.
@EhabY
EhabY force-pushed the fix/validate-workspace-app-urls branch from 37fb1d8 to 5c1013a Compare October 27, 2026 11:08
@EhabY
EhabY enabled auto-merge (squash) October 27, 2026 11:22
@EhabY
EhabY merged commit 8b0c0cc into main Oct 27, 2026
30 checks passed
@EhabY
EhabY deleted the fix/validate-workspace-app-urls branch October 27, 2026 11:44
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 27, 2026
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.

3 participants