Skip to content

fix(docs): protect the generate-page endpoint from anonymous abuse - #379

Open
atinux wants to merge 1 commit into
mainfrom
fix/docs-generate-page-limit
Open

fix(docs): protect the generate-page endpoint from anonymous abuse#379
atinux wants to merge 1 commit into
mainfrom
fix/docs-generate-page-limit

Conversation

@atinux

@atinux atinux commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

What

Adds a same-origin check, a per-IP rate limit (5/min, in-memory sliding window), and server-side body validation (zod: prompt ≤ 1000 chars, mode enum) to /api/generate-page.

Why

A security scan found the endpoint was an unauthenticated proxy to the project's AI Gateway: any internet client could run arbitrary prompts through claude-sonnet-4.6 with up to 8 tool steps, billed to the project, with no quota or length bound (the 1000-char cap was client-side only). The origin check fits because the only caller is the browser playground; the rate limiter is per serverless instance, which is a floor worth having even without shared storage.


🤖 Prepared by an AI agent (OpenCode) from a security-audit findings list; commits are signed by the repository owner's key.

The playground endpoint passed any anonymous POST straight to the AI
Gateway (claude-sonnet, up to 8 tool steps) with no authentication,
rate limit, or server-side length cap — a free LLM proxy billed to the
project.

- Require a matching Origin header (the playground is browser-only)
- Limit each IP to 5 requests per minute (in-memory sliding window)
- Validate the body with zod: prompt capped at 1000 chars (matching
  the client widget), mode restricted to its two values
@atinux
atinux requested a review from farnabaz as a code owner August 21, 2026 10:10
@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
comark Ready Ready Preview Aug 21, 2026 10:17am
comark-json-render Ready Ready Preview Aug 21, 2026 10:17am
comark-nextjs Ready Ready Preview Aug 21, 2026 10:17am
comark-nuxt Ready Ready Preview Aug 21, 2026 10:17am
comark-svelte Ready Ready Preview Aug 21, 2026 10:17am
comark-sveltekit Ready Ready Preview Aug 21, 2026 10:17am
comark-twoslash Ready Ready Preview Aug 21, 2026 10:17am
comark-vue Ready Ready Preview Aug 21, 2026 10:17am

@pkg-pr-new

pkg-pr-new Bot commented Aug 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

comark

npm i https://pkg.pr.new/comark@379

@comark/angular

npm i https://pkg.pr.new/@comark/angular@379

@comark/ansi

npm i https://pkg.pr.new/@comark/ansi@379

@comark/html

npm i https://pkg.pr.new/@comark/html@379

@comark/nuxt

npm i https://pkg.pr.new/@comark/nuxt@379

@comark/react

npm i https://pkg.pr.new/@comark/react@379

@comark/svelte

npm i https://pkg.pr.new/@comark/svelte@379

@comark/vue

npm i https://pkg.pr.new/@comark/vue@379

commit: fd4189f

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant