SHA 256 Digest Authentication
Categories
(Core :: Networking, enhancement, P5)
Tracking
()
Tracking | Status | |
---|---|---|
firefox93 | --- | fixed |
People
(Reporter: ph, Assigned: gs-bugzilla.mozilla.org)
References
Details
(Keywords: dev-doc-complete, sec-want, Whiteboard: [necko-would-take])
Attachments
(5 files, 3 obsolete files)
14.86 KB,
patch
|
dveditz
:
review+
|
Details | Diff | Splinter Review |
18.50 KB,
patch
|
Details | Diff | Splinter Review | |
27.40 KB,
patch
|
Details | Diff | Splinter Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
6.29 KB,
text/plain
|
Details |
Comment 1•16 years ago
|
||
Comment 2•16 years ago
|
||
Reporter | ||
Comment 3•16 years ago
|
||
Comment 4•16 years ago
|
||
Comment 5•16 years ago
|
||
Comment 6•9 years ago
|
||
Comment 7•9 years ago
|
||
Comment 8•9 years ago
|
||
Comment 9•9 years ago
|
||
Comment 10•9 years ago
|
||
Comment 11•9 years ago
|
||
Updated•9 years ago
|
Updated•9 years ago
|
Updated•9 years ago
|
Comment 12•9 years ago
|
||
Comment 13•9 years ago
|
||
Comment 14•9 years ago
|
||
Comment 15•8 years ago
|
||
Comment 16•7 years ago
|
||
Comment 17•7 years ago
|
||
Comment 18•7 years ago
|
||
Comment 19•7 years ago
|
||
Comment 20•6 years ago
|
||
If someone wants to rebase the patch, and is willing to add unit tests for it in netwerk/test/unit/test_authentication.js it would be great to land it.
Comment 21•6 years ago
|
||
Guys... there is a very common use-case for home routers where they want to transfer authentication without tls.
Making them transfer it in MD5 because the privacy-aware and security-aware browser doesn't implement SHA-256 for this is insecure.
Chrome is also broken for this (ignores algorithm= and continues with md5) but if you think about your own home router... it's a missing piece of the security puzzle isn't it?
Comment 22•4 years ago
|
||
I'm currently adding support for Digest auth to a web server, but I'm hitting the wall of SHA-256 being unsupported by all major web browsers. One can only wonder: why? If Digest auth is already supported, adding support for more secure algorithms seems like a minor inconvenience, just a few lines of code away.
It may be of little use today, but it has clear advantages over an HTML form. It requires no CGI, the web server is free to manage sessions at will, and it provides fairly acceptable security without TLS. And if you need absolute security, Digest+TLS with a strong hashing algorithm is thw way to go. TLS makes sure no third party messes around with our connection, and Digest makes sure we don't send our password as cleartext over the network. Imagine the security breaches that could have been avoided if we just followed the standard, secure-by-default path, so web admins had to confront password hashing as an immediate priority, and not just as an afterthought: no, you are not storing plaintext passwords anywhere, because you are not getting them in the first place. By default.
I really think that Digest+TLS+a better UI for standard authentication (one more pleasing, which shows info about the host, the realm, and the algorithm being used) may be not only attractive for web developers, but also desirable (and, depending on the environment—routers, intranets and such, also neccesary). And I may start working on that last one if this goes anywhere.
Comment 23•4 years ago
|
||
(In reply to Valentin Gosu [:valentin] (he/him) from comment #20)
If someone wants to rebase the patch, and is willing to add unit tests for it in netwerk/test/unit/test_authentication.js it would be great to land it.
I've created new patch based on Teun van Eijsden's with proposed improvements. I'd be happy if someone with proper rights reviews it and runs the tests.
Comment 24•4 years ago
|
||
(In reply to Vit Hampl from comment #23)
I've created new patch based on Teun van Eijsden's with proposed improvements. I'd be happy if someone with proper rights reviews it and runs the tests.
I'm not a C++
developer, but from what i can tell, it looks good.
I also filed an issue over at the chromium project and apple-support (no link cause of policy stuff) for supporting rfc7616 that are currently awaiting triage, so if all goes well, we might see proper support for this across the board soon.
Assignee | ||
Comment 25•4 years ago
|
||
Glad to see this is still alive. A long time ago, I had rewritten the original patch from Teun van Eijsden, but did not have sufficient disk space on my laptop to build Firefox. Now that I do, I have tested my patches against lighttpd, which has supported algorithm=SHA-256 since lighttpd 1.4.54 (released May 2019) (https://redmine.lighttpd.net/projects/lighttpd/wiki/Release-1_4_54). I'll attach my patches shortly.
My patches also improve preferential ordering for algorithm selection. (Any privileged committer: please let me know if I should submit that patch separately.) https://bugzilla.mozilla.org/show_bug.cgi?id=281851
My patches differs slightly from those of Vit Hampl, though I have incorporated the tests that Vit added (thanks!) However Vit's test has two errors.
algorithmRE
must match "SHA-256", but \w+
does not match '-'
fix: var algorithmRE = /algorithm=([\w-]+)/;
A2 must include the url-path. This was copied from the MD5 test (with test url-path /auth/digest), but not updated to /auth/digest_sha
fix: var A2 = "GET:/auth/digest_sha";
Assignee | ||
Comment 26•4 years ago
|
||
Tests have been run with ./mach test netwerk/test/unit/test_authentication
on x86_64 debug build.
Bug 472823 SHA 256 Digest Authentication
Original patch by Teun van Eijsden
Tests added by Vit Hampl <mozilla@bugear.com>
Original patch updated and tests fixed by gstrauss
Bug 281851 CVE-2005-2395 Wrong scheme used when server offers both Basic and Digest auth [rfc2617 obsoletes rfc2068]
At the risk of submitting the patch twice, I'll try submitting with moz-phab
next.
Assignee | ||
Comment 27•4 years ago
|
||
fixes:
Bug 472823 SHA 256 Digest Authentication
Original patch by Teun van Eijsden
Tests added by Vit Hampl <mozilla@bugear.com>
Original patch updated and tests fixed by gstrauss
fixes:
Bug 281851 CVE-2005-2395 Wrong scheme used when server offers both Basic and Digest auth
Updated•4 years ago
|
Assignee | ||
Comment 28•4 years ago
|
||
Vit, should I add support for "SHA-256-sess"? Your patch recognizes it, my patch does not.
Does any popular server implement "SHA-256-sess"? Does any popular server implement "MD5-sess"?
Apache does not implement MD5-sess (https://httpd.apache.org/docs/trunk/mod/mod_auth_digest.html#authdigestalgorithm)
(From a quick glance at the doc, Apache and nginx do not appear to support "SHA-256" digest auth)
Comment 29•4 years ago
|
||
Nice to see a progress. As for the -sess variant, from my point of view I don't see any strong reason not to add it. It is in the standard and it does not mean adding excessive amount of code, as it just utilises existing mechanism only with different hashing algorithm. There is bug https://bugzilla.mozilla.org/show_bug.cgi?id=270447 in the existing mechanism that limits the current use, but fix of the bug will be algorithm-independent.
From looking around, IIS should support MD5-sess. I'm not aware of any popular server currently supporting SHA-256-sess.
Assignee | ||
Comment 30•4 years ago
|
||
As for the -sess variant, from my point of view I don't see any strong reason not to add it. It is in the standard and it does not mean adding excessive amount of code
I agree that it probably does not add much code. However, it should ideally also have a unit test. Do you have interest in adding one?
I tested my version of the SHA-256 patches against a real webserver (lighttpd) in addition to the unit test. I am familiar with no such web server to be able to test SHA-256-sess and am hesitant to add support that I would not be confident testing. ...Update: someone noted that passport-http supports MD5-sess in https://github.com/postmanlabs/postman-app-support/issues/2941 but I have not verified that.
==> If the patches proposed here are accepted, adding support for additional algorithms, such as SHA-256-sess or SHA-512-256, becomes easier once there is a demonstrated use/need.
Assignee | ||
Comment 31•4 years ago
|
||
I updated the proposed patch to include "SHA-256-sess" and to prefer SHA-256 when multiple challenges with both SHA-256 and MD5 are offered.
https://phabricator.services.mozilla.com/D106241
Comment 32•4 years ago
|
||
Comment 33•4 years ago
|
||
Comment 34•4 years ago
|
||
Comment 35•4 years ago
|
||
Comment 36•4 years ago
|
||
The unit test for -sess variants should only differ in A1 computation (and things around like headers). More extensive examples are in attachment unit-parts.js (sorry for probable spamming with attachments, it always showed an error and only after several attempts I found out, that they all got uploaded).
var A1;
if (algorithm != null && algorithm.endsWith("-sess")){
A1 = [HXXX("guest:secret:guest"), nonce, cnonce].join(":"); //replace HXXX with actual hashing function
} else {
A1 = "guest:secret:guest";
}
Assignee | ||
Comment 37•4 years ago
|
||
Thanks @Vit. There were a few mistakes in your attachment which I fixed up and added to https://phabricator.services.mozilla.com/D106241
Updated•4 years ago
|
Comment 38•4 years ago
|
||
Comment 39•4 years ago
•
|
||
Backed out 14 changesets (Bug 1705659, Bug 472823, Bug 669675) for causing bustages in nsHttpChannelAuthProvider.cpp
Backout link: https://hg.mozilla.org/integration/autoland/rev/a9431e068bcd2dc86778d9b12bc7775850e2736b
Push with failures, failure log.
(Update): Also caused mochitest plain failures.
Comment 40•4 years ago
|
||
Comment 41•4 years ago
|
||
bugherder |
Comment 43•4 years ago
|
||
Backed out 14 changesets (Bug 1705659, Bug 472823, Bug 669675) as requested by valentin for causing regressions.
https://hg.mozilla.org/integration/autoland/rev/4207821cb4e016141be3c4b331f1ede47c90c0b7
Comment 44•4 years ago
|
||
Comment 45•4 years ago
|
||
Backout merged to central: https://hg.mozilla.org/mozilla-central/rev/4207821cb4e0
Comment 46•4 years ago
|
||
Comment 47•4 years ago
|
||
bugherder |
Updated•4 years ago
|
Comment 48•3 years ago
•
|
||
I'm soon going to start the FF93 docs work for this - you can track in https://github.com/mdn/content/issues/8682#issuecomment-917953353
- Would I be correct that this support for the sha256 can be used in both HTTP
Digest
and also in HTTP Authentication? - With respect to HTTP Authentication, does Firefox support anything other than the basic authentication and digest with md5 (and now sha256) - see the list?
Comment 49•3 years ago
|
||
(In reply to Hamish Willee from comment #48)
I'm soon going to start the FF93 docs work for this - you can track in https://github.com/mdn/content/issues/8682#issuecomment-917953353
- Would I be correct that this support for the sha256 can be used in both HTTP
Digest
and also in HTTP Authentication?
These changes only cover authentication, not HTTP Digest.
- With respect to HTTP Authentication, does Firefox support anything other than the basic authentication and digest with md5 (and now sha256) - see the list?
Depending on the operating system and installed utilities, we support basic, digest (on all platforms), and ntlm and negotiate (kerberos) depending on whether OS support is available - see here
Assignee | ||
Comment 50•3 years ago
|
||
Hamish: FYI, the lighttpd web server has supported HTTP Authentication method Digest with algorithm=SHA-256 (RFC 7616) since lighttpd 1.4.54 (May 2019). A few weeks ago, I tested lighttpd mod_auth with FF93 (alpha?) from the nightlies, and FF93 successfully authenticated using HTTP Auth Digest with algorithm=SHA-256. FF93 also correctly uses SHA-256 when lighttpd provides multiple WWW-Authenticate digest challenges (e.g. algorithm=SHA-256 and algorithm=MD5)
With FF93, Firefox joins Opera in supporting HTTP Authentication method Digest with algorithm=SHA-256. Chrome does not yet support algorithm=SHA-256: https://bugs.chromium.org/p/chromium/issues/detail?id=1160478
Valentin: Thank you for all your effort in getting this feature into Firefox!
Updated•3 years ago
|
Comment 51•3 years ago
|
||
FYI I have marked this dev-doc-complete - you can track work that was done in https://github.com/mdn/content/issues/8682
The actual work "required" for the release is minimal - the release note and starting to record algorithm compatibility information in BCD (still in discussion).
Other MDN docs got a "polish" to make them a bit less "Basic authentication"-centric - i.e. introduce Digest authentication and make it clear more clear that the directives depend on the algorithm used.
Comment 52•3 years ago
|
||
(In reply to Hamish Willee from comment #48)
I'm soon going to start the FF93 docs work for this - you can track in https://github.com/mdn/content/issues/8682#issuecomment-917953353
- Would I be correct that this support for the sha256 can be used in both HTTP
Digest
and also in HTTP Authentication?
...
FWIW, in what sense does Firefox support the "Digest" header field at all? (and the same question applies to the other browsers)
Comment 53•3 years ago
|
||
@julian - re ^^^^ No idea. The spec looks "speculative" - ie you "could" check the representation for round trip integrity. I'd be interested in the answer :-)
Comment 54•3 years ago
•
|
||
(In reply to Hamish Willee from comment #53)
@julian - re ^^^^ No idea. The spec looks "speculative" - ie you "could" check the representation for round trip integrity. I'd be interested in the answer :-)
Opened https://github.com/mdn/content/issues/9139 (which is about the MDN documentation of the "Digest" header field, which has nothing to do with the "Digest" authentication scheme this bug is about).
Comment 55•3 years ago
|
||
Thank you everybody for all your efforts.
I just downloaded Firefox 93 beta on my Mac and tested HTTP Digest Authentication against my own tiny web server which is written in C and used for controlling embedded devices. This one offers the SHA-256 algorithm (besides MD5), and it works perfectly together with Firefox 93.
My server says:
WWW-Authenticate: Digest realm="MyDevice",qop="auth",algorithm=SHA-256,nonce="819215e26641495c707d87bc9016edafb74f0152bed7ba50e38f8177aff4341900000000",stale=true
WWW-Authenticate: Digest realm="MyDevice",qop="auth",algorithm=MD5,nonce="819215e26641495c707d87bc9016edafb74f0152bed7ba50e38f8177aff4341900000000",stale=true
And Firefox chooses SHA256, here the Authorization header of a GET request:
Authorization: Digest username="xxx", realm="MyDevice", nonce="a5fbd50dc8888ea2deb961e93ce05a6836feca6f6087695bca1acd9306c5d3a700000000", uri="/|update|,|", algorithm=SHA-256, response="c6c9dbe83446efccd7d02373d0138381a66ef8fc72b710fea65ab385f9849dea", qop=auth, nc=0000000e, cnonce="7650c4a946133c98"
Everything works very well. Now besides TLS, the level of authorization security has been risen significantly.
Updated•3 years ago
|
Description
•