From 2bf9bd38eb8685a170d201fa253868968f40d125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Wed, 6 Apr 2011 09:49:23 +0300 Subject: main/kamailio: fix a from header rewriting bug --- ...ac-fix-from-to-restore-for-small-original.patch | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 main/kamailio/0001-modules_k-uac-fix-from-to-restore-for-small-original.patch (limited to 'main/kamailio/0001-modules_k-uac-fix-from-to-restore-for-small-original.patch') diff --git a/main/kamailio/0001-modules_k-uac-fix-from-to-restore-for-small-original.patch b/main/kamailio/0001-modules_k-uac-fix-from-to-restore-for-small-original.patch new file mode 100644 index 000000000..1b997719b --- /dev/null +++ b/main/kamailio/0001-modules_k-uac-fix-from-to-restore-for-small-original.patch @@ -0,0 +1,64 @@ +From e22eb2886c73634020c2747d6247df6bcb978850 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= +Date: Wed, 6 Apr 2011 09:33:10 +0300 +Subject: [PATCH] modules_k/uac: fix from/to restore for small original URI +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Seems that the URI length check is superfluous and fails under +certain conditions. It does not make sense for the URI to have +zero bytes, so just use the first seen zero byte as end marker. + +I have a reproducible test case where the restore inserts URI +with multiple zero-bytes to wire. This happens if the original +URI is smaller than the one we rewrote it to using uac_replace_from. + +Signed-off-by: Timo Teräs +--- + modules_k/uac/from.c | 14 ++++++++------ + 1 files changed, 8 insertions(+), 6 deletions(-) + +However, I think the delta encoding used for the RR attribute +is flawed. Hostile remote server could rewrite the RR attribute +and/or From/To headers in a way to forge it to something it was not +in the first place. Additionally the delta-encoded RR attribute +breaks if the From/To header isn't exact copy of what we sent. + +Would it not make more sense to just send the real original +header (possibly encrypted) but with a checksum? We could then +verify if someone had clobbered the RR attribute and ignore it. +And we could always restore the original URI even if the URI +we are swapping was modified unexpectedly. + +diff --git a/modules_k/uac/from.c b/modules_k/uac/from.c +index 4657e11..50822b6 100644 +--- a/modules_k/uac/from.c ++++ b/modules_k/uac/from.c +@@ -463,15 +463,17 @@ int restore_from( struct sip_msg *msg, int *is_from ) + LM_ERR("new URI shorter than old URI\n"); + goto failed; + } +- for( i=0 ; i