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

Properly handle very long URL fragments captured during SAML handshake. #53505

Closed
wants to merge 1 commit into from

Conversation

azasypkin
Copy link
Member

@azasypkin azasypkin commented Dec 18, 2019

This PR implements the alternative workaround proposed in #53478 (comment):

Alternatively we can just decide on the client side whether URL fragment is already too long and not send it at all (e.g. if it's already bigger than the default limit of 2kb) - that'd be easier and safer. I'm leaning towards this solution.

Fixes: #53478


"Release note: Since Kibana 7.5 we started to fully preserve the URL user used to login with SAML, but some very long URLs managed to exceed the size that Kibana server can accept leading to failures during SAML login. With this fix we truncate user URLs before sending them to the server if they exceed the limit."

@azasypkin azasypkin added release_note:fix Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! Feature:Security/Authentication Platform Security - Authentication v7.6.0 v7.5.2 labels Dec 18, 2019
@azasypkin azasypkin requested a review from a team as a code owner December 18, 2019 16:24
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

@@ -43,11 +50,15 @@ export function defineSAMLRoutes({ router, logger, authc, csp, basePath }: Route
options: { authRequired: false },
},
(context, request, response) => {
// NodeJS limits the maximum size of the Request-Line + all HTTP headers to 8KB.
// See https://nodejs.org/api/cli.html#cli_max_http_header_size_size.
const maxRedirectURLSize = config.authc.saml?.maxRedirectURLSize.getValueInBytes() ?? 4096;
Copy link
Member Author

@azasypkin azasypkin Dec 18, 2019

Choose a reason for hiding this comment

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

note: it's technically possible to call this endpoint even if SAML is not enabled (no use case for that yet), so that config isn't available. I thought not throwing error would be better, but I don't have strong opinion here.

Technically we can just hardcode any number here and not rely on config at all (since it's tied to NodeJS limit and not to what set through config). Curious what you have in mind?

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@azasypkin
Copy link
Member Author

I've been made aware that Kibana in prod is already configured to allow up to 64KB of headers incl. path. That sounds like enough to not hit this issue in real scenarios and if so we can probably wait till proper "custom HTML renderer" where we can just send entire URL fragment to a server via POST.

I'll talk to the original reporters/env maintainers to understand why they're hitting this issue on their environment.

@azasypkin
Copy link
Member Author

UPDATE: so we found that the root cause of the original SAML issue is in a proxy that sits in front of Kibana and has its own URL/headers size limit that's much lower than what we allow in Kibana server (64KB). Someone will bump up the limit there.

@kobelb
Copy link
Contributor

kobelb commented Jan 2, 2020

UPDATE: so we found that the root cause of the original SAML issue is in a proxy that sits in front of Kibana and has its own URL/headers size limit that's much lower than what we allow in Kibana server (64KB). Someone will bump up the limit there.

Given this information, do you think we should still pursue this change?

@azasypkin
Copy link
Member Author

azasypkin commented Jan 3, 2020

Given this information, do you think we should still pursue this change?

No, I'm leaning towards just closing this PR because 1. we haven't heard any "real" user complaints yet (default 64KB limit is quite large after all), 2. there is a good chance we can leverage the functionality introduced in #52161 (still needs some work) to do a proper POST call with entire fragment, 3. we have a workaround in case that actually happens in prod (set maxRedirectURLSize to 0) and 4. I just don't want to see this hacky and partial fix in our code base.

If there are no any objections I'll close this issue today/tomorrow.

@kobelb
Copy link
Contributor

kobelb commented Jan 3, 2020

If there are no any objections I'll close this issue today/tomorrow.

Sounds good to me!

@azasypkin azasypkin closed this Jan 3, 2020
@azasypkin azasypkin deleted the issue-xxx-saml-long-url branch January 3, 2020 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Security/Authentication Platform Security - Authentication release_note:fix Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v7.5.2 v7.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants