severity: errorpack: vercelv1.0 core
nextjs/server-action-unvalidated-input
Server action trusts an `any` parameter
npx @pitcheye/check . --pack vercelwhyItBreaks
A server action is a public HTTP endpoint with a machine-generated id: the TS signature is not enforced at runtime, so `any` is whatever the caller posts. Passing it straight into `.set(...)`/`.values(...)` lets an anonymous caller write arbitrary columns — including privileged ones — on any row the guard does not name.
✖ Bad — triggers errorfixtures/nextjs-server-action-unvalidated-input/bad
'use server';
export async function updateProfile(payload: any) {
await getDb().update(profiles).set(payload);
}✓ Good — passes checkfixtures/nextjs-server-action-unvalidated-input/good
'use server';
const Schema = z.object({ displayName: z.string().max(80) });
export async function updateProfile(raw: unknown) {
const input = Schema.parse(raw);
await getDb().update(profiles).set({ displayName: input.displayName });
}suggestedFix
Type the parameter `unknown`, parse it with a zod schema (`const input = Schema.parse(raw)`) and write only the parsed fields.
explain_rule({"nextjs/server-action-unvalidated-input"})Agent & MCP JSON output contract
{
"ruleId": "nextjs/server-action-unvalidated-input",
"pack": "vercel",
"severity": "error",
"file": "vercel.json",
"line": 6,
"message": "a `'use server'` export whose `any` parameter is used directly in a DB write",
"whyItBreaks": "A server action is a public HTTP endpoint with a machine-generated id: the TS signature is not enforced at runtime, so `any` is whatever the caller posts. Passing it straight into `.set(...)`/`.values(...)` lets an anonymous caller write arbitrary columns — including privileged ones — on any row the guard does not name.",
"suggestedFix": "Type the parameter `unknown`, parse it with a zod schema (`const input = Schema.parse(raw)`) and write only the parsed fields.",
"docsUrl": "https://pitcheye.dev/rules/nextjs-server-action-unvalidated-input"
}Markdown: curl -H "Accept: text/markdown" https://pitcheye.dev/rules/nextjs-server-action-unvalidated-input
raw markdown
# nextjs/server-action-unvalidated-input
- **severity:** error
- **pack:** vercel
- **docs:** https://pitcheye.dev/rules/nextjs-server-action-unvalidated-input
## whyItBreaks
A server action is a public HTTP endpoint with a machine-generated id: the TS signature is not enforced at runtime, so `any` is whatever the caller posts. Passing it straight into `.set(...)`/`.values(...)` lets an anonymous caller write arbitrary columns — including privileged ones — on any row the guard does not name.
## bad
```ts
'use server';
export async function updateProfile(payload: any) {
await getDb().update(profiles).set(payload);
}
```
## good
```ts
'use server';
const Schema = z.object({ displayName: z.string().max(80) });
export async function updateProfile(raw: unknown) {
const input = Schema.parse(raw);
await getDb().update(profiles).set({ displayName: input.displayName });
}
```
## suggestedFix
Type the parameter `unknown`, parse it with a zod schema (`const input = Schema.parse(raw)`) and write only the parsed fields.
## commands
```bash
npx @pitcheye/check . --pack vercel
```
```json
{"tool":"explain_rule","arguments":{"ruleId":"nextjs/server-action-unvalidated-input"}}
```