- All Implemented Interfaces:
OutboundEgressGuard
OutboundEgressGuard: classifies a target URI as eligible only when its scheme is
http/https and its host resolves entirely to public addresses. Any private, loopback, link-local,
cloud-metadata (169.254.169.254), carrier-grade-NAT, unique-local, or wildcard address — or a host that
cannot be resolved — yields a denied EgressCheckResult.
This is the network-safety sibling of Validate.requireWithinBase (path-traversal): a
small, dependency-light primitive shared by every module that makes tool-driven outbound calls. It
classifies and never enforces — it does not throw a policy exception; the denied result
carries a non-secret host/reason description, never a request body, header, or secret. Callers own the reaction.
DNS-rebinding: the guard resolves the host and re-checks every resolved address immediately before the caller issues the request (resolve-and-recheck). It does not pin the resolved IP for the connection, so a host that re-resolves to a non-public address between this check and the actual connect is a known residual time-of-check/time-of-use gap; IP-pinning is a future hardening step.
allowPrivateNetworks: when constructed with true the private,
loopback, link-local, and metadata classifications are lifted wholesale — a development-only escape hatch that
disables the cloud-metadata-IP protection. The http/https scheme allowlist is never lifted.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
HttpEgressGuard
public HttpEgressGuard(boolean allowPrivateNetworks) - Parameters:
allowPrivateNetworks- whentrue, lifts the private/loopback/link-local/metadata blocks (development only); the scheme allowlist still applies
-
-
Method Details
-
check
Description copied from interface:OutboundEgressGuardClassifies a target URL.- Specified by:
checkin interfaceOutboundEgressGuard- Parameters:
uri- the absolute target URL; must not benull- Returns:
- an allowed result when the scheme is
http/httpsand the host resolves entirely to public addresses; otherwise a denied result whoseEgressCheckResult.reason()describes the classification
-