Back to Checks
supabase

Supabase project restricts database access to allowed IP ranges

database_network_restrictions_configured
Service: databaseSeverity: high
OfficialVerifiedPrivate
Categories:internet-exposedtrust-boundaries
Resource Type:SupabaseProject

Checks that the project's network restrictions limit direct Postgres connections to allowed IPv4 and IPv6 ranges. An empty list, 0.0.0.0/0 or ::/0 lets every address in.

Prowler logoProwlerprowler-provider-supabase

Risk

An unrestricted database accepts connection attempts from the whole internet. A leaked or weak database password is then enough to read or change every table.

Run this check with Prowler

Run in Prowler Cloud
Run
prowler supabase --checks database_network_restrictions_configured

Recommendation

Allow direct database connections only from the IP ranges of your servers, CI and administrators, for both IPv4 and IPv6.

Remediation

Other

1In the Supabase dashboard, open Project Settings > Database
2Under Network Restrictions, add the IPv4 and IPv6 ranges that need direct access
3Remove any range that allows every address

Check Code

from prowler.lib.check.models import Check

from prowler_provider_supabase.check_report import CheckReportSupabase
from prowler_provider_supabase.services.database.database_client import database_client

ALLOW_ALL = {"0.0.0.0/0", "::/0"}


class database_network_restrictions_configured(Check):
    def execute(self) -> list[CheckReportSupabase]:
        findings = []
        for project in database_client.projects:
            if project.ref not in database_client.network_restrictions:
                continue
            restrictions = database_client.network_restrictions[project.ref]
            config = restrictions.get("config") or {}
            # An empty list lets every address of that family in.
            open_families = [
                family
                for family, cidrs in (
                    ("IPv4", config.get("dbAllowedCidrs") or []),
                    ("IPv6", config.get("dbAllowedCidrsV6") or []),
                )
                if not cidrs or ALLOW_ALL & set(cidrs)
            ]
            report = CheckReportSupabase(metadata=self.metadata(), resource=project)
            if not open_families:
                report.status = "PASS"
                report.status_extended = (
                    f"Project {project.name} restricts database connections to "
                    "allowed IPv4 and IPv6 ranges."
                )
            else:
                report.status = "FAIL"
                report.status_extended = (
                    f"Project {project.name} accepts database connections from any "
                    f"{' and '.join(open_families)} address."
                )
            findings.append(report)
        return findings