ci: harden sync-models pipeline and pin TanStack/config actions #549
main fromsecurity/sync-models-rce-and-action-pinning·merged by AlemTuzlak View on GitHubSummary#
Two findings from a CI/CD security audit, fixed together because they're the same security review.
1. RCE via OpenRouter sync (HIGH)#
The daily sync-models workflow fetched models from the OpenRouter API and serialized them back into a generated .ts file via string templating. Non-string fields (created, top_provider.context_length, top_provider.max_completion_tokens, top_provider.is_moderated) were interpolated raw with no runtime type validation, and the next pipeline step imported the file under tsx. A malicious or compromised upstream response could place an arbitrary JS expression in a numeric/boolean slot and execute it inside a job that has contents: write + GITHUB_TOKEN.
Fix: stop generating a .ts file. fetch-openrouter-models.ts now writes plain openrouter.models.json via JSON.stringify — JSON cannot carry a JS expression. A small hand-written wrapper at openrouter.models.ts (~60 lines, replaces the previous ~14k-line generated file) loads the JSON via JSON.parse(readFileSync(...)) and re-exports it typed as Array<OpenRouterModel>, so consumers (convert-openrouter-models.ts, sync-provider-models.ts) didn't need to change their imports. isValidModel is also tightened to reject malformed entries up-front as defence-in-depth.
2. Mutable @main action references (MEDIUM)#
Every workflow used TanStack/config/.github/*@main (mutable ref) while pinning every other third-party action to a tag or SHA. The release job in particular has contents: write + id-token: write and publishes to npm — a compromise of the upstream TanStack/config repo would reach the supply chain.
Fix: pin all TanStack/config/.github/* uses to commit SHA b033ad7 (current main at audit time), with a trailing # main comment so Renovate/Dependabot keeps it current.
Test plan#
-
npx tsx scripts/fetch-openrouter-models.ts— fetched 361 models, wrote JSON, 4 invalid entries rejected by tightenedisValidModel. -
npx tsx scripts/convert-openrouter-models.ts— consumed the JSON via the new wrapper, emittedmodel-meta.tsend-to-end with no consumer changes. -
npx eslint scripts/{fetch,convert,sync-provider}*.ts scripts/openrouter.models.ts— clean (also fixes a pre-existingsort-importsviolation on line 13 offetch-openrouter-models.ts). -
npx prettier --writeon touched files — idempotent. -
grep -r '@main' .github/— zero hits. - CI green on this PR.
- After merge, next
sync-modelscron run produces a clean JSON update PR with no spurious diff.
- 1
@tanstack/ai
npm i https://pkg.pr.new/@tanstack/ai@549@tanstack/ai-anthropic
npm i https://pkg.pr.new/@tanstack/ai-anthropic@549@tanstack/ai-client
npm i https://pkg.pr.new/@tanstack/ai-client@549@tanstack/ai-code-mode
npm i https://pkg.pr.new/@tanstack/ai-code-mode@549@tanstack/ai-code-mode-skills
npm i https://pkg.pr.new/@tanstack/ai-code-mode-skills@549@tanstack/ai-devtools-core
npm i https://pkg.pr.new/@tanstack/ai-devtools-core@549@tanstack/ai-elevenlabs
npm i https://pkg.pr.new/@tanstack/ai-elevenlabs@549@tanstack/ai-event-client
npm i https://pkg.pr.new/@tanstack/ai-event-client@549@tanstack/ai-fal
npm i https://pkg.pr.new/@tanstack/ai-fal@549@tanstack/ai-gemini
npm i https://pkg.pr.new/@tanstack/ai-gemini@549@tanstack/ai-grok
npm i https://pkg.pr.new/@tanstack/ai-grok@549@tanstack/ai-groq
npm i https://pkg.pr.new/@tanstack/ai-groq@549@tanstack/ai-isolate-cloudflare
npm i https://pkg.pr.new/@tanstack/ai-isolate-cloudflare@549@tanstack/ai-isolate-node
npm i https://pkg.pr.new/@tanstack/ai-isolate-node@549@tanstack/ai-isolate-quickjs
npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs@549@tanstack/ai-ollama
npm i https://pkg.pr.new/@tanstack/ai-ollama@549@tanstack/ai-openai
npm i https://pkg.pr.new/@tanstack/ai-openai@549@tanstack/ai-openrouter
npm i https://pkg.pr.new/@tanstack/ai-openrouter@549@tanstack/ai-preact
npm i https://pkg.pr.new/@tanstack/ai-preact@549@tanstack/ai-react
npm i https://pkg.pr.new/@tanstack/ai-react@549@tanstack/ai-react-ui
npm i https://pkg.pr.new/@tanstack/ai-react-ui@549@tanstack/ai-solid
npm i https://pkg.pr.new/@tanstack/ai-solid@549@tanstack/ai-solid-ui
npm i https://pkg.pr.new/@tanstack/ai-solid-ui@549@tanstack/ai-svelte
npm i https://pkg.pr.new/@tanstack/ai-svelte@549@tanstack/ai-utils
npm i https://pkg.pr.new/@tanstack/ai-utils@549@tanstack/ai-vue
npm i https://pkg.pr.new/@tanstack/ai-vue@549@tanstack/ai-vue-ui
npm i https://pkg.pr.new/@tanstack/ai-vue-ui@549@tanstack/openai-base
npm i https://pkg.pr.new/@tanstack/openai-base@549@tanstack/preact-ai-devtools
npm i https://pkg.pr.new/@tanstack/preact-ai-devtools@549@tanstack/react-ai-devtools
npm i https://pkg.pr.new/@tanstack/react-ai-devtools@549@tanstack/solid-ai-devtools
npm i https://pkg.pr.new/@tanstack/solid-ai-devtools@549commit:
d169fa6AlemTuzlak merged this1fea99b
AlemTuzlak closed this
Sign in to join this conversation.
🚀 Changeset Version Preview#
No changeset entries found. Merging this PR will not cause a version bump for any packages.