Hello,
To be accurate: I am going to implement this change and would like to know, if the PR would be accepted by the community.
BR
Theo
Von: sr-dev <sr-dev-bounces@lists.kamailio.org>
Im Auftrag von Scherney Theodor
Gesendet: Mittwoch, 22. September 2021 09:24
An: 'sr-dev@lists.kamailio.org' <sr-dev@lists.kamailio.org>
Cc: Onic Roman <Roman.Onic@kontron.com>; Valentin Christoph <Christoph.Valentin@kontron.com>
Betreff: [sr-dev] Syntax error
Hello,
I have tested following scenario:
Alice "calls" Bob. Call is established.
At the end of the call, Bob disconnects (hangs up) first and generates a BYE message.
If there is a syntax error in FROM Header of BYE message, a 400 “Bad From header” is responded by the Proxy.
If there is a syntax error in TO Header of BYE message, the message is discarded.
According RFC 3261 this is not correct.
Is it okay, to implement the same logic for TO Header as done for FROM Header?
RFC 3261:
16.2 Stateful Proxy
……….
For all new requests, including any with unknown methods, an element intending to proxy the request MUST:
1. Validate the request (Section 16.3)
2. Preprocess routing information (Section 16.4)
3. Determine target(s) for the request (Section 16.5)
+--------------------+
| | +---+
| | | C |
| | | T |
| | +---+
+---+ | Proxy | +---+ CT = Client Transaction
| S | | "Higher" Layer | | C |
| T | | | | T | ST = Server Transaction
+---+ | | +---+
| | +---+
| | | C |
| | | T |
| | +---+
+--------------------+
Figure 3: Stateful Proxy Model
4. Forward the request to each target (Section 16.6)
5. Process all responses (Section 16.7)
16.3 Request Validation
Before an element can proxy a request, it MUST verify the message’s validity.
A valid message must pass the following checks:
1. Reasonable Syntax
2. URI scheme
3. Max-Forwards
4. (Optional) Loop Detection
5. Proxy-Require
6. Proxy-Authorization
If any of these checks fail, the element MUST behave as a user agent server (see Section 8.2) and respond with an error code.
LOGs:
BYE with syntax error in FROM header:
Sep 21 16:44:51 vict2-ims3 /usr/sbin/kamailio[12723]: [logSDID@20306 resource="core"] ERROR: <core> [core/parser/parse_addr_spec.c:555]: parse_to_param(): unexpected end of header, status 20: [;transport=UDP;tag=b3af-8e5a-1e36-79340f18;#015]
.
Sep 21 16:44:51 vict2-ims3 /usr/sbin/kamailio[12723]: [logSDID@20306 resource="core"] ERROR: <core> [core/parser/parse_addr_spec.c:881]: parse_addr_spec(): invalid To - unexpected end of header in state 11
Sep 21 16:44:51 vict2-ims3 /usr/sbin/kamailio[12723]: [logSDID@20306 resource="core"] ERROR: <core> [core/parser/parse_from.c:75]: parse_from_header(): bad From header [sip:catt180@vict-ims.net;transport=UDP;tag=b3af-8e5a-1e36-79340f18;]
Sep 21 16:44:51 vict2-ims3 /usr/sbin/kamailio[12723]: [logSDID@20306 resource="pv"] ERROR: pv [pv_core.c:468]: pv_get_from_attr(): cannot parse From header
Sep 21 16:44:51 vict2-ims3 /usr/sbin/kamailio[12723]: [logSDID@20306 resource="xlog"] INFO: <script>: route BYE (<null> (193.154.113.40:5065) to
sip:catt181@vict-ims.net, 1632235417904catt180, )
Sep 21 16:44:51 vict2-ims3 /usr/sbin/kamailio[12723]: [logSDID@20306 resource="xlog"] INFO: <script>: BYE (BYE
sip:catt181@193.154.113.40:5065;transport=UDP;rinstance=317-catt181 SIP/2.0#015#012From:
sip:catt180@vict-ims.net;transport=UDP;tag=b3af-8e5a-1e36-79340f18;#015#012To:
sip:catt181@vict-ims.net;transport=UDP;tag=9d7b-d1c6-c06b-7a1dbec7#015#012Call-ID: 1632235417904catt180#015#012CSeq:
2 BYE#015#012Contact: sip:catt180@193.154.113.40:5065;transport=UDP;rinstance=317-catt180#015#012Content-Length: 0#015#012Max-Forwards:
70#015#012Route: sip:mo@172.29.21.60;r2=on;lr;ftag=b3af-8e5a-1e36-79340f18;rm=8;did=8ed.6e12#015#012Route:
sip:mo@pcscf-1.vict-ims.net:5060;r2=on;lr;ftag=b3af-8e5a-1e36-79340f18;rm=8;did=8ed.6e12#015#012Route:
sip:mo@vict-ims.net;lr;ftag=b3af-8e5a-1e36-79340f18;did=8ed.e7b1#015#012Route:
sip:mt@vict-ims.net;lr;ftag=b3af-8e5a-1e36-79340f18;did=8ed.e7b1#015#012Route:
sip:mt@pcscf-1.vict-ims.net;r2=on;lr;ftag=b3af-8e5a-1e36-79340f18;rm=7;did=8ed.7e12#015#012Route:
sip:mt@172.29.21.60:5060;r2=on;lr;ftag=b3af-8e5a-1e36-79340f18;rm=7;did=8ed.7e12#015#012Via: SIP/2.0/UDP 193.154.113.40:5065;branch=z9hG4bKf7057b36-0#015#012#015#012)
Sep 21 16:44:51 vict2-ims3 /usr/sbin/kamailio[12723]: [logSDID@20306 resource="core"] ERROR: <core> [core/parser/parse_addr_spec.c:555]: parse_to_param(): unexpected end of header, status 20: [;transport=UDP;tag=b3af-8e5a-1e36-79340f18;#015]
.
Sep 21 16:44:51 vict2-ims3 /usr/sbin/kamailio[12723]: [logSDID@20306 resource="core"] ERROR: <core> [core/parser/parse_addr_spec.c:881]: parse_addr_spec(): invalid To - unexpected end of header in state 11
Sep 21 16:44:51 vict2-ims3 /usr/sbin/kamailio[12723]: [logSDID@20306 resource="sanity"] WARNING: sanity [sanity.c:776]: check_parse_uris(): failed to parse From header [sip:catt180@vict-ims.net;transport=UDP;tag=b3af-8e5a-1e36-79340f18;]
Sep 21 16:44:51 vict2-ims3 /usr/sbin/kamailio[12723]: [logSDID@20306 resource="xlog"] INFO: <script>: t_relay_send_reply_sl - BYE (SIP/2.0
400 Bad From header#015#012From: sip:catt180@vict-ims.net;transport=UDP;tag=b3af-8e5a-1e36-79340f18;#015#012To:
sip:catt181@vict-ims.net;transport=UDP;tag=9d7b-d1c6-c06b-7a1dbec7#015#012Call-ID: 1632235417904catt180#015#012CSeq:
2 BYE#015#012Via: SIP/2.0/UDP 193.154.113.40:5065;branch=z9hG4bKf7057b36-0#015#012Server: Kamailio P-CSCF#015#012Content-Length: 0#015#012#015#012)
BYE with syntax error in TO header:
Sep 21 16:41:07 vict2-ims3 /usr/sbin/kamailio[12733]: [logSDID@20306 resource="core"] ERROR: <core> [core/parser/parse_addr_spec.c:555]: parse_to_param(): unexpected end of header, status 20: [;transport=UDP;tag=1ba4-ff0c-82af-415174d1;#015#012]
.
Sep 21 16:41:07 vict2-ims3 /usr/sbin/kamailio[12733]: [logSDID@20306 resource="core"] ERROR: <core> [core/parser/parse_addr_spec.c:881]: parse_addr_spec(): invalid To - unexpected end of header in state 13
Sep 21 16:41:07 vict2-ims3 /usr/sbin/kamailio[12733]: [logSDID@20306 resource="core"] ERROR: <core> [core/parser/msg_parser.c:167]: get_hdr_field(): bad to header
Sep 21 16:41:07 vict2-ims3 /usr/sbin/kamailio[12733]: [logSDID@20306 resource="core"] ERROR: <core> [core/parser/msg_parser.c:337]: parse_headers(): bad header field [To:
sip:catt181@vict]
Sep 21 16:41:07 vict2-ims3 /usr/sbin/kamailio[12733]: [logSDID@20306 resource="core"] ERROR: <core> [core/parser/msg_parser.c:687]: parse_msg(): ERROR: parse_msg: message=<BYE
sip:catt181@193.154.113.40:5065;transport=UDP;rinstance=317-catt181 SIP/2.0#015#012From:
sip:catt180@vict-ims.net;transport=UDP;tag=b7fb-dd8f-30fd-2a93fc86#015#012To:
sip:catt181@vict-ims.net;transport=UDP;tag=1ba4-ff0c-82af-415174d1;#015#012Call-ID: 1632235194213catt180#015#012CSeq:
2 BYE#015#012Contact: sip:catt180@193.154.113.40:5065;transport=UDP;rinstance=317-catt180#015#012Content-Length: 0#015#012Max-Forwards:
70#015#012Route: sip:mo@172.29.21.60;r2=on;lr;ftag=b7fb-dd8f-30fd-2a93fc86;rm=8;did=281.c9a1#015#012Route:
sip:mo@pcscf-1.vict-ims.net:5060;r2=on;lr;ftag=b7fb-dd8f-30fd-2a93fc86;rm=8;did=281.c9a1#015#012Route:
sip:mo@vict-ims.net;lr;ftag=b7fb-dd8f-30fd-2a93fc86;did=281.b871#015#012Route:
sip:mt@vict-ims.net;lr;ftag=b7fb-dd8f-30fd-2a93fc86;did=281.b871#015#012Route:
sip:mt@pcscf-1.vict-ims.net;r2=on;lr;ftag=b7fb-dd8f-30fd-2a93fc86;rm=7;did=281.d9a1#015#012Route:
sip:mt@172.29.21.60:5060;r2=on;lr;ftag=b7fb-dd8f-30fd-2a93fc86;rm=7;did=281.d9a1#015#012Via: SIP/2.0/UDP 193.154.113.40:5065;branch=z9hG4bK0850615e-0#015#012#015#012>
Sep 21 16:41:07 vict2-ims3 /usr/sbin/kamailio[12733]: [logSDID@20306 resource="core"] ERROR: <core> [core/receive.c:199]: receive_msg(): core parsing of SIP message failed (193.154.113.40:5065/1)
BR
Theo