Skip to content

fix(devtools): validate viewer database paths - #16049

Merged
gr2m merged 3 commits into
mainfrom
aayush/devtools-db-fix
Jun 12, 2026
Merged

fix(devtools): validate viewer database paths#16049
gr2m merged 3 commits into
mainfrom
aayush/devtools-db-fix

Conversation

@aayush-kapoor

Copy link
Copy Markdown
Collaborator

Background

currently /api/notify trusted whatever dbPath came in the request body. the viewer would store /etc/passwd as remoteDbPath, and the next /api/runs call would pass it into reloadDb(), which attempted to readFileSync() and parse that file. If the file happened to be JSON shaped like the devtools DB, it could be exposed through the viewer APIs

Summary

dbPath is only accepted if it resolves to a real regular file named:

<some-project>/.devtools/generations.json

Manual Verification

na

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
Adds a 100 MB cap in validateRemoteDbPath so an attacker-influenced (but
otherwise valid) .devtools/generations.json cannot hang/OOM the synchronous
read. Complements the existing basename/dir, isFile, and symlink-escape
checks. Closes the last gap noted when consolidating the duplicate VULN-11550
fixes (#16055).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gr2m

gr2m commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Pushed a small graft on top (20e7921): a 100 MB read-size cap in validateRemoteDbPath (stats.size > MAX_DB_BYTES → reject), plus a regression test using a sparse file just over the cap.

Context: this consolidates the duplicate VULN-11550 fix I'd opened (#16055), which I've now closed in favor of this PR. Your validation (basename/dir + isFile + realpathSync symlink-escape) is the better approach — zero behavior change for cross-directory viewers, and the symlink defense is something my version didn't have. The size cap was the one gap (a genuinely huge real generations.json could still hang/OOM the synchronous readFileSync), so I've added just that piece here. All 6 db tests pass; type-check clean.

Note: VULN-11530's Host/Origin gating (#16042 / its v6 backport #16054) makes the cross-origin POST unreachable, so the residual "another project's .devtools/generations.json" surface is local-only — fine to leave as-is.

@gr2m
gr2m merged commit 275674e into main Jun 12, 2026
49 checks passed
@gr2m
gr2m deleted the aayush/devtools-db-fix branch June 12, 2026 05:17
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: #16057

@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