IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

Bug in Basic Authentication parsing for client credentials

Open wallymathieu opened this issue 8 years ago • 12 comments

We have noticed that some of our (NodeJS based) clients have started having issues connecting to IdentityServer4 using existing code. There are two issues related to this on the library that we use:

https://github.com/lelylan/simple-oauth2/issues/148

https://github.com/lelylan/simple-oauth2/issues/167

As far as we have found, we can't use any special chars in client secrets in newer versions of the above lib. This kind of issue sounds a bit hairy that could end up breaking existing applications if behavior is changed.

wallymathieu avatar Jan 31 '18 14:01 wallymathieu

Have you posted a question to Stack Overflow? Please do and post the link here. You'll likely need to post at least some code fragments from your clients to go with that question.

DiginessForever avatar Feb 01 '18 06:02 DiginessForever

What kind of question would be suitable for stackoverflow?

Clients in possession of a client password MAY use the HTTP Basic authentication scheme as defined in [RFC2617] to authenticate with the authorization server. The client identifier is encoded using the "application/x-www-form-urlencoded" encoding algorithm per Appendix B, and the encoded value is used as the username; the client password is encoded using the same algorithm and used as the password. - Source

The code to reproduce it is simply to use the above mentioned library to connect to identity server with a password that is different when url encoded.

https://github.com/lelylan/simple-oauth2/blob/master/example/index.js

 const oauth2 = simpleOauthModule.create({
    client: {
      id: 'client.id',
      secret: 'asfdasd+fdsafdsa^fdsafsd&',
    },
    auth: {
      tokenHost: 'https://id.somedomain.com',
      tokenPath: '/connect/token',
      authorizePath: '/connect/authorize',
    },
  });

wallymathieu avatar Feb 01 '18 06:02 wallymathieu

Since I've not read the spec, I was hoping that someone else could read it and say : yay or nay. If this is something that is wrong in identity server, then changing it might break things ...

wallymathieu avatar Feb 01 '18 06:02 wallymathieu

yes

https://identityserver4.readthedocs.io/en/release/intro/specs.html

leastprivilege avatar Feb 01 '18 06:02 leastprivilege

thanks @leastprivilege

wallymathieu avatar Feb 01 '18 06:02 wallymathieu

I'm closing the question, since it's answered.

wallymathieu avatar Feb 01 '18 06:02 wallymathieu

I currently have not enough time to file a full bug report. But someone with more time could perhaps do that ...

wallymathieu avatar Feb 01 '18 06:02 wallymathieu

If I may jump in here, username and password (from OAuth2 clients) must be url-encoded according to RC6749. This is to keep consistency between using them in POST body, query params, and headers as well as to prevent this (what's the username? what's the password?): user:name:password (urlencoded: user%3Aname:password). If that's not the case, then you should consider fixing it.

aeneasr avatar Feb 01 '18 09:02 aeneasr

HTTP Basic says the username is TEXT (except the ":"), whereas 6749 says it's a form-urlencoded value. But those aren't exactly the same.

What we implemented was HTTP basic authentication, not the OAuth2 version of HTTP basic.

So this is what you think we need to change to? Authorization Basic Base64(FormUrlEncode(client_id):FormUrlEncode(client_secret))

brockallen avatar Feb 01 '18 13:02 brockallen

That's how I solved it for fosite & hydra

aeneasr avatar Feb 01 '18 13:02 aeneasr

fixed on dev

leastprivilege avatar Feb 06 '18 13:02 leastprivilege

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 13 '20 17:01 lock[bot]