Make TRUSTED_PROXIES' insecure-by-default risk loudly visible (#94)
TRUSTED_PROXIES ships empty in .env.example, which disables AuthMiddleware's reverse-proxy allowlist entirely — a fresh deployment that doesn't explicitly set it has zero verification that Remote-User/Remote-Groups headers actually came from the trusted Authelia proxy. Anything that can reach the app directly (a misconfigured firewall rule, an exposed container port, SSRF from another internal service) can set Remote-User: admin and fully impersonate any user with zero authentication. The enforcement logic itself was already correct; this was purely a dangerous, easy-to-miss default. Added a boxed, unmissable warning around TRUSTED_PROXIES in .env.example (previously just an inline comment easy to skim past), added the same warning to README's setup instructions (which didn't mention this variable at all), and added a Check 8 to api/health.php that reports a 'warning' status when TRUSTED_PROXIES is empty, so a deployment that forgets it doesn't go unnoticed after the fact. Verified against real MariaDB via a running server: the health endpoint correctly reports 'warning' when empty and 'ok' once set. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lhz7pGMaoTfL5sdYS5XiKv
This commit is contained in:
+11
-4
@@ -49,19 +49,26 @@ APP_DOMAIN=
|
||||
; Include all domains that can access this application
|
||||
ALLOWED_HOSTS=localhost,127.0.0.1
|
||||
|
||||
; ============================================================================
|
||||
; REQUIRED FOR PRODUCTION -- READ BEFORE DEPLOYING -- TRUSTED_PROXIES
|
||||
; ============================================================================
|
||||
; Trusted reverse proxy IPs, comma-separated -- e.g. the Authelia/nginx proxy.
|
||||
; Set this to the IP address(es) of your reverse proxy. Authelia forward-auth
|
||||
; headers (Remote-User / Remote-Groups) and forwarded client IPs are only
|
||||
; trusted when REMOTE_ADDR is in this list.
|
||||
;
|
||||
; Leaving this EMPTY disables reverse-proxy verification entirely: the app then
|
||||
; trusts Remote-User / Remote-Groups headers from ANY source. That is unsafe if
|
||||
; the PHP backend is reachable directly (bypassing the proxy), because a client
|
||||
; can then spoof those headers and log in as an admin. Only leave it empty when
|
||||
; network topology guarantees PHP is reachable solely via the trusted proxy.
|
||||
; trusts Remote-User / Remote-Groups headers from ANY source. If the PHP
|
||||
; backend is reachable directly -- a misconfigured firewall rule, a container
|
||||
; network accidentally exposing the port, SSRF from another internal service
|
||||
; -- ANYONE can set Remote-User: admin themselves and fully impersonate any
|
||||
; user, including an admin, with ZERO authentication. Only leave it empty when
|
||||
; network topology guarantees PHP is reachable solely via the trusted proxy
|
||||
; (e.g. local development), never in a real deployment.
|
||||
;
|
||||
; Exact IP match only (no CIDR). Example (single proxy): TRUSTED_PROXIES=10.10.10.27
|
||||
; Example (multiple): TRUSTED_PROXIES=10.10.10.27,10.10.10.28
|
||||
; ============================================================================
|
||||
TRUSTED_PROXIES=
|
||||
|
||||
; Timezone (default: America/New_York)
|
||||
|
||||
Reference in New Issue
Block a user