Skip to content

fix(devtools): secure devtools viewer api access - #16042

Merged
gr2m merged 2 commits into
mainfrom
aayush/devtools-cors
Jun 12, 2026
Merged

fix(devtools): secure devtools viewer api access#16042
gr2m merged 2 commits into
mainfrom
aayush/devtools-cors

Conversation

@aayush-kapoor

Copy link
Copy Markdown
Collaborator

Background

@ai-sdk/devtools served its API with wildcard CORS and listened without an explicit hostname. any website could fetch against the api route, and LAN peers could potentially hit the viewer directly if reachable.

Summary

malicious cross-origin pages and non-local host requests now get 403

Manual Verification

verified that there was no regression by running the viewer and the example examples/ai-functions/src/generate-text/anthropic/nested-subagent-with-telemetry.ts

Checklist

  • All commits are signed (PRs with unsigned commits cannot be merged)
  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

@aayush-kapoor aayush-kapoor added the backport Admins only: add this label to a pull request in order to backport it to the prior version label Jun 11, 2026
@gr2m
gr2m merged commit 32ce45c into main Jun 12, 2026
53 checks passed
@gr2m
gr2m deleted the aayush/devtools-cors branch June 12, 2026 04:21
github-actions Bot added a commit that referenced this pull request Jun 12, 2026
@github-actions github-actions Bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label Jun 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Backport to release-v6.0 created but has conflicts: #16054

gr2m pushed a commit that referenced this pull request Jun 12, 2026
Resolved the cherry-pick conflict for release-v6.0:
- Kept the security fix — removed wildcard `cors()`, bound `serve()` to
  localhost, and added the `/api/*` Host/Origin allowlist middleware
  (using `viewerPort`, with `app` exported).
- Dropped the stale `remoteDbPath` line from the incoming hunk: v6's viewer
  never had the network-supplied dbPath feature (its /api/notify already
  calls `reloadDb()` with no argument), so keeping it would be an unused var.
- Omitted the added `server.test.ts`: the v6 devtools package has no vitest
  dependency, test script, or config, so the test can't run there and its
  `vitest` import would break type-check.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gr2m pushed a commit that referenced this pull request Jun 12, 2026
Resolved the cherry-pick conflict for release-v6.0:
- Kept the security fix — removed wildcard `cors()`, bound `serve()` to
  localhost, and added the `/api/*` Host/Origin allowlist middleware
  (using `viewerPort`, with `app` exported).
- Dropped the stale `remoteDbPath` line from the incoming hunk: v6's viewer
  never had the network-supplied dbPath feature (its /api/notify already
  calls `reloadDb()` with no argument), so keeping it would be an unused var.
- Omitted the added `server.test.ts`: the v6 devtools package has no vitest
  dependency, test script, or config, so the test can't run there and its
  `vitest` import would break type-check.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gr2m pushed a commit that referenced this pull request Jun 12, 2026
This is an automated backport of #16042 to the release-v6.0 branch.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.0-canary.172 github npm
@ai-sdk/alibaba 2.0.0-canary.59 github npm
@ai-sdk/amazon-bedrock 5.0.0-canary.84 github npm
@ai-sdk/angular 3.0.0-canary.172 github npm
@ai-sdk/anthropic 4.0.0-canary.66 github npm
@ai-sdk/anthropic-aws 1.0.0-canary.7 github npm
@ai-sdk/assemblyai 3.0.0-canary.50 github npm
@ai-sdk/azure 4.0.0-canary.75 github npm
@ai-sdk/baseten 2.0.0-canary.56 github npm
@ai-sdk/black-forest-labs 2.0.0-canary.50 github npm
@ai-sdk/bytedance 2.0.0-canary.51 github npm
@ai-sdk/cerebras 3.0.0-canary.56 github npm
@ai-sdk/cohere 4.0.0-canary.52 github npm
@ai-sdk/deepgram 3.0.0-canary.49 github npm
@ai-sdk/deepinfra 3.0.0-canary.56 github npm
@ai-sdk/deepseek 3.0.0-canary.54 github npm
@ai-sdk/devtools 1.0.0-canary.30 github npm
@ai-sdk/elevenlabs 3.0.0-canary.49 github npm
@ai-sdk/fal 3.0.0-canary.49 github npm
@ai-sdk/fireworks 3.0.0-canary.56 github npm
@ai-sdk/gateway 4.0.0-canary.104 github npm
@ai-sdk/gladia 3.0.0-canary.49 github npm
@ai-sdk/google 4.0.0-canary.81 github npm
@ai-sdk/google-vertex 5.0.0-canary.107 github npm
@ai-sdk/groq 4.0.0-canary.53 github npm
@ai-sdk/harness 1.0.0-canary.7 github npm
@ai-sdk/harness-claude-code 1.0.0-canary.3 github npm
@ai-sdk/harness-codex 1.0.0-canary.3 github npm
@ai-sdk/harness-pi 1.0.0-canary.3 github npm
@ai-sdk/huggingface 2.0.0-canary.56 github npm
@ai-sdk/hume 3.0.0-canary.49 github npm
@ai-sdk/klingai 4.0.0-canary.50 github npm
@ai-sdk/langchain 3.0.0-canary.172 github npm
@ai-sdk/llamaindex 3.0.0-canary.172 github npm
@ai-sdk/lmnt 3.0.0-canary.49 github npm
@ai-sdk/luma 3.0.0-canary.49 github npm
@ai-sdk/mcp 2.0.0-canary.63 github npm
@ai-sdk/mistral 4.0.0-canary.54 github npm
@ai-sdk/moonshotai 3.0.0-canary.56 github npm
@ai-sdk/open-responses 2.0.0-canary.53 github npm
@ai-sdk/openai 4.0.0-canary.73 github npm
@ai-sdk/openai-compatible 3.0.0-canary.56 github npm
@ai-sdk/otel 1.0.0-canary.118 github npm
@ai-sdk/perplexity 4.0.0-canary.52 github npm
@ai-sdk/policy-opa 1.0.0-canary.9 github npm
@ai-sdk/prodia 2.0.0-canary.52 github npm
@ai-sdk/provider-utils 5.0.0-canary.48 github npm
@ai-sdk/quiverai 2.0.0-canary.5 github npm
@ai-sdk/react 4.0.0-canary.175 github npm
@ai-sdk/replicate 3.0.0-canary.50 github npm
@ai-sdk/revai 3.0.0-canary.50 github npm
@ai-sdk/rsc 3.0.0-canary.173 github npm
@ai-sdk/sandbox-just-bash 1.0.0-canary.7 github npm
@ai-sdk/sandbox-vercel 1.0.0-canary.7 github npm
@ai-sdk/svelte 5.0.0-canary.172 github npm
@ai-sdk/togetherai 3.0.0-canary.56 github npm
@ai-sdk/tui 1.0.0-canary.7 github npm
@ai-sdk/valibot 3.0.0-canary.48 github npm
@ai-sdk/vercel 3.0.0-canary.56 github npm
@ai-sdk/voyage 2.0.0-canary.23 github npm
@ai-sdk/vue 4.0.0-canary.172 github npm
@ai-sdk/workflow 1.0.0-canary.89 github npm
@ai-sdk/xai 4.0.0-canary.74 github npm

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants