Syntropy.Webhooks.UrlPolicy (syntropy v0.2.0)

Copy Markdown

SSRF guard for outbound webhook destinations.

Resolves the destination host and rejects addresses that point at the gateway's own network: loopback, RFC1918 private ranges, link-local (including the 169.254.169.254 cloud metadata endpoint), CGNAT, IPv6 unique-local, and their IPv4-mapped IPv6 equivalents.

The guard is enforced twice: when a webhook is registered (fast feedback) and again before every delivery (protects against DNS rebinding). When the host cannot be resolved the policy allows the attempt — the HTTP client will record the resolution failure as a normal delivery error.

SYNTROPY_WEBHOOK_ALLOW_PRIVATE disables the guard for local development; it defaults to true in dev/test and false in production.

Summary

Functions

Validate a webhook destination URL against the private-network policy.

Functions

allow_private?()

@spec allow_private?() :: boolean()

validate(url, opts \\ [])

@spec validate(
  String.t(),
  keyword()
) :: :ok | {:error, String.t()}

Validate a webhook destination URL against the private-network policy.

Options:

  • :allow_private — override the configured escape hatch (test support).