ssrf

package
v1.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package ssrf guards outbound webhook and notification delivery against server-side request forgery: a user-supplied URL that points at loopback, the LAN, or a cloud metadata endpoint (169.254.169.254). It offers a create-time URL check for fast feedback and a dial-time Control hook that is the actual security boundary — the hook runs after DNS resolution on the concrete address being dialed, so it also defeats DNS rebinding.

Index

Constants

This section is empty.

Variables

View Source
var ErrBlockedAddress = errors.New("URL must not resolve to a private or internal IP address")

ErrBlockedAddress is returned when a URL resolves to, or a connection targets, an internal/private IP that must not be reachable as a delivery destination.

Functions

func IsBlocked

func IsBlocked(ip net.IP) bool

IsBlocked reports whether ip must not be used as a delivery destination. It rejects loopback, link-local, private (RFC 1918 / ULA), CGNAT (RFC 6598), unspecified, and multicast addresses — the ranges an SSRF payload would use to reach cloud metadata, localhost, or the LAN.

func NewHTTPClient

func NewHTTPClient(timeout time.Duration, allowPrivate bool) *http.Client

NewHTTPClient returns an http.Client whose dialer blocks connections to internal/private IPs on every hop, including redirects. When allowPrivate is true (dev only, via MAINTENANT_ALLOW_PRIVATE_WEBHOOKS) the guard is disabled.

func ValidateURL

func ValidateURL(ctx context.Context, rawURL string) error

ValidateURL fails fast at create time: it requires an https scheme and rejects hostnames that resolve to a blocked IP. It is a fast-feedback guard — the dial-time Control hook is the true security boundary (it also defeats DNS rebinding between validation and delivery).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL