Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authorization Policy based on fields in request body #28988

Closed
senthilrch opened this issue Nov 18, 2020 · 4 comments
Closed

Authorization Policy based on fields in request body #28988

senthilrch opened this issue Nov 18, 2020 · 4 comments
Labels
area/security kind/enhancement lifecycle/automatically-closed Indicates a PR or issue that has been closed automatically. lifecycle/stale Indicates a PR or issue hasn't been manipulated by an Istio team member for a while

Comments

@senthilrch
Copy link

senthilrch commented Nov 18, 2020

Describe the feature request
The "AuthorizationPolicy" API provided by Istio supports defining authorization rules based on various attributes of the request: path, principal, requestprincipal, source, host, port, request header etc..This works fine for several scenarios.

Recently we have hit several scenarios in our project requiring us to define authorization rules based on json fields in the http request body. Within our project we use several micro services (both in-house and third party components) that expose resources that can be accessed only via fields in the request body. These are resources that cannot be represented in the API path.

I request you to consider adding support for "fields in the request body of the http request" in the AutorizationPolicy API in upcoming releases.

Describe alternatives you've considered
I've considered the following alternatives to work around this limitation.

1. opa-envoy-plugin:-
As part of the Open Policy Agent project, this plugin supports defining fine-grained policies using a policy language. There is support for defining policies based on fields in the request body. The opa container should be run as a sidecar within the Pod. It installs a ext_authz filter into the envoy proxy sidecar. The policies then get enforced within the opa container. For more details, refer to following URL:-
https://github.com/open-policy-agent/opa-envoy-plugin#example-policy

The following screenshot depicts how OPA policy is defined to read the fields in the request body:-
Screenshot 2020-11-18 at 10 32 21 AM

This approach doesn't scales well and introduces new friction within the team to learn and use an additional policy language outside of Istio. The need to run additional opa side car and the ext_authz hop to it, introduces latency.

2. Lua filter:-
The second alternative is to use Envoy's LUA filter to write LUA code to read the request body. Something on the lines of the following (thanks to chen for sharing it: https://discuss.istio.io/u/chen)

image

This approach has the advantage of being Istio-native, however it becomes unwieldy when the Auth policy rules have to be based on both request body and other attributes in the http request. This also requires developers to learn LUA and keep maintaining the LUA code.

[ ] Docs
[ ] Installation
[ ] Networking
[ ] Performance and Scalability
[ ] Extensions and Telemetry
[ X] Security
[ ] Test and Release
[ ] User Experience
[ ] Developer Infrastructure

Additional context
https://discuss.istio.io/t/istio-auth-policy-based-on-fields-in-request-body/8991/2

@yangminzhu
Copy link
Contributor

Note, this means the rbac filter will need to buffer the request body which is not supported today.

Do you need any custom parsing of the body? I'm not sure if a simple text matching would be useful enough here, it seems in most cases you will want a more semantic matching?

@senthilrch
Copy link
Author

Checked the list of HTTP filters supported by Envoy proxy in the data plane:-
https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters

None of the filters have capability to read the request body (The RBAC filter has no support for defining policy rules based on contents of the request body.). Perhaps the only way out is to install a LUA filter (stable) or hook in a wasm plugin using the wasm filter (experimental)?

From: https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/lua_filter
image

@istio-policy-bot istio-policy-bot added the lifecycle/stale Indicates a PR or issue hasn't been manipulated by an Istio team member for a while label May 24, 2021
@istio-policy-bot
Copy link

🚧 This issue or pull request has been closed due to not having had activity from an Istio team member since 2020-11-25. If you feel this issue or pull request deserves attention, please reopen the issue. Please see this wiki page for more information. Thank you for your contributions.

Created by the issue and PR lifecycle manager.

@istio-policy-bot istio-policy-bot added the lifecycle/automatically-closed Indicates a PR or issue that has been closed automatically. label Jun 8, 2021
@senthilrch
Copy link
Author

@leefernandes the reference you've provided is to add support for sending the request body to the ext_auth server and performing some checks when forwarding the request to the ext_auth server.

This issue is about adding support for request body in the AuthZ checks performed by Istio. Nevertheless this issue cannot be fixed in Istio because Envoy's in-built filters do not support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/security kind/enhancement lifecycle/automatically-closed Indicates a PR or issue that has been closed automatically. lifecycle/stale Indicates a PR or issue hasn't been manipulated by an Istio team member for a while
Projects
Status: Done
Development

No branches or pull requests

3 participants