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

fix: only allow istio gateways to set x509 client certificate header #572

Merged
merged 3 commits into from
Jul 15, 2024

Conversation

bburky
Copy link
Member

@bburky bburky commented Jul 12, 2024

Description

We terminate TLS at the Istio ingress gateway, and then we In the Keycloak VirtualService, we securely extract the client certificate, urlencode it, and copy it to the istio-mtls-client-certificate header. Keycloak then uses this as the x509 client identity.

headers:
request:
remove:
- istio-mtls-client-certificate
add:
istio-mtls-client-certificate: "%DOWNSTREAM_PEER_CERT%"

When Istio sets the header, we also delete any existing istio-mtls-client-certificate header. This ensures that all users through the ingress gateway cannot forge a istio-mtls-client-certificate when they do not use TLS client authentication.

However... we only do this at the gateway and we allow in-cluster mesh communication to Keycloak to non-admin URLs.

This PR adds a DENY AuthorizationPolicy rule to the Keycloak Istio sidecar, to deny any incoming requests with a istio-mtls-client-certificate header not originating from the admin or tenant gateway.

Credit to @rjferguson21 for asking great questions and catching this.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Other (security config, docs update, etc)

Checklist before merging

@bburky bburky requested a review from jeff-mccoy July 12, 2024 21:53
@mjnagel mjnagel changed the title Only allow istio gateways to set x509 client certificate header fix: only allow istio gateways to set x509 client certificate header Jul 12, 2024
@mjnagel mjnagel added security sso Issues related to the SSO stack (Keycloak/Authservice) labels Jul 12, 2024
Copy link
Member

@jeff-mccoy jeff-mccoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed in slack. This covers more cases, except the unlikely attack from the exempted namespaces. At that point you likely have the ability to get the db secrets anyway for keycloak.

@mjnagel mjnagel merged commit 5c62279 into main Jul 15, 2024
13 checks passed
@mjnagel mjnagel deleted the client-certificate-header-deny branch July 15, 2024 16:56
mjnagel pushed a commit that referenced this pull request Jul 22, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.24.1](v0.24.0...v0.24.1)
(2024-07-22)


### Bug Fixes

* **ci:** snapshot release publish, passthrough test on upgrade
([#575](#575))
([d4afe00](d4afe00))
* **ci:** workflow permissions
([cacf1b5](cacf1b5))
* only allow istio gateways to set x509 client certificate header
([#572](#572))
([5c62279](5c62279))
* **sso:** delete orphaned SSO secrets
([#578](#578))
([5a6b9ef](5a6b9ef))
* unicorn flavor proxy image reference
([#590](#590))
([db081fa](db081fa))
* update monitor mutation to not overwrite explicitly defined scrape
class ([#582](#582))
([7e550d3](7e550d3))


### Miscellaneous

* **deps:** update grafana chart + sidecar image
([#567](#567))
([85b6de4](85b6de4))
* **deps:** update pepr to v0.32.7
([#556](#556))
([e594f13](e594f13))
* **deps:** update uds-identity-config to v0.5.1
([#591](#591))
([b9c5bd3](b9c5bd3))
* **deps:** update uds-k3d to v0.8.0
([#581](#581))
([fab8919](fab8919))
* **loki:** default query settings, config as secret
([#579](#579))
([5fa889c](5fa889c))
* **oscal:** begin integration of composed oscal with validations
([#496](#496))
([047fd30](047fd30))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
security sso Issues related to the SSO stack (Keycloak/Authservice)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants