Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sip/transp: allow requests w/o Max-Forwards header #1217

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

cspiel1
Copy link
Collaborator

@cspiel1 cspiel1 commented Nov 22, 2024

A customer reports problems with their SIP proxy that misses the Max-Forwards header for SIP MESSAGE. Our devices reject these SIP requests.

In RFC 3261 couldn't find anything about what a UAC should do with a SIP request without a Max-Forwards header.

Found this about SIP Proxy:

16 Proxy Behavior

16.3 Request Validation

3. Max-Forwards check

If the request does not contain a Max-Forwards header field, this
check is passed.

Which is the opposite of the current behavior.

@juha-h @alfredh @sreimers Do you agree with removing the check?

@maximilianfridrich
Copy link
Contributor

maximilianfridrich commented Nov 25, 2024

Technically, every SIP request MUST contain a Max-Forwards header:

   A UAC MUST insert a Max-Forwards header field into each request it
   originates with a value that SHOULD be 70.

https://www.rfc-editor.org/rfc/rfc3261#section-8.1.1.6

and section 8.1.1:

   A valid SIP request formulated by a UAC MUST, at a minimum, contain
   the following header fields: To, From, CSeq, Call-ID, Max-Forwards,
   and Via; all of these header fields are mandatory in all SIP
   requests.  These six header fields are the fundamental building
   blocks of a SIP message, as they jointly provide for most of the
   critical message routing services including the addressing of
   messages, the routing of responses, limiting message propagation,
   ordering of messages, and the unique identification of transactions.
   These header fields are in addition to the mandatory request line,
   which contains the method, Request-URI, and SIP version.

But I guess you're right. It does not specifically state anywhere what a UAS should do with a request without a Max-Forwards header. Logically, it probably wouldn't do much damage to still accept these requests especially considering section 16.3 which you cited where proxies allow these requests too (and which contradicts section 8.1).

@sreimers
Copy link
Member

Also not sure about this, but the proxy is clearly violating the specs:

A customer reports problems with their SIP proxy that misses the Max-Forwards header for SIP MESSAGE

https://datatracker.ietf.org/doc/html/rfc3261#section-16.6

  3. Max-Forwards

     If the copy contains a Max-Forwards header field, the proxy
     MUST decrement its value by one (1).

     If the copy does not contain a Max-Forwards header field, the
     proxy MUST add one with a field value, which SHOULD be 70.

     Some existing UAs will not provide a Max-Forwards header field
     in a request.

@sreimers
Copy link
Member

Looks like pjsip ignores a missing Max-Forwards header too:

        /* Perform basic header checking. */
        if (rdata->msg_info.cid == NULL ||
            rdata->msg_info.cid->id.slen == 0 || 
            rdata->msg_info.from == NULL || 
            rdata->msg_info.to == NULL || 
            rdata->msg_info.via == NULL || 
            rdata->msg_info.cseq == NULL) 
        {
            mgr->on_rx_msg(mgr->endpt, PJSIP_EMISSINGHDR, rdata);

@cspiel1
Copy link
Collaborator Author

cspiel1 commented Nov 25, 2024

My understanding is now: A proxy should ignore a missing Max-Forwards header. A proxy should add a Max-Forwards header, if it is missing in the SIP request.

The logical consequence for me is that the UAC should not reject a SIP request with a missing Max-Forwards header.

@sreimers sreimers changed the title sip: allow requests w/o Max-Forwards header sip/transp: allow requests w/o Max-Forwards header Nov 25, 2024
@sreimers sreimers merged commit a07bc3e into baresip:main Nov 25, 2024
38 checks passed
@cspiel1 cspiel1 deleted the sip_transp_maxfwd_check branch November 25, 2024 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants