# Supabase Secret Scanner (`nacred_corner/supabase-secret-scanner`) Actor

Scan a GitHub user or organization for committed Supabase service_role keys before someone else finds them. Decodes JWT payloads (ignores the public anon key), checks .env files, NEXT_PUBLIC\_ leaks, MCP configs, and hardcoded keys in source. Built for pre-launch self-audits.

- **URL**: https://apify.com/nacred_corner/supabase-secret-scanner.md
- **Developed by:** [Cenk KURTOĞLU](https://apify.com/nacred_corner) (community)
- **Categories:** Developer tools
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Supabase Secret Scanner (Apify Actor)

Scan a GitHub user or organization for **committed Supabase service_role keys** before someone else finds them.

### What it checks

| Rule | Severity | What it means |
|---|---|---|
| `SERVICE_ROLE_JWT_LITERAL` | critical | A service_role JWT is hardcoded in source. It bypasses every RLS policy. |
| `SERVICE_KEY_IN_ENV_FILE` | high | A committed `.env*` file holds a service_role key. It lives in git history even after deletion. |
| `NEXT_PUBLIC_SERVICE_ROLE_NAME` | critical | A `NEXT_PUBLIC_` variable is named for the service role — it ships to every browser. |
| `NEXT_PUBLIC_JWT_NOT_ANON` | critical | A `NEXT_PUBLIC_` variable carries a non-anon Supabase JWT. |

The scanner **decodes JWT payloads** and only reports non-anon roles — the public anon/publishable key is never a finding.

### Input

| Field | Required | Default | Notes |
|---|---|---|---|
| `githubTarget` | yes | — | GitHub user or organization login |
| `targetType` | no | `user` | `user` or `org` |
| `githubToken` | yes | — | Your personal access token (read-only scope is enough) |
| `maxRepos` | no | `30` | Stops after N repositories (sorted by last push) |
| `maxFilesPerRepo` | no | `200` | Caps scanned files per repository |
| `includeForks` | no | `false` | Include forked repositories |

### Output

One dataset item per finding (repository, file, rule, severity, redacted evidence, fix hint), plus a `_type: "summary"` record with totals and a verdict.

### Important limits

- Scans the **default branch tree** of public repositories. Git history and private repositories are not covered.
- The GitHub token you provide is used only for API rate limits and stays in your own Apify account.
- Evidence is redacted (first 6 characters + length). Nothing sensitive leaves the scan.

### Fix (2 minutes, do it now if you got findings)

1. Supabase Dashboard → Project Settings → API → **rotate the service_role key**.
2. Move the new key to a runtime-only environment variable (server-side).
3. Deleting the committed file is not enough — the key stays in git history until rotated.

# Actor input Schema

## `githubTarget` (type: `string`):

GitHub login whose public repos are scanned, e.g. your-org.

## `targetType` (type: `string`):

Whether githubTarget is a user or an organization.

## `githubToken` (type: `string`):

Your personal access token, read-only scope is enough. Stored only in your own Apify account.

## `maxRepos` (type: `integer`):

Stops after this many scanned repositories.

## `maxFilesPerRepo` (type: `integer`):

Caps .env and source files fetched per repo.

## `includeForks` (type: `boolean`):

Also scan forked repositories.

## Actor input object example

```json
{
  "targetType": "user",
  "maxRepos": 30,
  "maxFilesPerRepo": 200,
  "includeForks": false
}
```

# Actor output Schema

## `repository` (type: `string`):

Full name of the scanned repository

## `html_url` (type: `string`):

Link to the repository

## `pushed_at` (type: `string`):

When the repository was last pushed

## `severity` (type: `string`):

Finding severity

## `rule` (type: `string`):

Detection rule, e.g. SERVICE_ROLE_JWT_LITERAL

## `file` (type: `string`):

File path containing the finding

## `detail` (type: `string`):

Human-readable explanation

## `evidence` (type: `string`):

Redacted evidence, first 6 chars + length

## `fix_hint` (type: `string`):

Concrete remediation steps

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("nacred_corner/supabase-secret-scanner").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("nacred_corner/supabase-secret-scanner").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call nacred_corner/supabase-secret-scanner --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nacred_corner/supabase-secret-scanner"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/5bfAn1joaEh8Ukc07/builds/TBCUAOi7WqvZtxhXf/openapi.json
