github svrforum/NginxProxyGuard v2.13.7

latest releases: v2.72.10, v2.72.9, v2.72.8...
7 months ago

🛡️ Security Hardening — Dotenv File Access Blocking

Problem

Users reported that /.env (and common variants like /.env.local, /.env.production) were not blocked by NPG's default exploit rules and instead passed through to the upstream application. Investigation showed two gaps:

  1. Redirect hosts include block_exploits.conf but that file had no .env rule.
  2. Proxy hosts use DB-driven exploit_block_rules which had no path-based (request_uri) rule for .env. The only defence was OWASP CRS — which doesn't block when the host's WAF mode is DetectionOnly.

Fix

  • ENV-001 rule added to nginx/includes/block_exploits.conf covering /.env, /.env.local, /.env.production, /.env.backup, /.env.example, nested /path/.env, etc. (does NOT match /environment.txt — no false positives).
  • Dotenv File Access seed rule added to exploit_block_rules table (pattern_type=request_uri, pattern=/\.env(\.|$|/), category rfi). Proxy hosts with block_exploits enabled now drop .env requests regardless of WAF mode.
  • Nginx entrypoint update_managed_includes() added — syncs includes/*.conf from image defaults on every startup (following the existing update_modsec_configs / update_static_html pattern). Without this, upgraders would keep the stale block_exploits.conf baked into their /etc/nginx volume and never pick up ENV-001.

Migration Behaviour

  • Fresh install: rule seeded from 001_init.sql.
  • Existing install (pre-v2.13.7): rule backfilled via ON CONFLICT DO NOTHING migration entry; admin edits preserved.
  • On startup, SyncAllConfigs regenerates every proxy_host nginx config and the new rule is applied immediately.

Verification (dev env)

Access log with primary block:

GET /.env HTTP/1.1 403 ... block=\"exploit_block\" exploit_rule=\"c1e7f001-0000-4000-8000-000000000001\"

Upgrade

docker compose pull && docker compose up -d

Docker Images

docker pull svrforum/nginxproxyguard-api:2.13.7
docker pull svrforum/nginxproxyguard-ui:2.13.7
docker pull svrforum/nginxproxyguard-nginx:2.13.7

Architectures: linux/amd64, linux/arm64

Component Status
API Built
UI Built
Nginx Built

Don't miss a new NginxProxyGuard release

NewReleases is sending notifications on new releases.