-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Authentication fails when using DIGEST_AUTH from Apple iPhone and iPad #4717
Comments
If it helps, I've captured the debug output from the serial terminal below for one iPad
|
@jason-but Could you capture the debug output of the browser side, show exactly what headers are sent from the client? BTW, MD5-sess was never correctly implemented in Mozilla, or Webkit.
It seems no major deployment of MD5-sess ever in the real world, so I wouldn't recommend to even think about MD5-sess, it is not worth the effort. :) |
I can try to capture the browser side if I can get some help. I don't know how to get debug info from an iPad and it's browser Ack on the MD5-sess Looking at my captured log above, I don't know if any of my three options are the problem as the "qop" variable is "auth" and not "auth-int" I think you are right, we need to somehow see the intermediate calculations at the iPad to properly see "where" it is going wrong |
Alternatively, can you alter the esp side source code and print the raw authorization header? The serial output indicate that at least the authorization header does not contain "qop=auth".
The question is, what exactly did the client send? |
So two separate comments here, one from a functioning Chrome Browser, followed by a non-functioning iPad. First from Chrome, here is a Serial output from the ESP8266
|
Now from the iPad
|
In both cases, the remote browser seems to respond with "qop=auth" so my initial analysis proved to be incorrect
However, looking more/very closely, the main difference appears to be:
Is failing because of the quotes and therefore the wrong string is being calculated? |
Yeap. Technically, I would say the fruity is in violation here, since RFC 2617 did not state quote is allowed in message-qop in section 3.2.2. |
Just finished scanning RFC2617 Interestingly (see Section 3.2.1) it allows quotes in qop on the WWW-Authenticate Response Header from the server but does not (Section 3.2.2) on the Authorization Request Header from the browser On my end, I am rather surprised this hasn't been caught earlier, the iPad/iPhone is not exactly a rare end-user device My guess would be the bug fix would require checking for both instances at line 194, or alternatively pulling the parameter out earlier on (lines 148-152) and storing the value regardless of quotes or no |
I have this working in some workaround code. If you change line 194 to recognize both instances, you will need to do the same at line 164 so that the _nc and _cnonce values are extracted. |
I presume you changed both conditionals to something like: if((authReq.indexOf(FPSTR(qop_auth)) != -1) || (authReq.indexOf(PSTR("qop=\"auth\"")))) { |
Yes. I defined another literal qop_auth_quote and used FPSTR, but same difference. I don't have the code to PR because I was just working through the issue on my way to writing a version of authorize that supports multiple outstanding sessions for multiple users. I implemented that as separate code as it really doesn't need to be in the class to work. But I'm satisfied that change fixes the IOS issue. |
Excellent |
If somebody makes a pr, I can review it. |
Do we know if a new build is out fixing this? Or when a fix will be released? I've verified that in the current ESP8266 arduino plugin I'm seeing this problem in all versions of Safari, iOS and Mac OS. When I run chrome or Firefox on the mac or iPhone it works fine though. The bug is bigger then an iOS bug. |
Reading @lukasostendorf's PR, it looks like it directly fixed this. Closing for now, but if there is still a problem with fruity computers, please do open a new issue so we can look at it. |
@earlephilhower Hello, In my view, the esp32 arduino-core seems to have a similar problem. Please tell me if you have some information about this fix to the esp32 arduino-core. |
@Hieromon, the PR is here: https://github.com/esp8266/Arduino/pull/5506/files You can check the -32 core and see if a similar change would make sense. I haven't done much w/the -32, so can't comment directly. |
@earlephilhower Always I surprise with your quick answer! |
Basic Infos
Platform
Settings in IDE
Irrelevant
Problem Description
I have built a web server using the ESP8266WebServer library and have come across an issue accessing the site via Apple products. I have tried using two different iPhone models (one 2 years old and one 3 years old) and two different iPad models (one 6 months old and one 3 years old) and all four devices indicate the same issues.
Problem Overview
If establishing a web site with NO authentication, everything works fine regardless of the browser or device being used
If establishing a web site with BASIC_AUTH authentication, everything works fine regardless of the browser or device being used
Establishing a web site with DIGEST_AUTH authentication does not function correctly. I have tried setting the authentications using:
For each of the three techniques above I have:
Apple products fail regardless of whether device is in AP or STA mode, the error message provided by HTTP_SERVER debugging is always that the hash response is incorrect
Apple products fail regardless of whether the iPhone/iPad is using the default Safari browser or the Chrome browser (although it appears that the Apple Chrome browser still uses the Safari libraries to submit qeb queries)
Code Evaluation
There is obviously an incorrect branch code that is taken based on the response Apple devices. Given the debug messages, it appears that the Digest_Auth branch of authenticate() in ESP8266WebServer.cpp IS being taken, however the incorrect response hash is being calculated.
Looking at the code, two possible options are being calculated
However, the standard implies that the value of qop (which the library hard-codes to "auth") should be either "auth" or "auth-int"
The standard also implies that there are two possible calculations for H1 and H2 of:
H1
H2
Whereas the existing code only calculates the first possibility of either H1 or H2
It appears that perhaps Apple devices are requiring one of the three currently not coded options in the DIGEST authentication library and that the code needs to be modified to support this.
Potential Fixes
Supporting auth or auth-int in final response hash
Supporting "auth" or "auth-int" appears to require an extra check in line 194 and modifying line 195 to use the actual parameter value rather than the hardcoded ":auth:"
Supporting alternate H1 Calculation
Supporing the more complex H1 requires (after line 172) checking if the algorithm directive is "MD5-sess" and then:
Supporting alternate H2 Calculation
Supporting the more complex H2 requires more thought. It appears the current code does not extract "entityBody" and so will have to be modified to support this
Conclusion
I am unsure which of these three changes are required to fix Apple brokenness
I note that if the issue is that the qop directive sent by Apple products is auth-int, then the solution will probably involve both fixing the H2 calculation AND modifying the code to calculate the final response hash
Given its current state, it is impossible to support digest authentcation on ESP8266WebServer for Apple devices accessing web sites
The text was updated successfully, but these errors were encountered: