Repository navigation
Description
Background
oras-go v2.6.4 rejects bearer token realms whose host resolves to a private (RFC 1918), loopback, CGNAT or similar address unless the realm is on the same host as the registry (GHSA-mm27-wq9c-mxxr). This breaks internal split-host registries such as self-hosted GitLab, where the registry and the token endpoint are on different internal hosts (#2260):
bearer realm host "gitlab.corp.example" resolves to 192.168.x.x, a loopback, link-local, private, unspecified, or carrier-grade NAT address
See oras-project/oras-go#1631. oras-go is replacing the hard-coded check with a configurable denylist, auth.Client.BlockedRealmPrefixes (oras-project/oras-go#1632, backport to v2 in oras-project/oras-go#1633). By default it blocks only loopback, link-local, unspecified and cloud metadata addresses; RFC 1918, ULA and CGNAT are allowed again.
Proposal
- Bump oras-go to the release that carries feat(auth): backport configurable realm denylist to v2 oras-go#1633 (planned v2.6.5). This alone fixes Gitlab registry login fails with 1.3.5 #2260; no flag is needed for internal GitLab.
- Add a per-reference flag for users who want to change the list:
--blocked-realm-prefix <value>(repeatable) on commands with a single target (pull,push,attach,discover, …).--from-blocked-realm-prefix/--to-blocked-realm-prefixoncopy, using the existingflagPrefixmechanism incmd/oras/internal/option/remote.go(same as--from-plain-http/--to-plain-http).
Scoping per reference matters: on oras copy public.example/x internal.example/y, loosening the list for the internal target must not loosen it for the public source.
Flag values
Same vocabulary as the registries.conf key in oras-project/oras-go#1634:
- a CIDR prefix or bare address (
10.0.0.0/8,127.0.0.1) default→auth.DefaultBlockedRealmPrefixes()private→auth.PrivateRealmPrefixes()none→ empty list (block nothing); must be the only value
When the flag is given, its values replace the default list, as in the library and config. Examples:
# strict: also block private ranges
oras pull --blocked-realm-prefix default --blocked-realm-prefix private registry.example/repo:tag
# local dev: token server on loopback, keep link-local and metadata blocked
oras pull --blocked-realm-prefix 169.254.0.0/16 --blocked-realm-prefix 100.100.100.200 localhost:5000/repo:tagFlag absent → library default (or the registries.conf value once oras-project/oras-go#1634 is read by the CLI; the flag wins over config).
Behavior
- The scheme and https→http downgrade checks always apply, whatever the list.
- Keep it separate from
--insecure, so users don't disable TLS verification to change realm handling. - Reject unparseable values and unknown named sets with a clear error.
- Help text should say that values replace the defaults, and suggest starting with
default.
Tests
- no flag: realm resolving to RFC 1918 is accepted
default+private: RFC 1918 realm rejected- custom list without loopback: localhost registry with loopback token server accepted
copywith--to-…only: source still uses the default list- invalid values rejected
Depends on: oras-project/oras-go#1632 / oras-project/oras-go#1633
Activity
[-]feat: add --allow-private-realm flag for internal token realms[/-][+]feat: support configurable blocked token realm prefixes[/+]TerryHowe commentedon Oct 23, 2026
Closing: we'd rather not add more flags to the command line. Once the oras-go v3 migration (#2002) lands, the blocked realm prefixes can be set in
registries.conf(oras-project/oras-go#1634). In the meantime, bumping oras-go to v2.7.0 restores the default that allows private (RFC 1918 / ULA / CGNAT) realms, which fixes #2260.