Skip to content

stir_shaken: strip RFC 4904 user parameters from telephone numbers#3906

Open
NormB wants to merge 1 commit into
OpenSIPS:masterfrom
NormB:fix/stir-shaken-tn-params
Open

stir_shaken: strip RFC 4904 user parameters from telephone numbers#3906
NormB wants to merge 1 commit into
OpenSIPS:masterfrom
NormB:fix/stir-shaken-tn-params

Conversation

@NormB
Copy link
Copy Markdown
Member

@NormB NormB commented Jun 4, 2026

Problem

get_orig_tn_from_msg() and get_dest_tn_from_msg() take the originating and destination telephone numbers straight from parse_uri()'s .user field. When a From/To/P-Asserted-Identity URI carries RFC 4904 parameters in the userinfo part, e.g.

sip:+33123456789;tgrp=grp1;trunk-context=example.com@host

parse_uri() resolves the user;params@host ambiguity by folding the entire userinfo into .user (the still_at_user backtrack path in parser/parse_uri.c), and .user_param is cleared. The trailing parameters therefore stay glued to the number, the E.164 check in check_passport_phonenum() fails, and stir_shaken_verify() errors out unless orig_tn/dest_tn are pre-cleaned from script.

Fix

Trim the extracted number at the first ;, dropping any embedded user parameters before validation. The two call sites share a small helper (trim_tn_params()) using the existing q_memchr() core util.

Notes

Closes #3904

get_orig_tn_from_msg() and get_dest_tn_from_msg() take the originating
and destination telephone numbers directly from parse_uri()'s .user
field. When a From/To/PAI URI carries RFC 4904 parameters in the
userinfo part (e.g. "+33123456789;tgrp=...;trunk-context=..."),
parse_uri() folds the whole userinfo into .user, so the trailing
parameters end up glued to the number and the E.164 check in
check_passport_phonenum() fails -- forcing the script to pre-clean
orig_tn/dest_tn before calling stir_shaken_verify().

Trim the number at the first ';' so any embedded parameters are dropped
before validation.

Based on the patch proposed by @StellaTeam in OpenSIPS#3904.

Closes OpenSIPS#3904
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.

[FEATURE] stir_shaken improve tn parsing from SIP messages

1 participant