[asterisk-bugs] [JIRA] (ASTERISK-30042) Registration over websocket returns a rewritten contact

Thomas Guebels (JIRA) noreply at issues.asterisk.org
Tue May 3 04:12:40 CDT 2022


     [ https://issues.asterisk.org/jira/browse/ASTERISK-30042?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Guebels updated ASTERISK-30042:
--------------------------------------

    Description: 
When registering over WebSocket using SIP.js, res_pjsip_transport_websocket rewrites the {{random.invalid}} contact that is sent in the REGISTER request. The original {{random.invalid}} host is replaced by the apparent ip:port from where the requests came from. This is then stored as the contact uri.

{code}
REGISTER sip:dev.elan.escaux.com SIP/2.0
Via: SIP/2.0/WSS k2km30gagse1.invalid;branch=z9hG4bK6030502
To: <sip:identity at localhost>
From: <sip:identity at localhost>;tag=31mhoq79ir
CSeq: 3 REGISTER
Call-ID: o5n3ln3aog19bdpt5bv6
Contact: <sip:bhe74v8j at k2km30gagse1.invalid;transport=ws>;expires=600
User-Agent: SIP.js/0.20.0
{code}

In the REGISTER response, this rewritten contact is sent back to SIP.js, triggering the following error, as SIP.js can't find back the contact it tried to register.

{code}
SIP/2.0 200 OK
Via: SIP/2.0/WSS k2km30gagse1.invalid;rport=42956;received=172.16.123.123;branch=z9hG4bK4399238
To: <sip:identity at localhost>;tag=z9hG4bK4399238
From: <sip:identity at localhost>;tag=31mhoq79ir
Call-ID: o5n3ln3aog19bdpt5bv6
CSeq: 3 REGISTER
Contact: <sip:bhe74v8j at 172.16.123.123:42956;transport=ws>;expires=599
Server: Asterisk PBX 18.7.1
{code}

bq. No Contact header pointing to us, dropping response
from https://github.com/onsip/SIP.js/blob/5555a9811f33df1f1461c9094a59b82307b25405/src/api/registerer.ts#L421

It is worth noting that this doesn't happen with the default SIP.js config in which it is more lenient and only verifies the user part of the contact. However, when you specify a custom contact user in the its configuration, it does the full check user at ip:port as per the RFC. This probably explains why one doesn't encounter that bug right away when trying SIP.js + asterisk. See https://github.com/onsip/SIP.js/blob/5555a9811f33df1f1461c9094a59b82307b25405/src/api/registerer.ts#L401

I tested a fix which is to save the original contact host in an x-ast-orig-host contact parameter, pretty much like it is done in res_pjsip_nat. It fixes my problem. If you think it is the right way to solve this I can provide a patch.

  was:
When registering over WebSocket using SIP.js, res_pjsip_transport_websocket rewrites the {{random.invalid}} contact that is sent in the REGISTER request. The original {{random.invalid}} host is replaced by the apparent ip:port from where the requests came from. This is then stored as the contact uri.

{code}
REGISTER sip:dev.elan.escaux.com SIP/2.0
Via: SIP/2.0/WSS k2km30gagse1.invalid;branch=z9hG4bK6030502
To: <sip:identity at localhost>
From: <sip:identity at localhost>;tag=31mhoq79ir
CSeq: 3 REGISTER
Call-ID: o5n3ln3aog19bdpt5bv6
Contact: <sip:bhe74v8j at k2km30gagse1.invalid;transport=ws>;expires=600
User-Agent: SIP.js/0.20.0
{code}

In the REGISTER response, this rewritten contact is sent back to SIP.js, triggering the following error, as SIP.js can't find back the contact it tried to register.

{code}
SIP/2.0 200 OK
Via: SIP/2.0/WSS k2km30gagse1.invalid;rport=42956;received=172.16.25.12;branch=z9hG4bK4399238
To: <sip:identity at localhost>;tag=z9hG4bK4399238
From: <sip:identity at localhost>;tag=31mhoq79ir
Call-ID: o5n3ln3aog19bdpt5bv6
CSeq: 3 REGISTER
Contact: <sip:bhe74v8j at 172.16.123.123:5247;transport=ws>;expires=599
Server: Asterisk PBX 18.7.1
{code}

bq. No Contact header pointing to us, dropping response
from https://github.com/onsip/SIP.js/blob/5555a9811f33df1f1461c9094a59b82307b25405/src/api/registerer.ts#L421

It is worth noting that this doesn't happen with the default SIP.js config in which it is more lenient and only verifies the user part of the contact. However, when you specify a custom contact user in the its configuration, it does the full check user at ip:port as per the RFC. This probably explains why one doesn't encounter that bug right away when trying SIP.js + asterisk.

I tested a fix which is to save the original contact host in an x-ast-orig-host contact parameter, pretty much like it is done in res_pjsip_nat. It fixes my problem. If you think it is the right way to solve this I can provide a patch.


> Registration over websocket returns a rewritten contact
> -------------------------------------------------------
>
>                 Key: ASTERISK-30042
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-30042
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Resources/res_pjsip_registrar, Resources/res_pjsip_transport_websocket
>    Affects Versions: 18.7.1
>            Reporter: Thomas Guebels
>
> When registering over WebSocket using SIP.js, res_pjsip_transport_websocket rewrites the {{random.invalid}} contact that is sent in the REGISTER request. The original {{random.invalid}} host is replaced by the apparent ip:port from where the requests came from. This is then stored as the contact uri.
> {code}
> REGISTER sip:dev.elan.escaux.com SIP/2.0
> Via: SIP/2.0/WSS k2km30gagse1.invalid;branch=z9hG4bK6030502
> To: <sip:identity at localhost>
> From: <sip:identity at localhost>;tag=31mhoq79ir
> CSeq: 3 REGISTER
> Call-ID: o5n3ln3aog19bdpt5bv6
> Contact: <sip:bhe74v8j at k2km30gagse1.invalid;transport=ws>;expires=600
> User-Agent: SIP.js/0.20.0
> {code}
> In the REGISTER response, this rewritten contact is sent back to SIP.js, triggering the following error, as SIP.js can't find back the contact it tried to register.
> {code}
> SIP/2.0 200 OK
> Via: SIP/2.0/WSS k2km30gagse1.invalid;rport=42956;received=172.16.123.123;branch=z9hG4bK4399238
> To: <sip:identity at localhost>;tag=z9hG4bK4399238
> From: <sip:identity at localhost>;tag=31mhoq79ir
> Call-ID: o5n3ln3aog19bdpt5bv6
> CSeq: 3 REGISTER
> Contact: <sip:bhe74v8j at 172.16.123.123:42956;transport=ws>;expires=599
> Server: Asterisk PBX 18.7.1
> {code}
> bq. No Contact header pointing to us, dropping response
> from https://github.com/onsip/SIP.js/blob/5555a9811f33df1f1461c9094a59b82307b25405/src/api/registerer.ts#L421
> It is worth noting that this doesn't happen with the default SIP.js config in which it is more lenient and only verifies the user part of the contact. However, when you specify a custom contact user in the its configuration, it does the full check user at ip:port as per the RFC. This probably explains why one doesn't encounter that bug right away when trying SIP.js + asterisk. See https://github.com/onsip/SIP.js/blob/5555a9811f33df1f1461c9094a59b82307b25405/src/api/registerer.ts#L401
> I tested a fix which is to save the original contact host in an x-ast-orig-host contact parameter, pretty much like it is done in res_pjsip_nat. It fixes my problem. If you think it is the right way to solve this I can provide a patch.



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list