tRPC gives you type safety between client and server, not authorization, so test by finding every publicProcedure and calling it with a foreign id. Then check the batched endpoint, which runs several procedures in one request and is easy to leave unguarded.
Where this class of bug actually lives in a tRPC API
publicProcedure. No session, no user. Anyqueryormutationdeclared public is an open endpoint, whatever the UI implies.- Input as identity.
.input(z.object({orgId: z.string()}))with the tenant taken from input rather thanctx.session. - The batching endpoint. One POST to
/api/trpccan carry several procedure calls; middleware that assumes one call per request may not see all of them. - Error shape. tRPC's error formatter in development returns the stack and the input, which is a free map of your schema.
What to try first
- Enumerate procedures from the client router type or the built bundle and call each with no cookie.
- Call each procedure that takes an id with another tenant's id.
- Send a batched request mixing an authenticated and an unauthenticated procedure.
- Trigger an error and read the shape for stack or input echo.
A reproduction you can keep
A tRPC call is a plain POST to one path, so it curls cleanly:
curl -sS -i 'https://staging.example.com/api/trpc/invoice.byId?batch=1&input=%7B%220%22%3A%7B%22json%22%3A%7B%22id%22%3A%221003%22%2C%22orgId%22%3A%22org_victim%22%7D%7D%7D' \
-H 'Cookie: next-auth.session-token=***'
# vulnerable: the other tenant's invoice
# fixed: NOT_FOUND, or UNAUTHORIZED when no session is presentWhat "fixed" has to look like
Take the tenant from ctx, which is built from the session, and never from input; make every procedure that reads data a protectedProcedure. The fixed result is UNAUTHORIZED without a session and NOT_FOUND for a foreign id.
Where people get this wrong
protectedProcedureonly checks that a session exists. Row-level scoping is still your code.- Using the tRPC TypeScript types as an argument that the API is safe: types constrain the client, not an attacker with curl.
- An
errorFormatterleft in dev mode returns the full stack in production builds if the env check is wrong.
What Offense does here
Offense runs an agent swarm against your app in a disposable sandbox, keeps the request, the identity and the vulnerable response as evidence, and replays the same attack after the fix so the retest is a control comparison rather than a green check. It does not read your source and it does not patch your code: the finding goes to your coding agent with the reproduction attached. The hosted workspace is invite-only — join the waitlist — and the free dependency audit in /install needs no account.
Questions this page answers
Does tRPC validate input?
It validates shape with zod. It does not check that the id in that shape belongs to the caller.
Is the tRPC endpoint protected by types?
No. Anything can POST to /api/trpc; the types only exist on the client.
Written by Offense Research, reviewed December 2, 2026. Correct something? Email imran@offenseresearch.com.