6.0.2 to 6.1.1 Migration issue: malformed From header no longer reachable in routing script
Hello, I am writing regarding a behaviour change between Kamailio 6.0.2 and 6.1.1 that is causing one of our system tests to fail. The test sends intentionally malformed SIP INVITE requests and expects a 400 response. The failing cases involve malformed From headers (e.g. an empty From). After reviewing the changelog and tracing the code, we believe the change was introduced in commit cf1c796 (cherry-picked into 6.0.4), which reworks From header parsing in get_hdr_field() to use the shared parse_to_body() function. As a result, a malformed From now causes parse_headers() to return an error earlier in receive.c, before the message reaches the routing script. Previously, the From header parsing failure was caught deep enough in execution for our sanity_check() call in the request route to detect and handle it — sending back a 400 as RFC 3261 implies. Now, the failure happens before the routing script is reached. We have attempted to intercept it in event_route[core:pre-routing] and event_route[core:receive-parse-error], but to no avail. All of our other malformed type messages (e.g. a bad Expires value or invalid RURI) work as intended. Our questions are: Is there any hook, event, or flag we could use to detect and respond to this condition before the message is dropped? If no config-level workaround exists, are there any other alternatives? Thank you in advance for your time. Best regards, Matteo Cazzola
Hello, Just an idea, maybe you can use the sanity module instead, which also should return a 400 in generic header parser errors. Cheers, Henning
-----Original Message----- From: m.cazzola--- via sr-users <sr-users@lists.kamailio.org> Sent: Mittwoch, 11. März 2026 14:02 To: sr-users@lists.kamailio.org Cc: m.cazzola@zaleos.net Subject: [SR-Users] 6.0.2 to 6.1.1 Migration issue: malformed From header no longer reachable in routing script
Hello,
I am writing regarding a behaviour change between Kamailio 6.0.2 and 6.1.1 that is causing one of our system tests to fail.
The test sends intentionally malformed SIP INVITE requests and expects a 400 response. The failing cases involve malformed From headers (e.g. an empty From).
After reviewing the changelog and tracing the code, we believe the change was introduced in commit cf1c796 (cherry-picked into 6.0.4), which reworks From header parsing in get_hdr_field() to use the shared parse_to_body() function.
As a result, a malformed From now causes parse_headers() to return an error earlier in receive.c, before the message reaches the routing script.
Previously, the From header parsing failure was caught deep enough in execution for our sanity_check() call in the request route to detect and handle it — sending back a 400 as RFC 3261 implies.
Now, the failure happens before the routing script is reached. We have attempted to intercept it in event_route[core:pre-routing] and event_route[core:receive-parse-error], but to no avail. All of our other malformed type messages (e.g. a bad Expires value or invalid RURI) work as intended.
Our questions are: Is there any hook, event, or flag we could use to detect and respond to this condition before the message is dropped? If no config-level workaround exists, are there any other alternatives?
Thank you in advance for your time.
Best regards,
Matteo Cazzola __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr- users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Thank you for your response. Actually, we are using sanity module. We call sanity_check() in our CFG which makes the other types of malformed messages correctly return 400. However, it seems that after upgrading versions, this specific case (malformed From header) is not even reaching the CFG logic layer. I don't know if there is some sort of built in flag (like a STRICT_SIP_PARSINNG) that can allow us to return to the previous behavior? Here are some examples of the malformed from headers we are testing: - from_hdr = "\"Mr.J.User <sip:j.user@example.com>" - from_hdr = "\"Mr.J.User\" <sip:j@user@example.com>" Again, thank you in advanced for your time. Matteo Cazzola.
Hello, On 13.03.26 12:10, m.cazzola--- via sr-users wrote:
Thank you for your response.
Actually, we are using sanity module. We call sanity_check() in our CFG which makes the other types of malformed messages correctly return 400.
However, it seems that after upgrading versions, this specific case (malformed From header) is not even reaching the CFG logic layer. I don't know if there is some sort of built in flag (like a STRICT_SIP_PARSINNG) that can allow us to return to the previous behavior?
Here are some examples of the malformed from headers we are testing:
- from_hdr = "\"Mr.J.User <sip:j.user@example.com>" - from_hdr = "\"Mr.J.User\" <sip:j@user@example.com>"
Again, thank you in advanced for your time.
From header being mandatory and needed pretty much everywhere on common sip routing (authentication, authorization, transactions, dialogs, ...), its parsing was made implicit, as it was done for To header very long time ago. It was decided to do it for 6.1 series for the safety of the new feature that allows applying changes based on a core param before creating the transaction. However, failing to parse those headers done before config execution (first via, to, from, ...) should trigger event_route[core:receive-parse-error] -- is it not executed? Cheers, Daniel -- Daniel-Constantin Mierla (@ asipto.com) twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy, Training and Development Services -- asipto.com Kamailio World Conference, May 7-8, 2026 - Berlin, Germany -- kamailioworld.com
We have tried but to no avail. Is there something special that we need to do so that we can catch the trigger event other than using the normal event_route syntax? Matteo Cazzola.
Hello everyone, I hope you are all doing well, and congratulations on what I'm sure was another successful Kamailio World Conference earlier this month! I wanted to kindly follow up on this thread regarding the malformed From header behavior in Kamailio 6.1.x. To answer Daniel's last question more explicitly: we did implement event_route[core:receive-parse-error] in our configuration exactly per the standard syntax, but it does not appear to be triggered for this specific core parsing failure before the message is dropped. Because of this, we aren't able to manually send the 400 Reply from the routing script. We would love to get your thoughts on whether this might be a edge-case bug in how the new From parsing interacts with core:receive-parse-error, or if there is another underlying mechanism we should look into to catch this condition. Thank you again for your time and continued support! Best regards, Matteo Cazzola
Hello, can you try with git master branch, I pushed a commit to cover some cases when parsing From is not done by parse_msg() on-receive. After sending a reply, use drop() in the event route to stop processing that message further. If all ok, it will be backported. Cheers, Daniel On 18.05.26 08:43, m.cazzola--- via sr-users wrote:
Hello everyone,
I hope you are all doing well, and congratulations on what I'm sure was another successful Kamailio World Conference earlier this month!
I wanted to kindly follow up on this thread regarding the malformed From header behavior in Kamailio 6.1.x.
To answer Daniel's last question more explicitly: we did implement event_route[core:receive-parse-error] in our configuration exactly per the standard syntax, but it does not appear to be triggered for this specific core parsing failure before the message is dropped. Because of this, we aren't able to manually send the 400 Reply from the routing script.
We would love to get your thoughts on whether this might be a edge-case bug in how the new From parsing interacts with core:receive-parse-error, or if there is another underlying mechanism we should look into to catch this condition.
Thank you again for your time and continued support!
Best regards, Matteo Cazzola __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
-- Daniel-Constantin Mierla (@ asipto.com) twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy, Training and Development Services -- asipto.com Kamailio World Conference, May 7-8, 2026 - Berlin, Germany -- kamailioworld.com
participants (3)
-
Daniel-Constantin Mierla -
Henning Westerholt -
m.cazzola@zaleos.net