Why AI tools produce this: AI coding tools produce this regularly, typically when prompted for a shortcut or a quick fix.
Why this matters
In advanced, disableCSRFCheck: true turns off ALL of better-auth's CSRF protection (origin-header validation and Fetch-Metadata checks), and disableOriginCheck: true drops the origin-header validation on its own. Either one lets a malicious site drive state-changing authentication requests against a logged-in user's session (CWE-352).
Remove the flag and keep the checks on. If a specific trusted front-end needs to reach the auth API cross-origin, add its exact origin to trustedOrigins instead of disabling the check globally.
import { betterAuth } from "better-auth";// ok: CSRF / origin protection left at its secure default (enabled). The app// simply lists the origins it trusts instead of disabling the check.export const auth = betterAuth({ trustedOrigins: ["https://app.example.com"], advanced: { useSecureCookies: true, },});export const auth2 = betterAuth({ advanced: { // ok: explicitly keeping the checks on disableCSRFCheck: false, disableOriginCheck: false, },});
Suppressing this rule
If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.