[ 
https://issues.apache.org/jira/browse/KNOX-3458?focusedWorklogId=1041840&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1041840
 ]

ASF GitHub Bot logged work on KNOX-3458:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 16/Sep/26 01:22
            Start Date: 16/Sep/26 01:22
    Worklog Time Spent: 10m 
      Work Description: hsheinblatt commented on code in PR #1400:
URL: https://github.com/apache/knox/pull/1400#discussion_r4021632965


##########
gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java:
##########
@@ -155,6 +155,8 @@ public class TokenResource {
   private static final String KNOX_TOKEN_HARDCODED_CLAIM_MAPPINGS = 
TOKEN_PARAM_PREFIX + "hardcoded.claim.mappings";
   private static final String METADATA_QUERY_PARAM_PREFIX = "md_";
   private static final String TOKEN_ENABLE_DELEGATED_AUTH = TOKEN_PARAM_PREFIX 
+ "enable.delegated.auth";
+  static final String DELEGATION_MAX_ACTOR_CHAIN_DEPTH = 
"delegation.max.actor.chain.depth";
+  static final int DELEGATION_MAX_ACTOR_CHAIN_DEPTH_DEFAULT = 10;

Review Comment:
   See comment on jira for reasoning, but 10 is risky, I suggest 5 (allows for 
most bespoke agentic flows), 3 (allows for standard agentic flows), or 1 
(secure default, customers must set consciously to enable realistic agentic 
flows).



##########
gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java:
##########
@@ -945,6 +972,11 @@ protected TokenResponseContext 
getTokenResponse(UserContext context) {
       } else {
         response = new TokenResponseContext(null, null, 
Response.serverError());
       }
+    } catch (ActorChainDepthExceededException e) {
+      log.rejectedTokenExchange(e.getMessage());

Review Comment:
   This doesn't seem like it is returned as an RFC 8693 compliant json 
response. It may be OK since this enforcement is a necessary best practice, not 
required by the spec, but I thought all failures for token exchange needed to 
conform.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 1041840)
    Time Spent: 40m  (was: 0.5h)

> Enforce a maximum actor-chain (act claim) depth in token exchange
> -----------------------------------------------------------------
>
>                 Key: KNOX-3458
>                 URL: https://issues.apache.org/jira/browse/KNOX-3458
>             Project: Apache Knox
>          Issue Type: Sub-task
>          Components: Server
>    Affects Versions: 3.1.0
>            Reporter: Sandor Molnar
>            Assignee: Sandor Molnar
>            Priority: Major
>             Fix For: 3.1.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> The RFC 8693 act claim chain is walked and rebuilt with no depth bound 
> anywhere: {{TokenUtils.extractActorChain()}}, {{addActorToChain()}}, and 
> {{buildNestedActClaim()}} all iterate unbounded, and 
> {{ActorChainPrincipalImpl}} does no validation. A deeply nested act claim can 
> grow without limit across successive delegation exchanges.
> Scope: Add a configurable maximum chain depth (e.g. 
> {{delegation.max.actor.chain.depth}}) and enforce it at the point the chain 
> is about to grow - TokenResource.handleDelegatedAuthentication() / 
> TokenUtils.addActorToChain() (last chance before minting), rejecting the 
> exchange when the resulting depth would exceed the bound. Default to 10.
> Note: {{TokenExchangeHandler.auditMessage()}} already lists 
> {{act_chain_depth}} as a deliberately-omitted field.  Audit it once enforced.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to