-
Notifications
You must be signed in to change notification settings - Fork 51
CRE-2025-0163: Supabase Self-Hosted Critical Failures - Comprehensive Detection #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
piyzard
wants to merge
2
commits into
prequel-dev:main
Choose a base branch
from
piyzard:supabase-cre-demo-163
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
rules: | ||
- cre: | ||
id: CRE-2025-0163 | ||
severity: 0 | ||
title: Supabase self-hosted deployment critical failures - comprehensive detection | ||
category: baas-problem | ||
tags: [supabase, supabase-auth, supabase-db, supabase-storage, supabase-realtime, supabase-api, postgres, container-port-conflict, jwt-validation, rate-limiting, ssl-certificate, disk-full, sql-migration, s3, timeout, misconfiguration] | ||
author: prequel-dev/cre | ||
description: | | ||
Comprehensive detection of high-severity Supabase self-hosted deployment failures including: | ||
- PostgreSQL container port binding conflicts preventing database startup | ||
- Missing or invalid JWT secrets breaking authentication | ||
- Database connection timeouts causing service degradation | ||
- S3 storage misconfigurations blocking file operations | ||
- Realtime service configuration errors preventing websocket connections | ||
- SQL migration syntax failures corrupting database schema | ||
- Auth service port conflicts and API rate limiting | ||
- Critical infrastructure failures: disk space exhaustion and SSL certificate issues | ||
|
||
These failures can render entire Supabase deployments non-functional and require immediate attention. | ||
cause: | | ||
Multiple potential failure modes in Supabase self-hosted environments: | ||
|
||
Infrastructure Issues: | ||
- Port 5432 (PostgreSQL) or 9999 (Auth) already bound by other processes | ||
- Disk space exhaustion during migrations or operations | ||
- SSL certificates expired, invalid, or missing | ||
|
||
Configuration Problems: | ||
- Missing or invalid JWT_SECRET environment variable | ||
- Incorrect S3 credentials or bucket configuration | ||
- Database connection string misconfigurations | ||
- Invalid websocket or realtime service settings | ||
|
||
Application-Level Failures: | ||
- SQL syntax errors in migration files | ||
- Database connection pool exhaustion | ||
- API rate limits exceeded during peak usage | ||
- TLS handshake failures due to certificate issues | ||
impact: | | ||
Complete service unavailability and critical system failures: | ||
- Supabase services unable to start due to port conflicts | ||
- Authentication system completely broken, blocking all user access | ||
- Database operations failing with timeouts and connection errors | ||
- File upload/download completely non-functional | ||
- Real-time features (subscriptions, presence) unavailable | ||
- API requests failing with 429, 500, or SSL errors | ||
- Database schema deployment failures causing data corruption | ||
- Security vulnerabilities from insecure connections | ||
- Potential data loss from incomplete operations | ||
- Business operations completely halted | ||
mitigation: | | ||
Immediate Response Actions: | ||
1. Port Conflicts: Check `lsof -i :5432` and `lsof -i :9999`, stop conflicting services | ||
2. JWT Secrets: Generate secure secret with `openssl rand -base64 64` | ||
3. Database: Monitor connections with `SELECT count(*) FROM pg_stat_activity;` | ||
4. Storage: Verify S3 credentials and bucket access with AWS CLI | ||
5. SSL: Renew certificates and verify chain with `openssl verify` | ||
6. Disk Space: Check `df -h`, clean up with `docker system prune -a` | ||
7. Migrations: Test SQL syntax in development before applying | ||
8. Rate Limits: Implement exponential backoff and request throttling | ||
|
||
Long-term Prevention: | ||
- Set up monitoring and alerting for all critical components | ||
- Implement automated certificate renewal | ||
- Configure log rotation and disk space monitoring | ||
- Use infrastructure as code for consistent deployments | ||
- Establish proper testing pipelines for migrations | ||
applications: | ||
- name: supabase | ||
version: ">= 0.1.0" | ||
- name: postgresql | ||
version: ">= 13.0" | ||
- name: docker | ||
version: ">= 20.10.0" | ||
- name: gotrue | ||
version: ">= 2.0.0" | ||
references: | ||
- "https://supabase.com/docs/guides/self-hosting/docker#troubleshooting" | ||
- "https://github.com/supabase/supabase/discussions" | ||
- "https://supabase.com/docs/guides/platform/performance" | ||
scores: | ||
cvss: "9.1" | ||
cvss_severity: "CRITICAL" | ||
cwe: "CWE-665" | ||
metadata: | ||
kind: prequel | ||
id: G5stYEGyQoDEGGaCbZLKdT | ||
gen: 1 | ||
rule: | ||
set: | ||
event: | ||
source: cre.log.supabase | ||
match: | ||
- regex: '.*(Error: listen EADDRINUSE.*:(5432|9999)|bind: address already in use|port.*already allocated|JWT_SECRET.*not set|invalid.*jwt.*secret|JWT secret.*too short|connection.*timeout|could not connect.*database|timeout expired|S3.*AccessDenied|InvalidAccessKeyId|NoSuchBucket|Realtime.*failed to start|websocket.*connection.*refused|ERROR.*syntax error.*at or near|migration.*failed.*invalid.*SQL|relation.*does not exist|429.*Too Many Requests|Rate limit exceeded|No space left on device|SSL.*certificate.*expired|certificate verify failed|TLS.*handshake.*failed).*' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# PostgreSQL Port Conflicts | ||
2025-08-31T10:15:23.456Z ERROR: listen EADDRINUSE: address already in use :::5432 | ||
2025-08-31T10:15:25.789Z ERROR: docker: Error response from daemon: bind: address already in use | ||
|
||
# JWT Secret Issues | ||
2025-08-31T10:20:15.123Z ERROR: JWT_SECRET environment variable not set | ||
2025-08-31T10:20:17.789Z ERROR: JWT secret is too short, minimum 32 characters required | ||
|
||
# Database Connection Timeouts | ||
2025-08-31T10:25:10.123Z ERROR: connection timeout after 30000ms | ||
2025-08-31T10:25:12.789Z ERROR: timeout expired (PostgreSQL connection) | ||
|
||
# S3 Storage Misconfigurations | ||
2025-08-31T10:30:05.123Z ERROR: S3 operation failed: AccessDenied: Access Denied | ||
2025-08-31T10:30:06.456Z FATAL: InvalidAccessKeyId: The AWS Access Key Id you provided does not exist | ||
|
||
# Realtime Service Errors | ||
2025-08-31T10:35:01.123Z ERROR: Realtime service failed to start: database connection invalid | ||
2025-08-31T10:35:02.456Z WARN: websocket connection refused on port 4000 | ||
|
||
# SQL Migration Failures | ||
2025-08-31T10:40:01.123Z ERROR: syntax error at or near "CRATE" at character 1 | ||
2025-08-31T10:40:03.789Z ERROR: relation "user_profiles" does not exist | ||
|
||
# API Rate Limiting | ||
2025-08-31T10:45:03.789Z WARN: 429 Too Many Requests: Rate limit exceeded for authentication | ||
2025-08-31T10:45:04.234Z ERROR: Rate limit exceeded for auth endpoint | ||
|
||
# Infrastructure Failures | ||
2025-08-31T10:50:01.123Z ERROR: write failed: No space left on device | ||
2025-08-31T10:50:03.789Z ERROR: SSL certificate expired: unable to get local issuer certificate | ||
2025-08-31T10:50:05.567Z ERROR: TLS handshake failed: certificate verification error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tonymeehan troubleshooting docs for reference,
should i change it ?