Back to Checks
Supabase project has the legacy JWT-based API keys disabled
api_legacy_keys_disabled
Service: apiSeverity: medium
OfficialVerifiedPrivate
Categories:secrets
Resource Type:SupabaseProject
Checks that the project's legacy API keys (the JWT-based anon and service_role keys) are disabled in favour of the new publishable and secret keys.
Risk
Legacy keys are long-lived JWTs that cannot be rotated without changing the JWT secret, which breaks every other key. A leaked service_role key bypasses RLS until then.
Run this check with Prowler
Run in Prowler CloudInstall
pip install --extra-index-url https://__token__:${PROWLER_REGISTRY_DOWNLOAD_API_KEY}@registry.prowler.com/simple/ "prowler-provider-supabase[runtime]"Run
prowler supabase --checks api_legacy_keys_disabledRecommendation
Migrate to publishable and secret API keys and disable the legacy anon and service_role keys.
Remediation
Other
1Move your apps to the publishable and secret API keys
2In the Supabase dashboard, open Project Settings > API Keys
3Under Legacy API Keys, disable the legacy keys
Check Code
from prowler.lib.check.models import Check
from prowler_provider_supabase.check_report import CheckReportSupabase
from prowler_provider_supabase.services.api.api_client import api_client
class api_legacy_keys_disabled(Check):
def execute(self) -> list[CheckReportSupabase]:
findings = []
for project in api_client.projects:
if project.ref not in api_client.legacy_keys_enabled:
continue
report = CheckReportSupabase(metadata=self.metadata(), resource=project)
if not api_client.legacy_keys_enabled[project.ref]:
report.status = "PASS"
report.status_extended = (
f"Project {project.name} has the legacy anon and service_role "
"API keys disabled."
)
else:
report.status = "FAIL"
report.status_extended = (
f"Project {project.name} has the legacy anon and service_role "
"API keys enabled."
)
findings.append(report)
return findings