Tarek Cheikh
Founder & AWS Cloud Architect
Right now, as you read this, there are automated bots scanning the internet for exposed databases. They're looking for RDS instances with weak configurations — and when they find them, the average cost to organizations is $4.88 million per breach (IBM Cost of Data Breach Report 2024).
Here's the terrifying part: most exposed databases aren't intentionally public. They become exposed through a dangerous combination of factors:
The challenge isn't just finding public databases — it's understanding which ones are actually exposed to the internet versus those that are public but properly secured. This distinction is critical and often missed by basic security tools.
Most organizations check database security like this:
This approach misses the real security picture. A database marked as "private" can still be exposed if it's in a public subnet with poor routing. A "public" database might be perfectly secure if its security groups only allow specific application servers to connect.
The RDS Detective tool answers these questions automatically, continuously, and at scale.
Your team spins up a test database for a new feature. To simplify testing, they:
Two months later, this "temporary" database contains a copy of production data for "realistic testing." It's now a ticking time bomb.
During a cloud migration, databases are recreated with scripts. The scripts work perfectly, except:
Post-migration validation checks if databases exist and respond — not if they're secure.
Your company acquires another organization. You inherit their AWS accounts containing:
Without automated scanning, these unknown databases remain exposed indefinitely.
The RDS Detective solves these problems by performing multi-dimensional security analysis that goes beyond simple configuration checks.
The tool first discovers every RDS instance across all AWS regions. Many breaches occur in "forgotten" regions where development or testing happened months ago.
What this finds: Databases in regions like ap-south-1 or sa-east-1 that your team forgot existed.
Instead of just checking the PubliclyAccessible flag, the tool analyzes:
What this reveals: The difference between "configured as public" and "actually exposed to the internet."
The tool assigns risk levels based on multiple factors:
Why this matters: You can focus on the databases that actually pose risk, not waste time on false positives.
For each issue found, the tool generates exact AWS CLI commands to fix the problem. No guessing, no manual lookup — just copy, paste, and execute.
Before running the scanner, ensure you have:
# Get the RDS Detective tool
git clone https://github.com/TocConsulting/aws-helper-scripts.git
cd aws-helper-scripts/check-public-rds
# Install dependencies
pip install -r requirements.txt
# Run comprehensive security scan across all regions
python check_public_rds_cli.py --all-regions
The scanner provides a clear security assessment:
================================================================================
RDS SECURITY ASSESSMENT SUMMARY
================================================================================
Total RDS Instances: 5
Publicly Accessible: 2
Encrypted Storage: 3
Critical Risk: 1
High Risk: 1
Medium Risk: 2
================================================================================
PUBLICLY ACCESSIBLE INSTANCES (IMMEDIATE ATTENTION REQUIRED)
================================================================================
Identifier Region Engine Risk Endpoint
------------------------------------------------------------------------------------------
prod-mysql-db us-east-1 mysql Critical mydb.cluster-xyz.us-east-1.rds.amazonaws.com
-- Open to Internet (0.0.0.0/0) - tcp 3306
Remediation commands:
1. Make RDS instance private
2. Remove open access from security group
staging-postgres us-west-1 postgres High staging.xyz.us-west-1.rds.amazonaws.com
-- Large network access (10.0.0.0/16) - tcp 5432
Remediation commands:
1. Make RDS instance private
================================================================================
UNENCRYPTED INSTANCES
================================================================================
legacy-mysql-db (us-east-1) - mysql
test-db (us-west-2) - postgres
The tool uses visual indicators to help you quickly identify issues:
For Security Teams — Immediate Risk Assessment:
# Find all internet-exposed databases NOW
python check_public_rds_cli.py --all-regions --public-only
# Generate remediation script
python check_public_rds_cli.py --all-regions --export-remediation fix_databases.sh
# Execute fixes
bash fix_databases.sh
For Compliance Audits — Documentation:
# Generate comprehensive security report
python check_public_rds_cli.py --all-regions --export-csv rds_audit_Q4_2024.csv
# Create JSON for SIEM integration
python check_public_rds_cli.py --all-regions --export-json rds_security.json
For DevOps — Pre-deployment Validation:
# Check specific region after deployment
python check_public_rds_cli.py --region us-east-1 --public-only
While manual scans catch current issues, databases can become exposed at any time. The Lambda version provides 24/7 automated monitoring.
The Reality: Database configurations change constantly:
The Solution: The Lambda version runs automatically (daily/weekly), scanning all databases and alerting only on critical issues.
# Navigate to Lambda version
cd ../check-public-rds-lambda
# Configure your settings
# Edit template.yaml:
# - AlertEmail: security-team@company.com
# - ScanSchedule: rate(1 day) # or cron(0 9 ? * MON *)
# Deploy the monitoring system
sam build && sam deploy --guided
What Gets Deployed:
The Lambda version sends targeted alerts to avoid alert fatigue:
Critical Alert (Immediate Action Required):
Subject: CRITICAL: Internet-Exposed Database Detected
prod-customer-db is exposed to the internet!
Region: us-east-1
Risk: Port 5432 accessible from 0.0.0.0/0
Data Classification: Customer PII
IMMEDIATE ACTIONS:
1. Execute these commands NOW:
aws rds modify-db-instance \
--db-instance-identifier prod-customer-db \
--no-publicly-accessible \
--region us-east-1
2. Review access logs for unauthorized connections
3. Rotate database credentials
4. Notify security team lead
Weekly Summary (Trending and Compliance):
Subject: Weekly RDS Security Report
Summary:
- Total Databases: 47
- New This Week: 3
- Fixed This Week: 2
- Compliance Rate: 95.7% (up from 93.2%)
Action Items:
- 2 databases still need remediation
- 5 databases missing encryption
- Review attached detailed report
Morning — Discovery:
Afternoon — Immediate Remediation:
Day 2–3:
Day 4–5:
Weekly:
Monthly:
Quarterly:
The RDS Detective doesn't just find problems — it tells you exactly how to fix them.
When the scanner finds an exposed database, it provides:
# CRITICAL: prod-customer-db exposed to internet
# Generated remediation commands:
# Step 1: Remove internet access immediately
aws ec2 revoke-security-group-ingress \
--group-id sg-0123456789abcdef \
--protocol tcp \
--port 5432 \
--cidr 0.0.0.0/0 \
--region us-east-1
# Step 2: Make database private
aws rds modify-db-instance \
--db-instance-identifier prod-customer-db \
--no-publicly-accessible \
--apply-immediately \
--region us-east-1
# Step 3: Add specific application access
aws ec2 authorize-security-group-ingress \
--group-id sg-0123456789abcdef \
--source-group sg-app-servers \
--protocol tcp \
--port 5432 \
--region us-east-1
The order matters — remove risk first, then add proper access.
The RDS Detective identifies real security issues based on actual configurations:
Track these metrics to demonstrate the value of automated database security:
Week 1:
Month 1:
Quarter 1:
In Episode 4, we'll tackle another massive security risk: exposed S3 buckets. You'll learn how to build scanners that find publicly accessible buckets, analyze their policies, and prevent the data leaks that make headlines. We'll go beyond simple ACL checks to understand object-level permissions, bucket policies, and cross-account access.
All tools from this series are production-ready and available at https://github.com/TocConsulting/aws-helper-scripts. Both CLI and Lambda versions are thoroughly tested and include comprehensive documentation.
This article is just the start. Get the full picture with our free whitepaper - 8 chapters covering IAM, S3, VPC, monitoring, agentic AI security, compliance, and a prioritized action plan with 50+ CLI commands.
Stop sending your IAM policies, CloudTrail logs, and infrastructure code to third-party APIs. Run LLMs locally with Ollama on Apple Silicon — private, offline, fast. Complete setup guide with AWS security use cases.
We obtained the actual compromised litellm packages, set up a disposable EC2 instance with honeypot credentials and mitmproxy, and detonated the malware. Full evidence: fork bomb, credential theft in under 2 seconds, IMDS queries, AWS API calls, and C2 exfiltration.
A deep technical breakdown of how threat actor TeamPCP compromised Trivy, pivoted to LiteLLM, and turned a popular AI proxy into a credential-stealing weapon targeting AWS IMDS, Secrets Manager, and Kubernetes.