-
Notifications
You must be signed in to change notification settings - Fork 24
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
Istio DECODE_AND_MERGE_SLASHES option breaks GitLab #288
Comments
This appears to be a result of the path normalization we added to the istio mesh config. At a glance I'm not sure this can be configured per workload so it may be difficult to enable it for keycloak, but not gitlab. Context on why we have this is essentially this doc, related to our usage of AuthorizationPolicy resources to protect certain keycloak endpoints. We may need to evaluate other options here if we can't do per-workload normalization, or identify if there is a way to make Gitlab happy with normalized paths. Edit: More context - Gitlab has an open issue regarding this, people have encountered it with other proxies. The TLDR is they don't plan to change anything, but may add docs to note this being a requirement for your proxy to not decode URLs. |
After doing some reading I was hoping that an envoyfilter like this might work: apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: disable-path-normalization
namespace: gitlab
spec:
configPatches:
- applyTo: NETWORK_FILTER
match:
context: ANY
listener:
filterChain:
filter:
name: envoy.filters.network.http_connection_manager
patch:
operation: MERGE
value:
typed_config:
'@type': 'type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager'
"normalize_path": false
"merge_slashes": false However it appears that merges don't overwrite the bools that would be set to true in this case (see istio/istio#18169) so this doesn't work as I would hope. There are other What might be possible is flipping the mesh config back to non-normalized paths and using the envoyfilter to normalize keycloak specifically. I'm not sure on the implications of that and would defer to @bburky and @jeff-mccoy if there's any downside to normalizing via envoyfilter, only for keycloak (assuming the above envoyfilter or similar would actually work)? I'm also not 100% sure - we might be impacted by the same issue in istio merging those boolean fields. |
Currently we're only trying to enforce policies on Keycloak and the AuthorizationPolicy is enforced at the workload not the gateway. So yes, we could theoretically only enforce policies at the Keycloak istio sidecar. If this EnvoyFilter works for enabling on Keycloak only, I guess this is fine. If we start to use more path-based AuthorizationPolicies we'll need one of these EnvoyFilters in each namespace, but so far it's just Keycloak. We could also downgrade the normalization level to |
FWIW we may run into this issue more often with GitLab since many services (NPM coming to mind) expect a |
To address CVEs promptly in UDS packages, I'd like to have the option to mitigate CVEs in packages with DENY AuthorizationPolicies. If we can securely mitigate a CVE by disabling an affected API, sometimes we can wait update and patch. Also sometimes it's hard to do a full update of a package, so shipping a mitigation ASAP while we take time to update is a nice option. For example, this recent Grafana CVE uses a (rarely used I think?) The reason I mention this is because, if possible, I'd like to have DECODE_AND_MERGE_SLASHES enabled on as many namespaces as possible, otherwise path based AuthorizationPolicies can likely be bypassed. If it's just GitLab we skip, that's fine. But I'd really like it enabled on all namespaces if possible. (If we have to use an EnvoyFilter, we could maybe use Pepr to generate it in each namespace?) |
Let's try the opposite of the previous EnvoyFilter: have UDS operator generate an EnvoyFilter per-namespace, opting into DECODE_AND_MERGE_SLASHES behavior. The UDS CR will have a setting defaulting to path normalization, but specific apps (GitLab) can opt out. Something along the lines of: apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: path-normalization
namespace: ${namespace}
spec:
configPatches:
- applyTo: NETWORK_FILTER
match:
context: ANY
listener:
filterChain:
filter:
name: envoy.filters.network.http_connection_manager
patch:
operation: MERGE
value:
typed_config:
'@type': 'type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager'
"normalize_path": true
"merge_slashes": true
"path_with_escaped_slashes_action": 4 I think the list of envoy settings configured by Istio with DECODE_AND_MERGE_SLASHES are: A couple questions:
@mjnagel If you want to do a PR to implement this that would be great. |
Commenting here for posterity - after further review of keycloak and the envoyfilter solution we are pivoting to just using This does however mean that we may not be able to confidently and quickly protect against CVEs affecting specific endpoints - we would need to review and validate each specific app to ensure they don't decode URLs, and potentially add an envoyfilter to do further modification, none of which could be done quickly in response to a CVE. |
… encoded slashes (#330) ## Description PR to address `DECODE_AND_MERGE_SLASHES` causing issues in certain applications. Gives the ability to selectively turn this off in a namespace with the `UDSPackage` CR. ## Related Issue Fixes #288 ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds functionality) - [ ] Other (security config, docs update, etc) ## Checklist before merging - [x] Test, docs, adr added or updated as needed - [X] [Contributor Guide Steps](https://github.com/defenseunicorns/uds-template-capability/blob/main/CONTRIBUTING.md)(https://github.com/defenseunicorns/uds-template-capability/blob/main/CONTRIBUTING.md#submitting-a-pull-request) followed --------- Co-authored-by: Micah Nagel <[email protected]>
… encoded slashes (#330) ## Description PR to address `DECODE_AND_MERGE_SLASHES` causing issues in certain applications. Gives the ability to selectively turn this off in a namespace with the `UDSPackage` CR. ## Related Issue Fixes #288 ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds functionality) - [ ] Other (security config, docs update, etc) ## Checklist before merging - [x] Test, docs, adr added or updated as needed - [X] [Contributor Guide Steps](https://github.com/defenseunicorns/uds-template-capability/blob/main/CONTRIBUTING.md)(https://github.com/defenseunicorns/uds-template-capability/blob/main/CONTRIBUTING.md#submitting-a-pull-request) followed --------- Co-authored-by: Micah Nagel <[email protected]>
Steps to reproduce
api/v4/projects/namespace%2Fproject
through the istio tenant gatewayExpected result
Project info is received
Actual Result
Gitlab serves a 404 since it's expecting the url to not have been decoded
Visual Proof (screenshots, videos, text, etc)
Severity/Priority
Medium: at least gitlab web ide is broken, but any other api requests that need encoded slashes are too
Additional Context
Add any other context or screenshots about the technical debt here.
The text was updated successfully, but these errors were encountered: