aboutsummaryrefslogtreecommitdiff
path: root/contrib/webmentions-ssg.example.cfg
diff options
context:
space:
mode:
authorDennis Fink2026-10-31 19:33:49 +0100
committerDennis Fink2026-10-31 19:33:49 +0100
commit3a3284abe23e143cbb638877f47958c82afa3367 (patch)
tree5409bb940d252756f502d545cc145b382f06a3a0 /contrib/webmentions-ssg.example.cfg
parent40bdba0f2aa132f47326d2591e83039249ae2121 (diff)
downloadwebmentions-ssg-3a3284abe23e143cbb638877f47958c82afa3367.tar.gz
webmentions-ssg-3a3284abe23e143cbb638877f47958c82afa3367.zip
fix(core): harden login rate limiting behind proxies
Trust forwarded client addresses only for an explicitly configured number of reverse-proxy hops so per-IP limits cannot be bypassed or collapsed in proxied deployments. Add a separate hashed per-username login limit across IPs to reduce distributed credential-guessing attempts without storing raw usernames in limiter keys.
Diffstat (limited to 'contrib/webmentions-ssg.example.cfg')
-rw-r--r--contrib/webmentions-ssg.example.cfg15
1 files changed, 14 insertions, 1 deletions
diff --git a/contrib/webmentions-ssg.example.cfg b/contrib/webmentions-ssg.example.cfg
index 577eeef..a5dbaf9 100644
--- a/contrib/webmentions-ssg.example.cfg
+++ b/contrib/webmentions-ssg.example.cfg
@@ -26,6 +26,14 @@ BOOTSTRAP_SERVE_LOCAL = True
# Upgrading to password-bound sessions also requires users to sign in again once.
SECRET_KEY = "REPLACE_WITH_A_LONG_RANDOM_SECRET"
+# When deployed behind a trusted reverse proxy, set this to the EXACT number
+# of trusted hops that set X-Forwarded-For and X-Forwarded-Proto. Use 1 for a
+# single nginx instance directly in front of the application; 0 (default)
+# ignores forwarded headers. Do not enable this if the backend is reachable
+# directly or if the proxy fails to overwrite untrusted forwarded headers.
+# See README.md for an nginx example and multi-proxy caveats.
+PROXY_FIX_TRUSTED_HOPS = 0
+
# ---------------------------------------------------------------------------
# Database and logging
# ---------------------------------------------------------------------------
@@ -100,8 +108,13 @@ ENDPOINT_GLOBAL_RATE_LIMIT = "1000/hour"
# Minimum seconds between verifications of the same source/target pair.
ENDPOINT_REVERIFY_COOLDOWN_SECONDS = 600
-# Limit login POST attempts per client.
+# Limit login POST attempts per client IP, and separately for each submitted
+# username across IPs (case-folded and hashed before being used as a key).
+# Both limits apply to POSTs, even unsuccessful validation attempts. A per-user
+# bucket can be deliberately exhausted to temporarily deny that account login;
+# keep its allowance higher than the per-IP limit and monitor for abuse.
LOGIN_RATE_LIMIT = "5/minute;30/hour"
+LOGIN_USERNAME_RATE_LIMIT = "20/minute;100/hour"
# ---------------------------------------------------------------------------
# Sending Webmentions from a statically generated site