fix(webhooks): set trust proxy and resolve client IP via req.ip#427
Merged
Conversation
Both webhook servers sit behind one XFF-writing hop (nginx ingress; the
DO LB is L4). Without trust proxy, express-rate-limit keyed every sender
into one bucket on the LB socket, and the IP allowlists resolved the
client via request-ip, which prefers the leftmost X-Forwarded-For entry
— forgeable by any caller once an allowlist is enabled.
- app.set("trust proxy", 1) on the Bridge and IBEX webhook servers
- ibex.webhook.allowedIps and the Bridge replay allowlist now match on
req.ip (rightmost untrusted XFF hop) with socket-address fallback
- loopback replay exemption unchanged: socket address only
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
bobodread876
approved these changes
Jul 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Launch-hardening follow-up from the #413 merge (tracked as a pre-cutover deploy item).
Both the Bridge and IBEX webhook servers run behind exactly one XFF-writing hop (nginx ingress; the DO load balancer is L4). Without
trust proxy:ibex.webhook.allowedIps, Bridge replayBRIDGE_WEBHOOK_REPLAY_ALLOWED_IPS) resolved the client withrequest-ip, which prefers the leftmostX-Forwarded-Forentry — any caller can forge that to an allowlisted IP once an allowlist is enabled.Changes
app.set("trust proxy", 1)on both webhook servers (trust exactly the one ingress hop; client-forged XFF entries stay untrusted).req.ip(rightmost untrusted XFF entry) with a socket-address fallback, replacingrequest-ipinvalidateIbexIpandreplayIngressMiddleware.validate: { xForwardedForHeader: false }on the limiters as a safety net: a future trust-proxy misconfiguration degrades to a shared bucket instead of a webhook outage.Testing
TEST=webhook-server npm run test:unit— 8 suites, 85 tests pass (replay ingress specs updated to thereq.ipsemantics, plus a new socket-fallback case).npx tsc --noEmitclean.Deploy notes
Pairs with the remaining pre-cutover config item: populate
ibex.webhook.allowedIpswith IBEX's published webhook IPs (allowlist is intentionally fail-open while empty).🤖 Generated with Claude Code