Ensure Device Trust Requirements Apply to Correct Applications#63467
Ensure Device Trust Requirements Apply to Correct Applications#6346721KennethTran wants to merge 7 commits intomasterfrom
Conversation
f5822bd to
3ce7819
Compare
645d9cd to
867876d
Compare
|
Hey @codingllama and @zmb3, tagging you both here as this fixes the device trust logic from my previous PR. Previously, having a I plan on adding some more tests for |
codingllama
left a comment
There was a problem hiding this comment.
Please address the test failures.
I also suggest we do some manual testing and document the test scenarios in the PR description. Ie, something like this:
Test Plan
- Test scenario 1
- Test scenario 2
- (etc)
| @@ -579,12 +579,22 @@ func (a *Server) CreateAppSessionFromReq(ctx context.Context, req NewAppSessionR | |||
| }, | |||
| } | |||
|
|
|||
| app, err := a.GetApp(ctx, req.AppName) | |||
There was a problem hiding this comment.
@rosstimothy any concerns from a scale perspective of having to fetch the app resource here? This code used to operate only on the contents of the certificate, and now it needs the target resource's labels.
There was a problem hiding this comment.
A cache read is going to be cheaper than a backend read. Perhaps we should take the opportunity to add a benchmark test to measure the impact of this change?
| @@ -579,12 +579,22 @@ func (a *Server) CreateAppSessionFromReq(ctx context.Context, req NewAppSessionR | |||
| }, | |||
| } | |||
|
|
|||
| app, err := a.GetApp(ctx, req.AppName) | |||
There was a problem hiding this comment.
Doesn't this break the use of apps defined statically for which there's only app_servers but not any matching app?
There was a problem hiding this comment.
How do we do RBAC for those scenarios?
What if we did all the new logic here on a best-effort basis - ie, we try to determine whether a device trust failure would happen, but if we fail to do that (app not found, unrelated RBAC errors, etc) we simply let it through so that it fails (or not) downstream?
Alternatively, what if we pushed audit event to the place where RBAC truly happens (lib/srv/app, I presume)? This way we'd avoid the dupe logic and any potential false resolutions.
There was a problem hiding this comment.
Outside of the app service, we assume that RBAC applies equally to all the app_servers for a given app name and then when RBAC is applied by the agent serving the app, it applies RBAC on the app it's serving (so if multiple static apps are registered with inconsistent labels then the users will just see inconsistent behavior and there's not much we can do about that).
If all we have is an app name here and we're not already checking app_servers I'd be a little wary of adding that check since that will require going through all the app servers in storage.
8b76075 to
ba8742f
Compare
ba8742f to
93174ad
Compare
|
I decided to add a benchmark test to see the impact of Let me know if I am missing something or if I should be benchmarking with other factors. |
|
Originally moved audit emission (both fail and start events) to Moving the logic to I still need to test this, and am not sure if using a map is the right choice for handling this issue. Any suggestions on cleaning this up or a better place to insert audit events are appreciated. |
Fixes and issue introduced in #62019 where device trust requirements from a role were mistakenly applied to all applications instead of the specific applications matched by the role.
Test Plan
env: proddevice_trust_mode: requiredand allows resources with labelsenv: prodAccess Deniedpage and an App Session Start Failure in the audit logsenv: testand another Application B with labelenv: proddevice_trust_mode: requiredand allows resources with labelsenv: prodand another Role B withdevice_trust_mode: offand allows resources with labels*: *keep_alive_intervala.GetApp()does not recognize the app, but passes the request along, start Teleport withenv: testlabel on Application B, then restart Teleport withenv:prodlabel on Application B, and access Application B with an untrusted deviceaccess denied pageand this event is audited as aAppSessionStart