caelum0x b5c41fc7ec fix(rago): outbound webhooks reach public addresses only, pinned, no redirects
The live webhook transport used reqwest::Client::new(): any address,
default redirects, and its own DNS lookup at connect time.

- New shared crate apps/rago/crates/egress-guard (also used by rithub), a
  port of product-analytics net-guard.ts: blocked IPv4 ranges (this network,
  private, CGNAT incl. 100.100.100.200, loopback, link-local incl.
  169.254.169.254, IETF, documentation, 6to4 relay, benchmarking, multicast,
  reserved); IPv6 judged on the IPv4 it carries (mapped, compatible, 6to4),
  otherwise only global unicast 2000::/3 outside 2001::/23, 2001:db8::/32 and
  3fff::/20 (so ::1, ULA incl. fd00:ec2::254, fe80::/10, NAT64 are refused).
  check_url uses the WHATWG parser, so decimal, octal, hex and short IPv4
  spellings are judged as the address they name. resolve_pinned resolves
  once and refuses if any answer is internal; pinned_client connects only to
  those addresses (resolve_to_addrs), follows no redirect, ignores proxies.
- HttpTransport gains post_external (default: post); ReqwestTransport
  overrides it with the guard. Provider and Mint calls are unchanged.
- webhooks::deliver checks the endpoint first (refused: failed, no retry,
  nothing sent) and posts through post_external. RAGO_WEBHOOK_ALLOW_PRIVATE=1
  lifts the address rule for self-hosted receivers (still pinned).

Tests: cargo test -p egress-guard 7/7 (address spellings incl. 2130706433,
0177.0.0.1, 0x7f.1, [::ffff:127.0.0.1], metadata; mixed answers refused;
rebinding: one lookup and the pinned client reaches a host that has no DNS
record; redirect to 127.0.0.1 not followed); cargo test -p rago-integrations
(+ --features live) all green incl. tests/webhook_egress.rs; rago-jobs tests
green; rago-api/rago-jobs check with live. Clippy -D warnings clean on
egress-guard and rago-integrations (with and without live).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 15:16:49 +03:00
..