smolnar82 commented on PR #1553:
URL: https://github.com/apache/knox/pull/1553#issuecomment-7291430612

   > @smolnar82 - this is easier to review than the previous one. We may still 
want to revisit that approach later if there are valid use cases but for now 
this is good.
   > 
   > One thing that I can't quite see here is protection against a registered 
client's access token being used to register more clients and so on and so on.
   > 
   > I may be missing it but I think in order to this to be protected that the 
client credentials flow minted access token would need the provenance as well. 
Is that already in there and I am missing it? Would it prevent something else 
that would be required with such a token?
   
   @lmccay thanks! With the default config, that chain is already refused by 
[KNOX-3600](https://issues.apache.org/jira/browse/KNOX-3600), so the 
`client_credentials` token doesn't need provenance:
   
   - A registered client is a `CLIENT_ID` token (`RegistrationResource` extends 
`ClientCredentialsResource`), and `thirdPartyApp` defaults to `true`. When the 
client authenticates with its id/secret, its subject is the client_id 
(`AbstractJWTFilter#createSubjectFromTokenIdentifier`), so the access token it 
gets from the client_credentials flow has `sub` = client_id.
   - `knoxidf.client.registration.client.callers.denied` (default `true`) looks 
the caller's subject up in the token state service and refuses registration 
when it is a `CLIENT_ID` (`client_caller_denied`). So a registered client's 
token can't register another client.
   - Laundering doesn't get around it. The check is on `sub`, not `iss`: a 
same-subject exchange keeps `sub` = client_id. A delegated exchange adds an 
`act` claim, which KNOX-3600 refuses too (`delegated_caller_denied`).
   - The check needs token state, but so does registration: the client is 
persisted as token metadata in the token state service, so any topology where 
registration works has one.
   
   Provenance covers the case 
[KNOX-3600](https://issues.apache.org/jira/browse/KNOX-3600) can't catch by 
subject: a token whose `sub` is a user. That's a login token (KNOXSSO, an 
auth-code token) laundered through a same-subject exchange, or a token from a 
client created with `thirdPartyApp=false`, which carries the owning user as 
`sub`. In both cases the exchange stamps the original issuer on the first hop. 
Stamping at `client_credentials` mint wouldn't add anything, because a direct 
caller is already identified by its own `iss` through `jwt.expected.issuer`.
   
   Unit coverage for the client-caller refusal is in 
`RegistrationResourceClientCallerGuardTest`. If you'd like it proven end to 
end, I can add an E2E test that chains register -> client_credentials token -> 
register again (directly and after a same-subject exchange) and expects 
`client_caller_denied`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to