Skip to content

rgw/sts: use the jwks_uri host and port for thumbprint verification - #73310

Merged
anrao19 merged 1 commit into
ceph:mainfrom
next0262:wip-rgw-sts-jwks-url-port
Nov 13, 2026
Merged

anrao19 merged 1 commit into
ceph:mainfrom
next0262:wip-rgw-sts-jwks-url-port

Conversation

@next0262

@next0262 next0262 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

With rgw_enable_jwks_url_verification = true, verify_oidc_thumbprint() opens its own TLS connection to the JWKS endpoint and compares the last certificate of the chain with the thumbprints registered on the OIDC provider. There are two defects in how it reaches the endpoint.

  1. The host is taken from jwks_uri by stripping only the scheme and the path. An explicit port stays attached, so https://host:6443/openid/v1/jwks becomes host:6443 and gethostbyname("host:6443") fails. Even https://host:443/... fails this way, as reported in the tracker.
  2. The connection port is hard-coded to 443, so a provider on another port is unreachable even if the host resolves.

Concrete case — Kubernetes service account tokens

A Kubernetes cluster can be registered as the provider for AssumeRoleWithWebIdentity, allowing pods to authenticate to RGW with projected service account tokens. The kube-apiserver issues those tokens and can serve discovery and JWKS directly on its HTTPS port, which defaults to 6443. For example, the discovery document could contain the following fields.

curl -sk https://kube-apiserver:6443/.well-known/openid-configuration
{
  "issuer": "https://kubernetes.default.svc.cluster.local",
  "jwks_uri": "https://kube-apiserver:6443/openid/v1/jwks"
}

For this setup, jwks_uri carries an explicit :6443. With endpoint verification enabled and thumbprints registered, AssumeRoleWithWebIdentity fails at the thumbprint check because RGW tries to resolve kube-apiserver:6443 as a hostname.

The JWKS download itself (RGWHTTPTransceiver, curl) handles the port correctly. The failure is in the separate certificate check. Users connecting directly to a provider on a non-default port cannot enable that check and may have to leave rgw_enable_jwks_url_verification off, which is its default value.

Fix

  • Add rgw::parse_url_host_port() next to the existing Boost.URL helpers in rgw_url.cc and use it in verify_oidc_thumbprint(), with a default port of 443. A jwks_uri that does not parse now fails verification with a log message instead of proceeding to DNS lookup.
  • Resolve the host with getaddrinfo() instead of the IPv4-only gethostbyname(), trying each returned address so IPv6 literals and AAAA records work too.
  • Drop get_top_level_domain_from_host(), which has no other caller.

Behaviour for a jwks_uri without an explicit port, served on 443, is unchanged.

Tests

unittest_rgw_url gains six cases for the new parser covering the default port, an explicit port, explicit 443, an IPv6 literal with a port, userinfo and invalid inputs. All 20 tests pass. Also compiled rgw_rest_sts.cc with the existing build dependencies.

The connection and thumbprint functions were exercised standalone against a local TLS server on ports 443 and 6443 over IPv4 and IPv6. Matching and non-matching thumbprints, a closed port and an unparsable URL behaved as expected. The pre-patch code fails the same setup with gethostbyname failed for host: localhost:6443. The local build has WITH_RADOSGW=OFF, so the full rgw_common build still needs CI.

Fixes: https://tracker.ceph.com/issues/74001

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

With rgw_enable_jwks_url_verification enabled, verify_oidc_thumbprint()
connects to the JWKS endpoint to compare its certificate against the
thumbprints registered with the OIDC provider. The hostname was taken
from jwks_uri by stripping the scheme and path only, so an explicit port
stayed attached ("host:6443") and gethostbyname() failed on it. Even
when no port was given, the connection always went to 443. Providers
served on any other port, such as a Kubernetes API server on 6443,
could therefore never pass verification.

Add rgw::parse_url_host_port() next to the existing Boost.URL based
helpers in rgw_url.cc and use it to take both the host and the port
(default 443) from jwks_uri. Resolve the host with getaddrinfo() so that
IPv6 literals and AAAA records work as well, and try each address until
one connects.

Fixes: https://tracker.ceph.com/issues/74001
Signed-off-by: Woojoong Kim <[email protected]>
@github-actions

Copy link
Copy Markdown

Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR ci-approved to allow Jenkins CI jobs to run.

@next0262

Copy link
Copy Markdown
Contributor Author

@pritha-srivastava Could you approve CI? This fixes the jwks_uri port handling reported in tracker 74001.

@pritha-srivastava

Copy link
Copy Markdown
Contributor

lgtm

@pritha-srivastava

Copy link
Copy Markdown
Contributor

jenkins test api

@anrao19

anrao19 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-anrao8-testing-2026-11-02-0653-main.

@anrao19

anrao19 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-anrao8-testing-2026-11-02-0653-main.

pr testing completed and approved by @ivancich more details on :https://tracker.ceph.com/issues/82523
@next0262 , if no further testing is needed then this pr can be merged

@pritha-srivastava

pritha-srivastava commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

This PR has been added to wip-anrao8-testing-2026-11-02-0653-main.

pr testing completed and approved by @ivancich more details on :https://tracker.ceph.com/issues/82523 @next0262 , if no further testing is needed then this pr can be merged

@anrao19 @ivancich please merge this PR

@anrao19
anrao19 merged commit ca2da03 into ceph:main Nov 13, 2026
23 checks passed
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/43383311075

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants