hard20 pts · first answer countsapi-securityvalidation
Profile update accepts any field
What is the security bug in this profile update handler?
export async function PATCH(req: Request) {
const session = await auth()
if (!session) return new Response(null, { status: 401 })
const body = await req.json()
await db.user.update({
where: { id: session.user.id },
data: body,
})
return Response.json({ ok: true })
}Discussion 0
Join free to post in the discussion.
Related questions
- Is browser validation enough?Full Stack Developer
- One schema for form and APIFull Stack Developer
- Rate limiter that does not limitFull Stack Developer
- Webhook signature always failsFull Stack Developer
- Route parameter never matches a numberBackend Developer
- 400 versus 422Backend Developer
- Repeated query keys in ExpressBackend Developer
- Stopping cheaters calling the APIMobile App Developer