by rossmohax · 5y ago · 0 comments
When user agent (UA) makes authenticated call to service A, which in turn makes call to service B:
UA -[user auth]-> A -[????]-> B
how to pass authentication information from A, when making a call to B? Options I can think of:
- pass UA token as is. This has a problem that token becomes too powerful and can be made to call any service.
- pass own token and pass user auth info as an additional field. This doesn't solve confused deputy problem, since own token can be used with any user auth and service B can be tricked to make request for data in B not belonging to user
- Mint new unique token derived from tuple (A own token, UA token, B service name). B then extracts user information from the token presented by A and authorizes request. This seems to solve confused deputy problem, because A has no access to other UA tokens, so it can't mint a new token for a wrong user. Downside is that token minting should probably be done in another service and it requires making a call to it for almost every request between two microservices, making it a bottleneck pretty quickly.
I've never seen last one in real life, maybe it has some critical flaws I am failing to see?
That way account A couldn’t access account B’s decryption key to get to their private video data
> A confused deputy is a legitimate, more privileged computer program that is tricked by another program into misusing its authority on the system.[0]
In this case, we know we don't have access to open the safe, but we were able to convince the deputy, who does have access to the safe, to give us what's inside one small piece at a time. The deputy didn't intend to empty the safe- he was only showing little bits of what's inside! That's all he's allowed to do with his access!
I see where the OP is coming from in calling it that.
This reminds me more of the Facebook bug where www.facebook.com had access control but mobile.facebook.com didn't. I don't really consider every endpoint to be a "deputy".
Not sure what you mean by "token becomes too powerful and can be made to call any service." Each sub-service can have in token what is required to access it, and that can be managed by main frontend service.
There is a limit to token size but you can easily optimize claims and stuff to not go overboard in majority of cases.
If UA token is passed as is down the chain of microservices, then every service starts to accept it. Intercepting this single token allows attacked to craws whole internal system. It wont grant access to other users data, but nevertheless it doesn't seem like a secure solution to me.
> Each sub-service can have in token what is required to access it, and that can be managed by main frontend service.
This would require UA token to contain audience claim of every single internal service, this is unlikely to pass security review.
It can intercept it, but can not change it. It can replay it eventually (even that shortly, depending on timeframe of your access token which is usually minutes) but you can protect against it.
> This would require UA token to contain audience claim of every single internal service, this is unlikely to pass security review.
I have penetration tests on my main service. Sub-services are not accessible and can be secured to desired level on the internal network. I never had security inspections on internal services (I work on highly critical gov systems). Maybe in some domains its like you say but I believe its generally not a problem. Furthermore, we need to have some perspective on this - there are multiple easier ways to hack a service and there probably exists big number of other exploits that are easier to achieve.
The second option is indeed bad.
The third option is used heavily in production for both cost savings and latency reduction.
There's a 4th option which is to go back to your auth server with the UA token and get a new one representing all the data you discuss in your tuple, but still signed and valid representing (a, user, b). This is the on behalf of flow, and is standardized in oauth2 under the name Token Exchange, roughly.
(E - actually, my 4th and your 3rd are the same. My 3rd is an improvement to not require minting a new token)
UB has a list of allowed intermediates (in this case, A) so user agent doesn't send it to every service.
In my implementation there were various kinds of tokens, so UB couldn't be used by itself to invoke B directly.
For our situation all this complexity turned out to be not worth it. :-/
Bonus: When using a mesh service like this, you can also ban/rate-limit/load-balance/canary calls between any two microservices if necessary.
The way Google does mutual authentication between services (which, I reiterate, does not address this problem) is described in great detail at https://cloud.google.com/security/encryption-in-transit/appl...
Service B then uses A token for authentication, but UA token for authorization.
Doesn't Kerberos solve this with s4u2self and s4u2proxy and other delegated credentials?
I'll admit it isn't quite the exact same, but the general idea is the same.