tRPC publicProcedure mutation without an auth check
Rule ID: vetkit.js.trpc.public-procedure-destructive-mutation
A tRPC publicProcedure mutation updates or deletes database rows without checking who is calling. Anyone can call this procedure over HTTP and change or delete records by id.
Last updated:
Suite: Security
javascript, typescript
A tRPC publicProcedure mutation updates or deletes database rows without checking who is calling. Anyone can call this procedure over HTTP and change or delete records by id.
Category: SECURITY · Engine rule severity: WARNING
How to fix it
Build the mutation on protectedProcedure (or a procedure whose middleware checks the session) and scope the write to the caller, for example where: { id: input.id, createdById: ctx.session.user.id }. Keep publicProcedure for reads and for flows that carry their own proof, such as a password-reset token.
References
Source: packages/engine/rules/sast/javascript.yml.
Related checks
- NextAuth allowDangerousEmailAccountLinking enabled
- NextAuth Auth.js debug: true logs tokens in production
- NextAuth Auth.js hardcoded secret in source code
- JavaScript eval() with a dynamic argument: code injection
- Node.js code injection: request input loads a module
- Node.js child_process command injection from user input
Check your own repository for this
vetkit runs this rule as part of a repository audit, alongside secret scanning, dependency vulnerabilities, code quality and AI code risk checks. It reads a temporary checkout and never executes your code.
Start with the free Security Quick Scan · See how the platform works
Generated from shipped rule definitions at build time. Matching is a review signal, not proof of exploitability. “generic” denotes text matching, not complete language or framework coverage. Runtime configuration and available tools affect whether a rule runs.