pitcheye.dev← All 30 rules
severity: errorpack: supabase-authv1.0 core

supabase-auth/server-get-session

`supabase.auth.getSession()` used on the server

npx @pitcheye/check . --pack supabase-auth

whyItBreaks

On the server `getSession()` reads the session out of the request cookie without verifying its signature. Any caller can forge the cookie and be treated as that user. Supabase documents it as untrusted on the server and it is the single most-exploited mistake in this migration.

✖ Bad — triggers errorfixtures/supabase-auth-server-get-session/bad
const { data: { session } } = await supabase.auth.getSession();
✓ Good — passes checkfixtures/supabase-auth-server-get-session/good
const { data: { user } } = await supabase.auth.getUser();

suggestedFix

Use `const { data: { user } } = await supabase.auth.getUser()`, which round-trips to the Auth server and validates the JWT before you trust it.

explain_rule({"supabase-auth/server-get-session"})

Agent & MCP JSON output contract

{
  "ruleId": "supabase-auth/server-get-session",
  "pack": "supabase-auth",
  "severity": "error",
  "file": "apps/web/src/app/dashboard/page.tsx",
  "line": 6,
  "message": "`.auth.getSession()` in a file that runs on the server",
  "whyItBreaks": "On the server `getSession()` reads the session out of the request cookie without verifying its signature. Any caller can forge the cookie and be treated as that user. Supabase documents it as untrusted on the server and it is the single most-exploited mistake in this migration.",
  "suggestedFix": "Use `const { data: { user } } = await supabase.auth.getUser()`, which round-trips to the Auth server and validates the JWT before you trust it.",
  "docsUrl": "https://pitcheye.dev/rules/supabase-auth-server-get-session"
}

Markdown: curl -H "Accept: text/markdown" https://pitcheye.dev/rules/supabase-auth-server-get-session

raw markdown
# supabase-auth/server-get-session

- **severity:** error
- **pack:** supabase-auth
- **docs:** https://pitcheye.dev/rules/supabase-auth-server-get-session

## whyItBreaks

On the server `getSession()` reads the session out of the request cookie without verifying its signature. Any caller can forge the cookie and be treated as that user. Supabase documents it as untrusted on the server and it is the single most-exploited mistake in this migration.

## bad

```ts
const { data: { session } } = await supabase.auth.getSession();
```

## good

```ts
const { data: { user } } = await supabase.auth.getUser();
```

## suggestedFix

Use `const { data: { user } } = await supabase.auth.getUser()`, which round-trips to the Auth server and validates the JWT before you trust it.

## commands

```bash
npx @pitcheye/check . --pack supabase-auth
```

```json
{"tool":"explain_rule","arguments":{"ruleId":"supabase-auth/server-get-session"}}
```
Back to rule catalogsupabase-auth/deprecated-auth-helpers →