[Home]

Summary:ASTERISK-25387: res_pjsip_nat: Malformed REGISTER request causes NAT'd Contact header to not be rewritten
Reporter:Matt Jordan (mjordan)Labels:
Date Opened:2015-09-10 08:37:43Date Closed:2015-09-11 16:15:50
Priority:MinorRegression?
Status:Closed/CompleteComponents:Resources/res_pjsip_nat
Versions:13.5.0 Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Consider the following REGISTER request:

{code}
<--- Received SIP request (699 bytes) from UDP:127.0.0.1:5060 --->
REGISTER sip:127.0.0.1:5061 SIP/2.0
Record-Route: <sip:127.0.0.1;lr>
Via: SIP/2.0/UDP 127.0.0.1;branch=z9hG4bK007b.2356f13f445725767aee5ecd1028fc69.0
Via: SIP/2.0/UDP 127.0.0.1:5070;received=127.0.0.1;rport=5070;branch=z9hG4bKPj454b6886-a832-48b2-aae1-694be8ccbf5b
Route: <sip:127.0.0.1:5060;lr>
From: <sip:foo@127.0.0.1>;tag=8e2a25cb-8999-4397-9bb4-d204622ba14f
To: <sip:foo@127.0.0.1>
Call-ID: 1ba5c0a5-4bb4-4d76-a0d1-416f0cae63ba
CSeq: 59033 REGISTER
Contact: <sip:foo@127.0.0.1:5070>
Expires: 3600
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REGISTER, REFER
Max-Forwards: 69
User-Agent: bar
Content-Length:  0


{code}

For some sad reason, this REGISTER request contains a Record-Route header, which it clearly shouldn't:

{quote}
  A REGISTER request does not establish a dialog.  A UAC MAY include a
  Route header field in a REGISTER request based on a pre-existing
  route set as described in Section 8.1.  The Record-Route header field
  has no meaning in REGISTER requests or responses, and MUST be ignored
  if present.  In particular, the UAC MUST NOT create a new route set
  based on the presence or absence of a Record-Route header field in
  any response to a REGISTER request.
{quote}

Unfortunately, we don't ignore the Record-Route header in {{res_pjsip_nat}} if the request is a REGISTER request. As a result, this REGISTER request will cause the Contact to stay at {{127.0.0.1:5070}} instead of being rewritten to the received IP/port of {{127.0.0.1:5060}}.
Comments: