read cert from header when trusted proxy sets it#6287
Conversation
Signed-off-by: Asif Bashar <asif.bashar@gmail.com>
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 9eea16f.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
The ssl validation for client happens at the load balancers/proxy servers , the opensearch still validates load balancers/proxy certificates and trust that load balancer did correct validation. So it is dependent on load balancer/proxy to do original client validation. |
|
@cwperks please review |
Description
Where there a external load balancer/proxy that itself does mTLS authentication, it forwards the request to opensearch where client to opensearch is load balancer and original client cert is no longer performing client cert authentication with OpenSearch , it is the load balancer that is performing client authentication with opensearch cluster.
What solution would you like?
To preserve identity of the original client, we can have first opensearch do client authentication validation with external load balancer /proxy , during TLS handshake and then external load balancer/proxy can store the original client certificate in header as URL encoded value in header field x-client-cert (This is configurable by setting "plugins.security.ssl.http.clientauth_header_cert_name"). The external load balancer/proxy will connect to opensearch cluster and forward the request with original client cert in header so that opensearch cluster can assign original client's principle which is correct identity of the original client. The load balancer has to be trusted by the opensearch so that it can trust its header so load balancer certificate will be validated at every request by opensearch using its standard certficate based authentication and then will validate if the external load balancer certificate principle matches setting plugins.security.ssl.http.clientauth_header_cert_allowed_for_principle list of regex.
The feature will be controlled by flag settings "clientauth_header_cert_allowed_for_principle" where by default this feature will be disabled.
Category (Enhancement)
Why these changes are required?
Some of the general purpose load balancers are allowing the actual cert to be placed in header, but those load balancers are not setting x-forwarded-for field with the principle as its dedicated for IP. So allowing opensearch to extract its desired field from the certificate allows both opensearch and load balancer to work with their own requirements and configuration but still work together. In this scenerio,load balancer will validate original client and but it does not have the role mapping or correct principle extraction logic, so it will just pass the cert as is, Opensearch then will know the request is from proxy from proxy(external load balancer) by validating client cert authentication of the load balancer/proxy, so it will trust the request , but it should assume the actual client associated user that belongs to original client and not the load balancer , so it will then use certificate from header to switch to that principle .
What is the old behavior before changes and new behavior after changes?
By default the flag to read from header cert is false, so it does not change default behaviour.
If user sets this flag plugins.security.ssl.http.clientauth_use_header_cert to true, then a header cert will be checked when plugins.security.ssl.http.clientauth_header_cert_allowed_for_principle setting has the principle regex list that matches proxy server (external load balancer) client cert principle matching .
Issues Resolved
[ #6268 ]
Is this a backport? If so, please add backport PR # and/or commits #, and remove
backport-failedlabel from the original PR.Do these changes introduce new permission(s) to be displayed in the static dropdown on the front-end? If so, please open a draft PR in the security dashboards plugin and link the draft PR here
-No new permission
Testing
[unit testing added]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.