-
Notifications
You must be signed in to change notification settings - Fork 284
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
Fixes #2023: incorrect URI parsing caused Digest auth failure. #2059
Conversation
Thanks for the pull request! I have two questions: It appears that there are a few more issues in this function that I'd later target in a separate PR. |
Just to make sure, does the incorrect parsing just happen if the URI contains "=", or is there any other case that I'm missing?
Yes that is correct.
At which kind of input is the stripLeft() targeted?
Each parameter is usually separated by a comma and whitespaces:
https://en.wikipedia.org/wiki/Digest_access_authentication#Example_with_explanation
So param would contain e.g. ` uri="/?a=b"`
2018-02-10 6:49 GMT+13:00 Sönke Ludwig <[email protected]>:
…
Thanks for the pull request! I have two questions:
Just to make sure, does the incorrect parsing just happen if the URI contains "=", or is there any other case that I'm missing? At which kind of input is the stripLeft() targeted?
It appears that there are a few more issues in this function that I'd later target in a separate PR.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
It appears that there are a few more issues in this function that I'd later target in a separate PR.
Are these causing incorrect authentication success/failure?
2018-02-10 6:49 GMT+13:00 Sönke Ludwig <[email protected]>:
…
Thanks for the pull request! I have two questions:
Just to make sure, does the incorrect parsing just happen if the URI contains "=", or is there any other case that I'm missing? At which kind of input is the stripLeft() targeted?
It appears that there are a few more issues in this function that I'd later target in a separate PR.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I think I mostly had parameters without quotes in mind, as well as quoted strings that contain a comma, so since those would lead to wrong parameter value contents they could indeed lead to failures. |
According to the RFC2069, and RFC2617 which supersedes the former, all parameter values are quoted strings, so we are good here [1, 2]. By the way, I noticed that we send the
Commas however are a problem indeed, since they could be present in the field [1] https://tools.ietf.org/html/rfc2069#page-4 |
There are some fields that are not, for example
Even that is problematic, because double-quotes can be escaped as
Parsing the quoted string would then:
|
Indeed, However I am surprised to see the example from wikipedia with an unquoted Indeed, again. Note that with the current implementation we should not receive these two parameters, since they are sent only when the server sends a
Do you mean that quotes could be either specified or omitted for the value of one same given parameter? I have not been able to find that in the RFC. What do you mean by important? I do not think
I found that firefox does not escape nor encode the backslash in the If we allow By the way, this document has expired in Feb 2012. [1] https://en.wikipedia.org/wiki/Digest_access_authentication#Example_with_explanation |
You are right, I read that too quickly.
Important just in the sense that if something with the quote removal isn't implemented right, the authentication validation result will be wrong. If we handle both possibilities, this will be done correctly more or less automatically though, so the statement was more or less redundant.
The Would be interesting to see whether Firefox actually escapes a trailing backslash, and which encoding it uses for |
Yeah, a.k.a slicing blindly.
Understood.
Thanks!
It does not, so we really get the string
Percent encoding: I realized that
That was incorrect, even with the RFC2069 alone. The
I have checked the other fields we currently support. Only
This is actually the example from the RFC2617 [2].
That is incorrect too [1]. We send it right. [1] https://tools.ietf.org/html/rfc2069#page-4 |
I found that Edge and Chrome also percent-encode the double quote. Edge also does not escape nor encode the backslash. Chrome escapes the backslash. |
This field is sent by the server, not the client. I think there are several issues at hand:
Case 1 is very common, and I think it should be fixed as soon as possible. Other cases are less common, and may involve research time to find a solution (case 4). I think the whole parsing could be reworked in a following PR. By the way, such parsing of field lists seems to be common when handling HTTP headers, so it might be better done as a function independent from this module so that it is reusable. What do you think? |
Related PR: #1931 |
I agree that we can split this up into an immediate fix and a full fix. A reusable function for this may also be useful, although obviously it requires extra-care to account for possibly differing specification details. Regarding percent-decoding, I don't think that we should do that. The string between the quotes is used verbatim when computing the digest, so fortunately at least there we don't have to do any workarounds. For the @tchaloupka: I thought that the PR was merged a long time ago, that's definitely a drawback of the |
Sorry for the delayed reply.
Too bad that it did not make into 0.8.3; hopefully this immediate fix will be included in the next release. I extended the fix to cover case 2 in addition to case 1. That is, there should be no failure caused by an equal sign
Yes, I agree.
Note that the linked PR did not overlap in feature nor in code with this one. |
No description provided.