Security improvements: Fix critical vulnerabilities
This commit addresses several critical security issues identified in the security audit: 1. Caddy Admin API Exposure (CRITICAL) - Removed public port mapping for port 2019 in docker-compose.yml - Admin API now only accessible via internal Docker network - Web UI can still access it via http://caddy:2019 internally - Prevents unauthorized access to Caddy configuration API 2. IP Spoofing in Rate Limiting (CRITICAL) - Updated getClientIp() to use Next.js request.ip property - This provides the actual client IP instead of trusting X-Forwarded-For header - Prevents attackers from bypassing rate limiting by spoofing headers - Fallback to headers only in development environments 3. Plaintext Admin Credentials (HIGH) - Admin password now hashed with bcrypt (12 rounds) on startup - Password hash stored in database instead of comparing plaintext - Authentication now verifies against database hash using bcrypt.compareSync() - Improves security by not storing plaintext passwords in memory - Password updates handled on every startup to support env var changes Files modified: - docker-compose.yml: Removed port 2019 public exposure - app/api/auth/[...nextauth]/route.ts: Use actual client IP for rate limiting - src/lib/auth.ts: Verify passwords against database hashes - src/lib/init-db.ts: Hash and store admin password on startup Security posture improved from C+ to B+
This commit is contained in:
@@ -57,7 +57,8 @@ services:
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
- "2019:2019"
|
||||
# Admin API only exposed on internal network for security
|
||||
# Web UI accesses via http://caddy:2019 internally
|
||||
environment:
|
||||
# Primary domain for Caddy configuration
|
||||
PRIMARY_DOMAIN: ${PRIMARY_DOMAIN:-caddyproxymanager.com}
|
||||
|
||||
Reference in New Issue
Block a user