[SR-Users] people complain Kamailio not handling stale nonce correctly

Henning Westerholt hw at skalatan.de
Tue Jul 2 19:30:15 CEST 2019


Hello,

I did a quick check in the code, this is the path:

auth_check() -> digest_authenticate_hdr() -> auth_api.pre_auth() -> check for stale nonce etc..

DB calls are done later in the code path. So it looks that there is no possibility to do a DB DOS just with this path.

And as Juha mentioned, it is also not good from a security POV to keep sending the password hash again and again.

Cheers,

Henning


Am 02.07.19 um 19:04 schrieb Daniel-Constantin Mierla:
Hello,
I am not sure if this option is actually implemented according to the specs. iirc, stale=true should be set when the server checks the username and password and all is ok, but the nonce is expired. afaik, the check for nonce expiration is done before hiting the database to fetch the password and check the response. In UA side the stale=true would just make the app rebuild the response without prompting for password again, because the server said that with the expired nonce all was ok, from user/password point of view.

But if we hit the database for every expired nonce, then we expose the server to kind of a DoS processing.

Moreover, the latest recommendations in security is to disclose as less as possible what was not "correct", avoiding responses like "invalid user id" or "invalid password".

The lack of stale=true means that the UA should build again the authorization header from scratch with all the attributes.

I won't be against enabling this option if it would be for a "trusted" endpoint, but for servers exposed to the wild world, it may create some security concerns.

Therefore for the moment I would suggest to wait for more feedback from community, along with checking if the stale=true is implemented as per spec or is half brewed option.

Cheers,
Daniel

On Tue, Jul 2, 2019 at 6:48 PM Henning Westerholt <hw at skalatan.de<mailto:hw at skalatan.de>> wrote:
Hello Juha,

sounds like a good idea to me, we should integrate it to the default cfg.

Just a small comment, I think this would be match the current behaviour
more closely (only return stale=true, don't use qop=auth).

!                       case -4:
!                               auth_challenge("$fd", 16);
!                               exit;


Cheers,

Henning

Am 02.07.19 um 17:15 schrieb Juha Heinanen:

> Several people are complaining on baresip git that Kamailio is among
> those SIP servers that don't handle stale nonce properly, i.e., don't
> include stale=true flag in WWW-Authenticate header of 401 response.
>
> I have tried to tell that Kamailio does what it has been configured to
> do, but the response is that "by default" Kamailio works incorrectly.  "By
> default" I guess refers to the example Kamailio kamailio.cfg in etc dir.
>
> How about adding stale nonce handling to the example config, for
> example, like in below?
>
> -- Juha
>
> *** kamailio.cfg      2019-06-13 17:17:17.182148989 +0300
> --- /tmp/kamailio.cfg 2019-07-02 18:02:02.947183503 +0300
> ***************
> *** 745,753 ****
>
>       if (is_method("REGISTER") || from_uri==myself) {
>               # authenticate requests
> !             if (!auth_check("$fd", "subscriber", "1")) {
> !                     auth_challenge("$fd", "0");
> !                     exit;
>               }
>               # user authenticated - remove auth header
>               if(!is_method("REGISTER|PUBLISH"))
> --- 745,759 ----
>
>       if (is_method("REGISTER") || from_uri==myself) {
>               # authenticate requests
> !             switch (auth_check("$fd", "subscriber", "1")) {
> !                     case 1:
> !                             break;
> !                     case -4:
> !                             auth_challenge("$fd", 17);
> !                             exit;
> !                     default:
> !                             auth_challenge("$fd", "0");
> !                             exit;
>               }
>               # user authenticated - remove auth header
>               if(!is_method("REGISTER|PUBLISH"))
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org<mailto:sr-users at lists.kamailio.org>
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

--
Henning Westerholt - https://skalatan.de/blog/
Kamailio services - https://skalatan.de/services

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users at lists.kamailio.org<mailto:sr-users at lists.kamailio.org>
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


--
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda



_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users at lists.kamailio.org<mailto:sr-users at lists.kamailio.org>
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


--
Henning Westerholt - https://skalatan.de/blog/
Kamailio services - https://skalatan.de/services
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20190702/578da5ea/attachment.html>


More information about the sr-users mailing list