Skip to content

KNOX-3600: Prevent CLIENT_ID and delegated tokens from registering other clients - #1531

Merged
smolnar82 merged 2 commits into
apache:masterfrom
smolnar82:KNOX-3600
Nov 20, 2026
Merged

smolnar82 merged 2 commits into
apache:masterfrom
smolnar82:KNOX-3600

Conversation

@smolnar82

@smolnar82 smolnar82 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

KNOX-3600 - Prevent CLIENT_ID and delegated tokens from registering clients

What changes were proposed in this pull request?

A registered client (thirdPartyApp=true) authenticates with its own client id as subject. If its token reaches /knoxidf/api/v1/client/register, it registers clients owned by itself, each with its own knoxidf.knox.token.limit.per.user, so the limit bounds nothing. Revoking the first client leaves the clients it registered working. Likewise, a delegated token (RFC 8693 act claim) lets its actor act for a user at one audience, but at registration it creates a long-lived client owned by that user.

  • RegistrationResource.registerClient rejects, with access_denied, right after the anonymous check:
    • a caller whose effective principal is the id of a CLIENT_ID token, audited as reason=client_caller_denied. An unknown id is treated as a user.
    • a caller whose subject carries an ActorChainPrincipal, audited as reason=delegated_caller_denied.
  • New KNOXIDF service params, both default true; false restores the previous behaviour:
    • knoxidf.client.registration.client.callers.denied
    • knoxidf.client.registration.delegated.callers.denied
  • Docs: configuration.md and security.md (dynamic client registration), including the known limits: a deleted client's earlier tokens pass until they expire, and only tokens with an act claim count as delegated (not impersonation minted without delegated auth, nor passcodes).

How was this patch tested?

Unit tests: new RegistrationResourceClientCallerGuardTest (7 tests) covers a client caller rejected by default and allowed with the opt-out, user callers, non-client token ids, the effective principal after identity-assertion mapping, and no subject or token state. New RegistrationResourceDelegatedCallerGuardTest (4 tests) covers a delegated caller rejected by default and allowed with the opt-out, a caller without an actor chain, and no subject. All 286 gateway-service-knoxidf tests pass.

Manual test on a local gateway. The knoxidf-auth-clientregistration topology (JWTProvider trusting KNOXSSO, lowercase principal mapping, thirdPartyApp=true) issues the clients. tokenexchange (KNOXTOKEN + CLIENTID, server-managed) exchanges a client's credentials for a JWT. A test-only delegation topology (JWTProvider, doAs impersonation for guest, KNOXTOKEN with knox.token.enable.delegated.auth=true) mints KNOXSSO tokens with an act claim.

Client callers:

  1. Get guest's KNOXSSO token: {"iss":"KNOXSSO","sub":"guest"}.
  2. guest registers client 1 at /knoxidf-auth-clientregistration/knoxidf/api/v1/client/register: HTTP 200.
  3. Client 1 gets its own token at /tokenexchange/oauth/v1/token (client_credentials): {"iss":"KNOXSSO","sub":"<client 1 id>"}.
  4. Client 1 registers client 2 with that token.

Results of step 4:

  • knoxidf.client.registration.client.callers.denied=true: HTTP 403, {"error":"access_denied","error_description":"A registered client cannot register another client."}.
  • knoxidf.client.registration.client.callers.denied=false: HTTP 200, client 2 registered.

Delegated callers:

  1. Get guest's KNOXSSO token.
  2. guest gets a token for itself at /delegation/knoxtoken/api/v1/token: {"iss":"KNOXSSO","sub":"guest","act":null}.
  3. That token registers a client: HTTP 200.
  4. guest gets a token for admin (?doAs=admin): {"iss":"KNOXSSO","sub":"admin","act":{"sub":"guest"}}.
  5. That delegated token registers a client.

Results of step 5:

  • Default (param unset): HTTP 403, {"error":"access_denied","error_description":"A delegated token cannot register a client."}; the audit log has principal=admin|failure|event=client_registration reason=delegated_caller_denied.
  • knoxidf.client.registration.delegated.callers.denied=true with knoxidf.client.registration.client.callers.denied=false: still HTTP 403; each flag controls only its own check.

Client caller denied (knoxidf.client.registration.client.callers.denied=true): client 1 cannot register client 2.

1. guest's KNOXSSO token
{"iss":"KNOXSSO","sub":"guest"}
2. guest registers client 1 (expect 200)
{"client_secret":"…","redirect_uris":"https://app.example.com/cb","client_id":"ea6edf45-2a04-4ea8-a388-a44f89e9214b","allowed_scopes":"openid,profile,email,offline_access"}
HTTP 200
3. client 1 gets its own token at tokenexchange (client_credentials)
{"iss":"KNOXSSO","sub":"ea6edf45-2a04-4ea8-a388-a44f89e9214b"}
4. client 1 registers client 2 (expect 403 access_denied when sub is the client id)
{
  "error_description" : "A registered client cannot register another client.",
  "error" : "access_denied"
}
HTTP 403

Client caller opt-out (knoxidf.client.registration.client.callers.denied=false): client 1 registers client 2.

1. guest's KNOXSSO token
{"iss":"KNOXSSO","sub":"guest"}
2. guest registers client 1 (expect 200)
{"client_secret":"…","redirect_uris":"https://app.example.com/cb","client_id":"38e0886d-0c25-4b06-9cd9-b4dd2b1b4b6e","allowed_scopes":"openid,profile,email,offline_access"}
HTTP 200
3. client 1 gets its own token at tokenexchange (client_credentials)
{"iss":"KNOXSSO","sub":"38e0886d-0c25-4b06-9cd9-b4dd2b1b4b6e"}
4. client 1 registers client 2 (expect 403 access_denied when sub is the client id)
{"client_secret":"…","redirect_uris":"https://app.example.com/cb","client_id":"8be4ac22-121c-4ad9-9368-fefdf163cb2f","allowed_scopes":"openid,profile,email,offline_access"}
HTTP 200

Delegated caller denied (default, knoxidf.client.registration.delegated.callers.denied unset): the delegated token cannot register a client.

1. guest's KNOXSSO token
{"iss":"KNOXSSO","sub":"guest","act":null}
2. guest gets a token for itself at delegation (no act)
{"iss":"KNOXSSO","sub":"guest","act":null}
3. that token registers a client (expect 200)
{"client_secret":"…","redirect_uris":"https://app.example.com/cb","client_id":"6e042d73-7f62-469c-8db0-4c5a2bd5ce6b","allowed_scopes":"openid,profile,email,offline_access"}
HTTP 200
4. guest gets a token for admin at delegation (doAs=admin, act.sub=guest)
{"iss":"KNOXSSO","sub":"admin","act":{"sub":"guest"}}
5. the delegated token registers a client (expect 403 access_denied unless delegated callers are allowed)
{
  "error_description" : "A delegated token cannot register a client.",
  "error" : "access_denied"
}
HTTP 403

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Test Results

  5 files    5 suites   1m 15s ⏱️
227 tests 226 ✅ 1 💤 0 ❌
271 runs  270 ✅ 1 💤 0 ❌

Results for commit 32a77fe.

♻️ This comment has been updated with latest results.

@lmccay lmccay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple questions added.

@smolnar82
smolnar82 requested a review from lmccay November 19, 2026 23:49
@smolnar82 smolnar82 changed the title KNOX-3600: Prevent CLIENT_ID tokens from registering other clients KNOX-3600: Prevent CLIENT_ID and delegated tokens from registering other clients Nov 19, 2026

@lmccay lmccay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
+1

@smolnar82
smolnar82 merged commit 8fa1415 into apache:master Nov 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants