Skip to content

[BUG] topology_hiding: in-dialog requests carry the wrong Contact username #4513

Backlog

Description

@Lt-Flash

OpenSIPS version you are running

version: opensips 4.1.0-dev (x86_64/linux)
flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, HP_MALLOC, F_PARALLEL_MALLOC, DBG_MALLOC, CC_O0, FAST_LOCK-ADAPTIVE_WAIT
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535
poll method support: poll, epoll, sigio_rt, select.
main.c compiled with cc 14

Built from master at 98ee38b.

Describe the bug

With dialog-based topology hiding and the U flag with two usernames, in-dialog requests don't carry the username meant for the side that receives them. The initial INVITE and its 200 are correct.

There are two causes, both in topo_hiding_logic.c:

  1. th_params_dup() copies both usernames into one block, but it points the callee username at the start of the block. That is where the caller username is, so the callee username overwrites it.
  2. topo_dlg_onroute() reads that copy as a single str, so every in-dialog request gets the caller username, whichever way it goes. Replies already choose by the destination leg (dlg_th_onreply()), but requests don't.

To Reproduce

  1. Use this route on a proxy with dialog and topology_hiding loaded, and topology_hiding_match() for in-dialog requests:
    create_dialog();
    topology_hiding("U", "/alice/bobbylonger");
    t_relay();
    
  2. Send an INVITE from the caller. The callee answers 200 and gets the ACK.
  3. Send a re-INVITE from the caller, then one from the callee.
  4. Look at the Contact of each request as the other side receives it.

Expected behavior

Request Received by Expected Actual
initial INVITE callee sip:bobbylonger@ sip:bobbylonger@
200 to the INVITE caller sip:alice@ sip:alice@
re-INVITE from the caller callee sip:bobbylonger@ sip:bobby@
re-INVITE from the callee caller sip:alice@ sip:bobby@

bobby is the callee username cut to the length of the caller username.

Relevant System Logs

No errors are logged.

OS/environment information

  • Operating System: Debian 13 (trixie)
  • OpenSIPS installation: git (source)
  • other relevant information: found while running clang-tidy on the module; reproduced with a small SIP test script

Additional context

Dialogs restored from the database or from a cluster peer (th_loaded_callback) go through the same two functions, so they are affected too.

Fix: #4512

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions