pr-review-appsec-vendored
Stack-Specific Application Security Checks
Security patterns specific to this repo's technology stack.
How to Use This Checklist
- Review changed files against the relevant sections below.
- Not every section applies to every PR — better-auth checks apply to auth code, SpiceDB checks apply to
.zedfiles and permission-check code, Next.js RSC checks apply to components with'use server'or'use client'directives. - When unsure whether a pattern is vulnerable, lower confidence rather than asserting.
§1 better-auth
-
SSO session missing organization context: After SSO callback,
activeOrganizationIdis not explicitly set on the session. better-auth does not auto-set this — downstream code readingsession.activeOrganizationIdgetsundefined, silently bypassing org-scoped authorization. Flag SSO callback handlers orafterSignInhooks that do not callsetActiveOrganization(). -
SSO auto-provisioning bypasses membership hooks: SSO auto-provisioning creates organization memberships directly, bypassing
beforeAddMemberhooks. Any gating logic (role assignment, approval workflows, seat limits) in those hooks is silently circumvented. Flag SSO config withautoProvision: truewherebeforeAddMemberhooks enforce business rules. -
Triple onboarding path creates duplicate memberships: Three independent paths can create memberships: invitation acceptance, SSO auto-provisioning, and SCIM provisioning. Each may assign different roles, creating duplicates with conflicting permissions. Flag membership creation in invitation handlers, SSO callbacks, AND SCIM endpoints without a shared upsert-or-reconcile layer.