Class OutboundUriPolicy
Revetsec applies the policy to every URI it is about to fetch, such as an issuer, a JSON Web Key Set and every
endpoint named in remote metadata, before any request is sent. There are two presets:
defaultInstance(), which rejects the addresses and names it knows to reach a machine's own metadata or
configuration services, and publicAddressesOnlyInstance(), which also rejects the local, private-use and
special-use addresses and names it lists. Neither list is exhaustive.
Hostnames are never resolved. The policy looks only at the text of the URI. It classifies IP
address literals, including the all-digit form (https://2852039166/ is 169.254.169.254), and IPv4 addresses
embedded in IPv4-mapped, IPv4-compatible, IPv4-translated and NAT64 IPv6 addresses, and it recognizes special-use
and private-use names by their text, folding ASCII letters only and ignoring one trailing dot. A URI whose host
URI cannot parse, including the short dotted forms https://127.1/ and
https://169.254.43518/ that InetAddress would accept, has no host and is rejected.
The policy cannot see where a DNS name points, so no policy stops a hostname that resolves to a private or metadata
address, or a name whose DNS answer changes between checks (DNS rebinding). A network-specific NAT64 prefix and an
explicit address mapping (RFC 7757) look like ordinary IPv6 addresses, so the policy cannot tell where they lead
either. When the URIs come from someone you do not control, such as a tenant-supplied issuer, send Revetsec's
traffic through an egress proxy that enforces the destinations you allow, by configuring it on the
HttpClient you give Revetsec.
- Since:
- 1.0.0
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull OutboundUriPolicyReturns the default policy.Returns whether this policy permits a request touri.static @NonNull OutboundUriPolicyReturns the policy that permits only globally reachable destinations, as far as the URI's text shows.toString()Returns a description of this policy.
-
Method Details
-
defaultInstance
Returns the default policy.It permits an absolute
httpsorhttpURI whose host is a DNS name or an IP address literal, except:- a link-local literal:
169.254.0.0/16, which includes the common cloud metadata address169.254.169.254, andfe80::/10; - an any-local literal:
0.0.0.0/8(sohttps://0/is rejected) and::; - the known cloud metadata endpoints as of 2026-09-27: the addresses
100.100.100.200(Alibaba Cloud),168.63.129.16(Azure WireServer),fd00:ec2::254(Amazon EC2),fd00:ec2::23(Amazon EKS Pod Identity) andfd20:ce::254(Google Compute Engine, over IPv6), and Google Compute Engine's namesmetadata.google.internalandmetadata.googand every name under them. The list is not exhaustive; - any address in the RFC 8215 local-use NAT64 prefix
64:ff9b:1::/48; - an IPv4-mapped, IPv4-compatible, IPv4-translated or NAT64 Well-Known Prefix IPv6 literal around one of the IPv4 addresses above.
0xa9fea9feor0251.254.169.254, which the JDK refuses by default but passes to the platform resolver whenjdk.net.allowAmbiguousIPAddressLiteralsistrue, and which a proxy or resolver that usesinet_atonreads as169.254.169.254; and an IPv6 literal with a zone ID.Loopback, private, shared (carrier-grade NAT), unique local, 6to4, Teredo, multicast, reserved and other non-global addresses are permitted, and so are
localhostand other local names. Revetsec's HTTP layer separately requireshttps, except that a builder may explicitly allow plainhttpfor tests, to a loopback literal or exactlylocalhostonly.- Returns:
- the default policy; always the same instance
- Since:
- 1.0.0
- a link-local literal:
-
publicAddressesOnlyInstance
Returns the policy that permits only globally reachable destinations, as far as the URI's text shows.It permits an absolute
httpsorhttpURI whose host is either:- an IPv4 literal outside the blocks listed below, or an IPv4-mapped (
::ffff:0:0/96) or NAT64 Well-Known Prefix (64:ff9b::/96) IPv6 literal around one. IPv4 is checked against a list, so a block that IANA marks as not globally reachable after 2026-09-27 is permitted until Revetsec lists it; - an IPv6 literal in the global unicast block
2000::/3, except2001::/23as a whole (which includes Teredo,2001::/32), 6to4 (2002::/16) and the documentation blocks2001:db8::/32and3fff::/20. Everything outside2000::/3is rejected, so an IPv6 block allocated for a special purpose in the future is rejected too; - a DNS name of at least two labels that is none of the names listed below. Other special-use names, such
as
example.com, are permitted.
defaultInstance()rejects, it therefore rejects:- loopback, in every form (
127.0.0.0/8,::1and the IPv6 forms around a loopback IPv4 address); - the private-use blocks
10.0.0.0/8,172.16.0.0/12and192.168.0.0/16, the shared address space100.64.0.0/10and unique local addresses (fc00::/7); - the IPv4 blocks that IANA's special-purpose registry marked as not globally reachable as of 2026-09-27,
such as the documentation and benchmarking blocks, and the deprecated 6to4 relay anycast block
192.88.99.0/24; - multicast and reserved space:
224.0.0.0/4,240.0.0.0/4,255.255.255.255andff00::/8; - 6to4 and Teredo as a whole: the IPv4 address inside them is a tunnel endpoint, not the destination;
- IPv4-compatible (
::/96) and IPv4-translated (::ffff:0:0:0/96) literals, whatever the IPv4 address inside; - the names
localhostand every name under it, every single-label name (which a resolver may complete with its search domains), andlocal,internal,test,invalid,example,onionandaltand every name under them; arpa, the domain reserved for Internet infrastructure (RFC 3172), and every name under it, such ashome.arpa, the other special-use names there (service.arpa,ipv4only.arpa,resolver.arpaand others) and the reverse-mapping zonesin-addr.arpaandip6.arpa.
idp.internal.is rejected,idp.evilinternalis not.This policy does not resolve names either, so a public name that points at a private address still passes; see
OutboundUriPolicy. An identity provider reached through a private DNS zone, such as a name under.internal, needsdefaultInstance()and, where the URIs are not your own, an egress proxy.- Returns:
- the public-addresses-only policy; always the same instance
- Since:
- 1.0.0
- an IPv4 literal outside the blocks listed below, or an IPv4-mapped (
-
permits
Returns whether this policy permits a request touri.The URI must be absolute, with the scheme
httpsorhttpin any case and a host thatURI.getHost()can parse; a URI without one, such ashttps://127.1/(whose hostURIcannot parse), is rejected. The host is never resolved. The port, path, query and user information are not examined.- Parameters:
uri- the URI Revetsec is about to send a request to- Returns:
trueif the policy permits the request- Throws:
NullPointerException- ifuriisnull- Since:
- 1.0.0
-
toString
-