MEDIUM AI PREVALENCE: MEDIUM auth.nextauth.session-token-leak
The NextAuth/Auth.js session callback copies an OAuth token onto the session object.
Why AI tools produce this: AI coding tools produce this regularly, typically when prompted for a shortcut or a quick fix.
Why this matters
Whatever the session callback returns is serialized and sent to the browser (and readable by client-side JavaScript), so assigning session.accessToken = token.accessToken exposes a bearer token to every script on the page, including any XSS. Keep access and refresh tokens in the encrypted JWT (the token argument) or a server-side store, and put only non-sensitive fields such as session.user.id or session.user.role on the session.
VULNERABLE
SAFE
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.
// oauthlint-disable-next-line auth.nextauth.session-token-leak -- <reason>