Skip to content

Gitlab registry login fails with 1.3.5 #2260

Description

@computeralex92

What happened in your environment?

We use oras to mirror the Trivy databases to a internal Gitlab container registry.
Unfortunately, with oras 1.35.0 the login against the registry is not working anymore:

$ oras login --debug -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
[2026-10-19T05:59:58.95631237Z][DEBUG]: --> Request #0
> Request URL: "https://registry.example/v2/"
> Request method: "GET"
> Request headers:
   "User-Agent": "oras/1.3.5"
[2026-10-19T05:59:58.987684506Z][DEBUG]: <-- Response #0
< Response Status: "401 Unauthorized"
< Response headers:
   "X-Content-Type-Options": "nosniff"
   "Date": "Mon, 19 Oct 2026 05:59:58 GMT"
   "Content-Type": "application/json"
   "Content-Length": "87"
   "Server": "nginx"
   "Docker-Distribution-Api-Version": "registry/2.0"
   "Www-Authenticate": "Bearer realm=\"https://gitlab.example/jwt/auth\",service=\"container_registry\""
< Response body:
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}
Error: failed to validate the credentials for registry.example: GET "https://registry.example/v2/": bearer realm host "gitlab.example" resolves to 172.31.53.173, a loopback, link-local, private, unspecified, or carrier-grade NAT address

What did you expect to happen?

Login is working as in oras 1.34.0:

$ oras login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Login Succeeded
$ echo "Copy all images to Gitlab Docker Registry"
Copy all images to Gitlab Docker Registry
$ oras copy ghcr.io/aquasecurity/trivy-db:latest ${CI_REGISTRY_IMAGE}/trivy-db:latest
Copied [registry] ghcr.io/aquasecurity/trivy-db:latest => [registry] registry.example/shared/containers/trivy-db/trivy-db:latest
Digest: sha256:5f7728812fca071a7bd9905a0b7e05ff0a4cae48e16aba701ef40db7a72af0f7
$ oras copy ghcr.io/aquasecurity/trivy-db:2 ${CI_REGISTRY_IMAGE}/trivy-db:2
Copied [registry] ghcr.io/aquasecurity/trivy-db:2 => [registry] registry.example/shared/containers/trivy-db/trivy-db:2
Digest: sha256:1e86b730a4e178372a092b036bc8f1d9ae5e1c889ebb4909303b74ffead49711
$ oras copy ghcr.io/aquasecurity/trivy-checks:latest ${CI_REGISTRY_IMAGE}/trivy-checks:latest
Copied [registry] ghcr.io/aquasecurity/trivy-checks:latest => [registry] registry.example/shared/containers/trivy-db/trivy-checks:latest
Digest: sha256:aed55d13b2971c90752a4500da2f99f678bca53de2a90cc2c3677d5fc67a50b8
$ oras copy ghcr.io/aquasecurity/trivy-java-db:1 ${CI_REGISTRY_IMAGE}/trivy-java-db:1
Copied [registry] ghcr.io/aquasecurity/trivy-java-db:1 => [registry] registry.example/shared/containers/trivy-db/trivy-java-db:1
Digest: sha256:e5add4ea7f30417b01901e1d2a17a1ceb72734bc70df4db9b72c4f4eefd630f6

How can we reproduce it?

We use oras within a Gitlab CI pipeline with the official container image.
The login line is standard against the Gitlab Container registry, and worked without any issue for years now.
As shown, in 1.34.0 everything is fine.

What is the version of your ORAS CLI?

Version: 1.3.5
Go version: go1.27.2
OS/Arch: linux/arm64
Git commit: d6e7b58
Git tree state: clean

What is your OS environment?

Alpine (oras container image)

Are you willing to submit PRs to fix it?

  • Yes, I am willing to fix it.

Activity

  1. added
    bug
    triage
    on Oct 19, 2026
  2. shashankxrm commented on Oct 19, 2026

    @shashankxrm

    Hi, I can look into this. Before I start, should private realm hosts like this GitLab setup get an allowlist again in oras-go, or is there another approach you'd prefer here?

  3. TerryHowe commented on Oct 19, 2026

    @TerryHowe
    Member

    Related to oras-project/oras-go#1631 there was a CVE patch that broke this. I think the solution would be add a trusted realm type thing, but investigating on the oras-go side

  4. TerryHowe commented on Oct 19, 2026

    @TerryHowe
    Member

    Follow-up: this is caused by the oras-go v2.6.4 security fix GHSA-mm27-wq9c-mxxr, which rejects bearer realms whose hostname resolves to an internal address unless the realm is on the same host as the registry. A GitLab setup like yours, with registry.example issuing a challenge for gitlab.example/jwt/auth on a private IP, looks identical to the attack the fix blocks, so we won't relax the default. Instead we're adding an explicit, per-registry opt-in:

    For your pipeline, the flag would be needed on oras login and as --to-allow-private-realm on the oras copy commands.

    Until that ships, the workaround is staying on the previous oras release, which also means going without the other security fixes in this one.

    @shashankxrm thanks for offering! #2261 would be a good one to pick up once the oras-go side lands.

  5. changed the title [-]Gitlab registry login fails with 1.35.0[/-] [+]Gitlab registry login fails with 1.3.5[/+] on Oct 19, 2026
  6. computeralex92 commented on Oct 19, 2026

    @computeralex92
    Author

    Thx for checking it out, I don't know how often such a setup of auth is used outside of Gitlab.
    As 1.3.4 is working just fine for us, the update MR stay open until a new version dropped.

  7. bb-Ricardo commented on Oct 20, 2026

    @bb-Ricardo

    same here, running a private GitLab instance and this broke the oras login command. reverting to 1.3.4 helped.

  8. removed
    triage
    on Oct 22, 2026
  9. TerryHowe commented on Oct 22, 2026

    @TerryHowe
    Member

    This will be resolved with oras-go 2.7.0 oras-project/oras-go#1660 and an update for oras to use that version

  10. TerryHowe commented on Oct 25, 2026

    @TerryHowe
    Member

    This is fixed in ORAS CLI v1.3.6, which updates to oras-go v2.7.0 (#2284).

    oras-go v2.7.0 narrows the default bearer realm denylist to loopback, link-local, unspecified, and cloud metadata addresses. RFC 1918, IPv6 unique-local, and carrier-grade NAT realms are allowed again, so split-host setups like self-hosted GitLab work without any extra configuration.

    That replaces the opt-in plan from my earlier comment: no --allow-private-realm or --to-allow-private-realm flag is needed (#2261 was dropped). Upgrading to 1.3.6 should be all it takes. If login still fails for you on 1.3.6, please reopen with the --debug output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions