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

Don't send POST params on query string also #610

Merged
merged 1 commit into from
May 3, 2023

Conversation

jabbera
Copy link
Contributor

@jabbera jabbera commented May 2, 2023

token_url takes post data, don't also send the same data on the query string.

@consideRatio
Copy link
Member

Not confident on theory here, and lacking live integration tests, i think there it would be good to either review the behavior in 15.1.0 about the behavior used then or try validate what we do against a oauth2 standard document.

I'm on vacation and wont look into it now, but wanted especially to say: thank you @jabbera for your help with these patches!!! ❤️ 🎉 🌻

@consideRatio
Copy link
Member

My intuition agrees with that this makes sense btw, just hoping its not required by some authenticator for a weird reason.

@jabbera
Copy link
Contributor Author

jabbera commented May 2, 2023

Full disclosure: only tested on AzureAD.

By doing this you we are putting the server side secret and the refresh token in the query string. This is explicitly against OWASP guidance and the oauth spec*. Any auth provider that requires this would not be an auth provider worth trusting IMO and should have provider specific overrides to support this broken behavior so other providers don't leak secrets.

In our case we redirect all traffic out a corporate firewall. By putting these secrets in the query string anyone with access to read firewall traffic history can now impersonate any user who was logged into our jupyterhub instance. (We keep track of what URIs people visit) To make matters worse (for us) we use the on behalf of oauth flow to generate user tokens that allow impersonated access to storage and sql resources. This is all really bad stuff and a legitimate auth provider would never require post data to be sent on the query string.

At a minimum I'd request the removal of the refresh token and the client secret.

*The client MUST use the HTTP "POST" method when making access token requests.

@jabbera
Copy link
Contributor Author

jabbera commented May 2, 2023

I spot checked some of the 15.1.0 providers and there is a mix of ones that use the query string (GitHub) and those that don't (AzureAD, auth0, generic). That said, I can't imagine any require a secret to be passed this way for the reasons mentioned above. I'm happy to live off my fork but this is a default insecure configuration that's being provided and my sec team won't allow it. I can't imagine I'm alone here.

@consideRatio
Copy link
Member

Thanks for clarifying this is also to be considered a security aspect and looking into this further @jabbera!

I understand that both query strings and post body is encrypted, but query strings may get stored in logs and such far more often and that is against OWASP recommendations.

To me, that is a good enough background to dare go for it.

Screenshot_20230502-185343

@GeorgianaElena or @manics wdyt, lets go for a merge?

@manics
Copy link
Member

manics commented May 2, 2023

Including POST parameters in the URL originates from this comment:
#526 (comment)
which references the GitLab authenticator.

We've got two options here:

  1. Merge this PR as is, and hope that GitLab no longer requires parameters in the URL (ideally someone who uses GitLab would test this)
  2. Modify GitLab only to override this change

As you can probably guess 1. is a better option.

@manics
Copy link
Member

manics commented May 2, 2023

Based on a quick skim of the latest version of the referenced GitLab doc I can't see anything about needing URL parameters:
https://github.com/gitlabhq/gitlabhq/blob/v15.11.1/doc/api/oauth2.md

Edit: actually I'm not sure, the example Ruby code is

parameters = 'client_id=APP_ID&code=RETURNED_CODE&grant_type=authorization_code&redirect_uri=REDIRECT_URI&code_verifier=CODE_VERIFIER'
RestClient.post 'https://gitlab.example.com/oauth/token', parameters

Does this mean parameters is the body, or is it added as the URL query string?

@consideRatio
Copy link
Member

I think the post body is used when Ruby's REST client is used like in their example.

https://www.rubydoc.info/gems/rest-client/2.1.0/RestClient

The format of the body makes me wonder still, but i think we can work that separately. This PR doesnt change the post body anyhow

@consideRatio
Copy link
Member

Ah the example post body is now something that i recognize as a x-www-form-urlencoded string like: Name=John+Smith&Age=23

So, i think we should be fine in gitlab as well without fixes.

👍 For merge

@manics manics merged commit 921824c into jupyterhub:main May 3, 2023
9 checks passed
@jabbera jabbera deleted the remove-get-params branch May 3, 2023 10:01
@jabbera
Copy link
Contributor Author

jabbera commented May 3, 2023

Thanks folks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants