Skip to main content
skill CX Codex

supabase-extract-anon-key — Claude Code skill: extract anon key

supabase-extract-anon-key finds the Supabase public API key in client-side code — the one passed to createClient. Needed for RLS testing.

MIT 521 installs ★ 76 updated 2026-01-31

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add yoanbernabeu/supabase-pentest-skills --skill supabase-extract-anon-key -a claude-code
Open on GitHub

What supabase-extract-anon-key does

The skill searches for the Supabase anonymous key in JavaScript files and environment variables like NEXT_PUBLIC_SUPABASE_ANON_KEY or VITE_SUPABASE_ANON_KEY. This key is a JWT with anon role; having it in client code is expected, but only if Row Level Security policies are configured in the database. It decodes the key, checks expiration, saves results to .sb-pentest-context.json, and suggests which skill to run next — for example, supabase-audit-rls.

When multiple keys are found or the role is service_role instead of anon, the skill flags it as critical. Checking obfuscated keys requires FFmpeg and Python.

What it helps with

  • extract Supabase public API key from frontend code
  • check whether the JWT role is anon or service_role
  • decode and validate key expiration
  • write extracted key to context file for subsequent skills
  • detect service_role key leaks in client-side code

Example prompts for the agent

  • Find the Supabase anon key at https://myapp.example.com
  • Extract the public key for project abc123def
  • Check what Supabase key is in main.js

How to install supabase-extract-anon-key

1Skills CLI (Vercel)

npx skills add yoanbernabeu/supabase-pentest-skills --skill supabase-extract-anon-key -a claude-code

2Manually: put the files in place

~/.claude/skills/supabase-extract-anon-key/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/supabase-extract-anon-key/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about supabase-extract-anon-key

How to install supabase-extract-anon-key in Claude Code?

Run npx skills add yoanbernabeu/supabase-pentest-skills --skill supabase-extract-anon-key -a claude-code, then check ~/.claude/skills/supabase-extract-anon-key/SKILL.md.

What does supabase-extract-anon-key do?

It finds the Supabase public API key in client code, decodes it, checks role and expiration, and saves results to .sb-pentest-context.json. Having the anon key in client code is expected when Row Level Security policies are configured.

What is the difference between anon key and service_role?

The anon key can be in client code and operates under RLS restrictions. Service_role grants full database access bypassing policies — it must never be in client code, as that is a critical vulnerability.

Source text

SKILL.md · MIT
---
name: supabase-extract-anon-key
description: Extract the Supabase anon/public API key from client-side code. This key is expected in client apps but important for RLS testing.
---

# Supabase Anon Key Extraction

> 🔴 **CRITICAL: PROGRESSIVE FILE UPDATES REQUIRED**
>
> You MUST write to context files **AS YOU GO**, not just at the end.
> - Write to `.sb-pentest-context.json` **IMMEDIATELY after each discovery**
> - Log to `.sb-pentest-audit.log` **BEFORE and AFTER each action**
> - **DO NOT** wait until the skill completes to update files
> - If the skill crashes or is interrupted, all prior findings must already be saved
>
> **This is not optional. Failure to write progressively is a critical error.**

This skill extracts the Supabase anonymous (public) API key from client-side code.

## When to Use This Skill

- After extracting the Supabase URL, to get the API key for testing
- To verify that only the anon key (not service key) is exposed
- Before running API audit skills that require authentication

## Prerequisites

- Supabase URL extracted (or will auto-invoke `supabase-extract-url`)
- Target application accessible

## Understanding Anon Keys

The **anon key** (also called public key) is:

- ✅ **Expected** to be in client-side code
- ✅ **Safe** when RLS (Row Level Security) is properly configured
- ⚠️ **Risky** if RLS is missing or misconfigured
- ❌ **Not the same** as the service_role key (which should NEVER be in client code)

### Key Format

Supabase anon keys are JWTs:

```
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImFiYzEyMyIsInJvbGUiOiJhbm9uIiwiaWF0IjoxNjQwMDAwMDAwLCJleHAiOjE5NTUzNjAwMDB9.xxxx
```

Key characteristics:
- Starts with `eyJ` (base64 encoded `{"alg":`)
- Contains `"role":"anon"` in payload
- Project reference in `"ref"` claim

## Extraction Patterns

The skill searches for:

### 1. Direct Key Assignment

```javascript
const SUPABASE_KEY = 'eyJhbGci...'
const SUPABASE_ANON_KEY = 'eyJhbGci...'
```

### 2. Client Initialization

```javascript
createClient(url, 'eyJhbGci...')
createClient(url, process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY)
```

### 3. Environment Variable Patterns

```javascript
NEXT_PUBLIC_SUPABASE_ANON_KEY
VITE_SUPABASE_ANON_KEY
REACT_APP_SUPABASE_KEY
SUPABASE_KEY
```

## Usage

### Basic Extraction

```
Extract Supabase anon key from https://myapp.example.com
```

### If URL Already Known

```
Extract anon key for project abc123def
```

## Output Format

```
═══════════════════════════════════════════════════════════
 ANON KEY EXTRACTED
═══════════════════════════════════════════════════════════

 Key Type: anon (public)
 Severity: ℹ️  Expected (verify RLS configuration)

 Key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJz
      dXBhYmFzZSIsInJlZiI6ImFiYzEyM2RlZiIsInJvbGUiOiJhbm
      9uIiwiaWF0IjoxNjQwMDAwMDAwLCJleHAiOjE5NTUzNjAwMDB9
      .xxxxxxxxxxxxx

 Decoded Payload:
 ├── iss: supabase
 ├── ref: abc123def
 ├── role: anon
 ├── iat: 2021-12-20T00:00:00Z
 └── exp: 2031-12-20T00:00:00Z

 Found in:
 └── /static/js/main.js (line 1253)
     createClient('https://abc123def.supabase.co', 'eyJhbGci...')

 Next Steps:
 ├── Run supabase-audit-rls to test if RLS protects your data
 ├── Run supabase-audit-tables-read to see what's accessible
 └── Run supabase-extract-service-key to check for critical leaks

 Context updated: .sb-pentest-context.json
═══════════════════════════════════════════════════════════
```

## Key Validation

The skill validates the extracted key:

```
Validation:
├── Format: ✅ Valid JWT structure
├── Decode: ✅ Payload readable
├── Role: ✅ Confirmed "anon" role
├── Project: ✅ Matches extracted URL (abc123def)
└── Expiry: ✅ Not expired (expires 2031-12-20)
```

## Multiple Keys

If multiple keys are found:

```
═══════════════════════════════════════════════════════════
 MULTIPLE KEYS FOUND
═══════════════════════════════════════════════════════════

 ⚠️  2 potential Supabase keys detected

 1. Anon Key (confirmed)
    └── Role: anon, Project: abc123def

 2. Unknown Key
    └── Role: service_role ⚠️  SEE supabase-extract-service-key
        This may be a CRITICAL security issue!

═══════════════════════════════════════════════════════════
```

## Context Output

Saved to `.sb-pentest-context.json`:

```json
{
  "supabase": {
    "anon_key": "eyJhbGci...",
    "anon_key_decoded": {
      "iss": "supabase",
      "ref": "abc123def",
      "role": "anon",
      "iat": 1640000000,
      "exp": 1955360000
    },
    "anon_key_sources": [
      {
        "file": "/static/js/main.js",
        "line": 1253
      }
    ]
  }
}
```

## Security Assessment

| Finding | Severity | Description |
|---------|----------|-------------|
| Anon key in client | ℹ️ Info | Expected, but test RLS |
| Anon key expired | ⚠️ P2 | Key should be rotated |
| Multiple anon keys | ⚠️ P2 | May indicate key rotation issues |
| Role is not "anon" | 🔴 P0 | Wrong key type exposed! |

## Common Issues

❌ **Problem:** Key found but won't decode
✅ **Solution:** May be obfuscated or split. Try:
```
Extract anon key with deobfuscation from https://myapp.example.com
```

❌ **Problem:** Key doesn't match URL project
✅ **Solution:** App may use multiple Supabase projects. Both keys are recorded.

❌ **Problem:** No key found but Supabase detected
✅ **Solution:** Key may be fetched at runtime. Check network requests:
```
Monitor network for anon key on https://myapp.example.com
```

## Best Practices Reminder

For developers reading this report:

1. **Anon key in client is normal** — It's designed for this
2. **RLS is critical** — The anon key relies on RLS for security
3. **Never use service_role in client** — Use Edge Functions instead
4. **Rotate keys periodically** — Available in Supabase Dashboard

## MANDATORY: Progressive Context File Updates

⚠️ **This skill MUST update tracking files PROGRESSIVELY during execution, NOT just at the end.**

### Critical Rule: Write As You Go

**DO NOT** batch all writes at the end. Instead:

1. **Before starting any action** → Log the action to `.sb-pentest-audit.log`
2. **After each discovery** → Immediately update `.sb-pentest-context.json`
3. **After each significant step** → Log completion to `.sb-pentest-audit.log`

This ensures that if the skill is interrupted, crashes, or times out, all findings up to that point are preserved.

### Required Actions (Progressive)

1. **Update `.sb-pentest-context.json`** with extracted data:
   ```json
   {
     "supabase": {
       "anon_key": "eyJhbGci...",
       "anon_key_decoded": { ... },
       "anon_key_sources": [ ... ]
     }
   }
   ```

2. **Log to `.sb-pentest-audit.log`**:
   ```
   [TIMESTAMP] [supabase-extract-anon-key] [START] Beginning anon key extraction
   [TIMESTAMP] [supabase-extract-anon-key] [SUCCESS] Anon key extracted
   [TIMESTAMP] [supabase-extract-anon-key] [CONTEXT_UPDATED] .sb-pentest-context.json updated
   ```

3. **If files don't exist**, create them before writing.

**FAILURE TO UPDATE CONTEXT FILES IS NOT ACCEPTABLE.**

## MANDATORY: Evidence Collection

📁 **Evidence Directory:** `.sb-pentest-evidence/02-extraction/`

### Evidence Files to Create

| File | Content |
|------|---------|
| `extracted-anon-key.json` | Anon key with decoded JWT payload |

### Evidence Format

```json
{
  "evidence_id": "EXT-ANON-001",
  "timestamp": "2025-01-31T10:07:00Z",
  "category": "extraction",
  "type": "anon_key",
  "severity": "info",

  "key_data": {
    "key_prefix": "eyJhbGciOiJIUzI1NiI...",
    "key_suffix": "...xxxx",
    "full_key_length": 256
  },

  "decoded_payload": {
    "iss": "supabase",
    "ref": "abc123def",
    "role": "anon",
    "iat": "2021-12-20T00:00:00Z",
    "exp": "2031-12-20T00:00:00Z"
  },

  "source": {
    "file": "/static/js/main.js",
    "line": 1253,
    "context": "createClient('https://abc123def.supabase.co', 'eyJhbGci...')"
  },

  "validation": {
    "format_valid": true,
    "role_confirmed": "anon",
    "project_matches": true,
    "expired": false
  }
}
```

## Related Skills

- `supabase-extract-url` — Get URL first (auto-invoked if needed)
- `supabase-extract-service-key` — Check for critical service key leak
- `supabase-audit-rls` — Test if RLS protects your data
- `supabase-audit-tables-read` — See what data is accessible with this key

© yoanbernabeu · MIT · yoanbernabeu/supabase-pentest-skills

Similar skills

All skills for Security →

From the same set24

The whole set →
supabase-audit-tables-read supabase-audit-tables-read — a skill for Claude Code and five other platforms that checks which Supabase tables return data without authentication and tests how well RLS policies hold up. CX Codex +1 533installs supabase-audit-buckets-public supabase-audit-buckets-public scans Supabase storage to identify publicly exposed buckets and flags sensitive files like database backups, environment variables, or private user uploads. CX Codex +1 530installs supabase-audit-auth-users supabase-audit-auth-users is a Claude Code skill that checks Supabase Auth endpoints for user enumeration through error messages and response timing. CX Codex +1 526installs supabase-audit-tables-list supabase-audit-tables-list — a skill for Claude Code and other agents that enumerates tables exposed through the Supabase PostgREST API and ranks them by risk level. Runs before RLS policy testing or public-schema inventory. CX Codex +1 524installs supabase-detect The supabase-detect skill checks a web app for signs of Supabase and records what it finds. Use it before auditing an unfamiliar application. CX Codex +1 520installs supabase-extract-db-string supabase-extract-db-string scans client-side code for PostgreSQL connection strings and exposed Supabase credentials. Use it when auditing an application before release. CX Codex +1 519installs supabase-extract-service-key supabase-extract-service-key scans client-side bundles and source maps for leaked Supabase service_role keys. Useful during security reviews to prevent RLS bypass. CX Codex +1 519installs supabase-audit-buckets-list supabase-audit-buckets-list is a Claude Code skill that inventories Supabase storage buckets and examines their settings. It runs during storage security audits and access reviews. CX Codex +1 518installs

Project sponsors

Companies that keep this analytics open