[
https://issues.apache.org/jira/browse/KNOX-3623?focusedWorklogId=1057700&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1057700
]
ASF GitHub Bot logged work on KNOX-3623:
----------------------------------------
Author: ASF GitHub Bot
Created on: 30/Nov/26 17:57
Start Date: 30/Nov/26 17:57
Worklog Time Spent: 10m
Work Description: smolnar82 commented on code in PR #1553:
URL: https://github.com/apache/knox/pull/1553#discussion_r4743273921
##########
gateway-service-knoxidf/src/main/java/org/apache/knox/gateway/service/knoxidf/RegistrationResource.java:
##########
@@ -180,6 +201,10 @@ public Response registerClient(@FormParam("redirect_uris")
String redirectUris,
detail = "reason=delegated_caller_denied";
return error("access_denied", "A delegated token cannot
register a client.");
}
+ if (provenanceDenied()) {
Review Comment:
Fixed in ebdacd329. The guard the inherited token endpoints already used for
delegated callers now also refuses a denied provenance, with 403
`access_denied` and audit reason `provenance_denied`. That covers
`getUserTokens`, `revoke`, `revokeTokens`, `enable`, `enableTokens`, `disable`
and `disableTokens`, with unit tests per endpoint and an E2E test.
##########
.github/workflows/build/conf/topologies/knoxidf-provenance-denied.xml:
##########
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with this
+work for additional information regarding copyright ownership. The ASF
+licenses this file to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations under
+the License.
+-->
+<!--
+ KNOX-3623 (token-laundering defense, Option 2 - enforcement side). The
KNOXIDF
+ /client registration endpoint refuses any caller whose token carries a
+ knox_token_provenance claim listed in
+ knoxidf.client.registration.denied.provenance.issuers. KNOXSSO is the
provenance a
+ login token minted on knoxidf-ldap carries after a same-subject exchange on
+ knoxidf-token-provenance, so such a laundered token is refused here (HTTP 403
+ access_denied) while a token with no provenance claim (a plain minted token,
or an
+ exchange output from a topology that does not stamp provenance) registers
normally.
+ Empty/undefined (the default) denies no provenance.
+-->
+<topology>
+ <gateway>
+ <provider>
+ <role>federation</role>
+ <name>JWTProvider</name>
+ <enabled>true</enabled>
+ <param>
+ <name>knox.token.exp.server-managed</name>
+ <value>true</value>
+ </param>
+ </provider>
+ <provider>
+ <role>identity-assertion</role>
+ <name>Default</name>
+ <enabled>true</enabled>
+ </provider>
+ </gateway>
+
+ <service>
+ <role>KNOXIDF</role>
+ <param>
+ <name>knoxidf.knox.token.limit.per.user</name>
+ <value>-1</value>
+ </param>
+ <param>
+ <name>knoxidf.client.registration.denied.provenance.issuers</name>
Review Comment:
Agreed, done in ebdacd329.
`gateway.knox.token.exchange.provenance.claim.enabled` in gateway-site.xml sets
the deployment-wide default (false). A topology that sets
`token.exchange.provenance.claim.enabled` overrides it either way. That way
stamping can be switched on for every exchange topology at once and turned off
surgically.
I left the deny-list
(`knoxidf.client.registration.denied.provenance.issuers`) topology-level, since
it lives on the registration topology and there's typically only one of those.
Happy to add a global default for it too if you think it's worthwhile.
Issue Time Tracking
-------------------
Worklog Id: (was: 1057700)
Time Spent: 1h (was: 50m)
> KnoxIDF token exchange: prevent a same-subject exchange from laundering an
> input token into a client-registration credential
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: KNOX-3623
> URL: https://issues.apache.org/jira/browse/KNOX-3623
> Project: Apache Knox
> Issue Type: Task
> Components: KnoxIDF
> Reporter: Sandor Molnar
> Assignee: Sandor Molnar
> Priority: Major
> Fix For: 3.1.0
>
> Time Spent: 1h
> Remaining Estimate: 0h
>
> h3. Background
> The KnoxIDF token endpoint supports RFC 8693 token exchange. A topology can
> enable a same-subject exchange
> ({{token.exchange.same.subject.requested.audience.enabled}}): the caller
> presents a {{subject_token}} and receives a new token for the same subject,
> stamped with the exchange topology's own issuer
> ({{knoxidf.knox.token.issuer}}) and default audience
> ({{knoxidf.knox.token.audiences}}), with no {{act}} claim added.
> KNOX-3600 lets the dynamic client-registration endpoint
> ({{/client/register}}) refuse a caller whose subject is a registered client
> (a CLIENT_ID token) or whose token carries an {{act}} claim. A deployment can
> configure registration to trust the token-exchange topology's issuer so that
> service identities can register clients.
> h3. Problem
> A same-subject exchange normalizes *both* the issuer and the audience of the
> output token to the exchange topology's own values. If a deployment also lets
> the token-exchange topology trust a user-facing login / auth-code issuer (so
> OBO flows can exchange a user's token), a holder of a user's login token can:
> # present it to the token endpoint as a plain same-subject exchange (no
> {{actor_token}}, no {{requested_subject}});
> # receive a token stamped with the exchange issuer and default audience,
> carrying no {{act}} claim;
> # present that token to {{/client/register}}, which cannot distinguish it
> from a legitimate service token and registers clients as the user.
> The KNOX-3600 guards do not catch this: the subject is a user (not a
> CLIENT_ID) and there is no {{act}} claim. An audience check at registration
> cannot help either, because the exchange has already overwritten the audience
> with its own default. The only property that distinguishes a laundered token
> from a legitimate one -- the original input issuer -- is lost during the
> exchange.
> Today the only mitigation is deployment-side issuer-list segregation (a
> dedicated exchange topology whose output issuer no registration endpoint
> trusts). It works but is fragile: it relies on every future topology edit
> preserving the segregation.
> h3. Proposed enhancement
> Give the token-exchange provider a way to stop an input issuer's tokens from
> becoming registration-capable credentials, so the invariant is enforced by
> Knox rather than by deployment wiring. Either, or both, of:
> # *Per-issuer exchange policy:* a provider parameter listing input issuers
> for which a same-subject exchange is refused -- tokens from those issuers may
> only be exchanged as a delegation (with an {{actor_token}}), so the output
> always carries an {{act}} claim that RegistrationResource already refuses.
> # *Input-issuer provenance:* stamp the original {{subject_token}} issuer into
> a claim on the exchanged token that survives further exchanges, and let
> RegistrationResource (and other resources) refuse tokens whose provenance
> chain originates from a configured set of issuers.
> h3. Related
> KNOX-3600 -- prevent CLIENT_ID and delegated tokens from registering other
> clients.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)