Summary:ASTERISK-25978: res_pjsip_authenticator_digest: Should not use source port in nonce verification
Reporter:Mark Michelson (mmichelson)Labels:
Date Opened:2016-05-02 13:25:01Date Closed:2016-05-09 22:36:29
Versions:13.8.2 Frequency of
Description:res_pjsip_outbound_authenticator_digest builds a nonce that is a hash of the timestamp, the source address, the source port, a server UUID that is calculated at startup, and the authentication realm.

Rather than caching nonces that we create, we instead attempt to re-calculate the nonce when receiving an incoming request with authentication. We then compare the re-calculated nonce to the incoming nonce, and if they don't match, then authentication has failed early.

The problem is that it is possible, especially when using TCP, to receive two requests from the same endpoint but have differing source ports for those requests. Asterisk itself commonly will use different source ports for outbound TCP requests.

The easy fix here is to remove the source port from nonce calculation. It may be prudent, however, to add something else to the hash calculation in place of the port instead of just removing that factor.