security: reject hostile tokens cleanly and record webhook sources

secrets.compare_digest raises TypeError on str containing non-ASCII, so a
webhook path token or header token with one answered 503/500 instead of
401/403 — a scanner manufactured a false money-critical alert on 2026-11-20.
Compare UTF-8 bytes through _secret_eq and fail closed on empty.

webhook_failures now stores ip and user_agent; the sweep email names each
source and distinguishes a probe from an Open Collective delivery.
This commit is contained in:
inference-admin committed 2026-11-20 20:08:12 +00:00
1 parent 347f2cf720
commit 34f2eeddd7
3 files changed
+223 -24

No files matched your search

+4 -1
View File
@@ -224,7 +224,10 @@ Four jobs run inside the container via `CloudronManifest.json` → `addons.sched
webhook wrapper, including the 401 that means the webhook URL and
`WEBHOOK_TOKEN` disagree) and the sweep emails `info@` **once per new batch**
via a marker in `portal_state`, so a wrong token does not mail every sweep while
the rows stay queryable. This replaces the log-scraping watcher that used to run
the rows stay queryable. Each row carries the source IP and user-agent, and the
email names the source: Open Collective posts from its own hosts, so a refusal
from an unrelated address is a probe, not a purchase. This replaces the
log-scraping watcher that used to run
on the operator's machine: the portal handles every delivery, so the portal is
what must notice and report a failure. (It also removes the dependency on a log
buffer with only hours of memory — when the 2026-11-13 $10 purchase was