GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [fix][admin] PIP-478: PulsarAdminBuilderImpl.build() shares its configuration, so a second admin can inherit the first's OAuth2 IdP trust material · Issue #26398 · apache/pulsar

[fix][admin] PIP-478: PulsarAdminBuilderImpl.build() shares its configuration, so a second admin can inherit the first's OAuth2 IdP trust material #26398

New issue
Copy link
New issue
Copy link
Closed
Closed
[fix][admin] PIP-478: PulsarAdminBuilderImpl.build() shares its configuration, so a second admin can inherit the first's OAuth2 IdP trust material#26398
Copy link

Description

@lhotari
lhotari
opened on Aug 20, 2026
Issue body actions

Motivation

PulsarAdminBuilderImpl.build() hands the builder's own ClientConfigurationData to the admin without
copying it:

// PulsarAdminBuilderImpl:49
public PulsarAdmin build() throws PulsarClientException {
    return new PulsarAdminImpl(conf.getServiceUrl(), conf,
            clientBuilderClassLoader, acceptGzipCompression, sharedResources);
}

and PulsarAdminImpl.foldOAuth2IdpPolicy writes into it during construction:

// PulsarAdminImpl:514
oauth2.idpTlsPolicy(clientDefault.jsseProvider(), clientDefault.jcaProvider()).ifPresent(policy -> {
    Map<TlsPurpose, TlsPolicy> policies = conf.getTlsPolicyMap();
    if (policies == null) {
        policies = new LinkedHashMap<>();
        conf.setTlsPolicyMap(policies);
    }
    policies.putIfAbsent(TlsPurpose.CLIENT_OAUTH2, policy);
});

The first build() installs the IdP policy into a map that stays reachable from the builder. On a second
build() the map is already present and already has a CLIENT_OAUTH2 entry, so putIfAbsent keeps the
first one:

PulsarAdmin a = builder.authentication(oauth2ForIdpA).build();
PulsarAdmin b = builder.authentication(oauth2ForIdpB).build();  // b resolves against IdP A's policy

Admin b then fetches its token against IdP B while trusting IdP A's material — the wrong private CA, or
the wrong mTLS client key — with no error and no log line.

Scope

Narrower than the client-side version of this bug. The admin never stores a composed PulsarTlsFactory
back onto conf, so there is no closed-factory failure and no cross-client teardown; a plain second
build() with unchanged authentication is idempotent. It needs two builds from one builder with
different OAuth2 credentials, which is unusual — but the outcome is silent wrong-trust rather than a
visible failure, which is why it is worth closing rather than documenting.

Suggested fix

The same one-line change the two client builders received in #26326 — hand the admin a copy:

return new PulsarAdminImpl(conf.getServiceUrl(), conf.clone(), ...);

ClientConfigurationData.clone() is a shallow copy, which is enough here: the defect is the shared
mutation target, and every caller that mutates the builder's configuration does so before build().
Note that a shallow copy still shares the tlsPolicyMap instance itself, so the copy should be paired
with either a defensive copy of that map or a put rather than putIfAbsent at the fold — worth
deciding when fixing, and worth a test that builds two admins with different OAuth2 IdP material from one
builder and asserts each gets its own CLIENT_OAUTH2 policy.

Context

Reported by @david-streamlio reviewing #26326, alongside the same defect on ClientBuilderImpl and
PulsarClientBuilderV5 — both of which are fixed in that PR. Split out here on his suggestion, since the
consequence and the reasoning differ enough to take on their own merits rather than for symmetry.

Verified against master before filing: both call sites are as quoted.

Activity

  1. lhotari
    added 2 commits that reference this issue on Aug 24, 2026

    [fix][client] PIP-478: stop the v5 builder carrying one client's stat…

    1a02b02

    [fix][admin] PIP-478: stop the admin builder carrying one admin's sta…

    eb867b1
  2. merlimat commented on Oct 24, 2026

    @merlimat
    merlimat
    on Oct 24, 2026
    Contributor
    More actions

    Thanks @lhotari for the detailed report. This is fixed on master by #26326: PulsarAdminBuilderImpl.build() now gives each admin its own copy of the configuration, and PulsarAdminImpl.foldOAuth2IdpPolicy copies the TLS policy map before adding the CLIENT_OAUTH2 entry, so a second build() with different OAuth2 credentials no longer inherits the first admin's IdP policy. Closing as completed.

  3. merlimat
    closed this as completedon Oct 24, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.