Skip to content

TEL-892: Overriding the To user when req.ToUserOverride is present - #795

Open
genseric-ghiro wants to merge 1 commit into
mainfrom
genseric/ovewriting_user_when_ToUserOverride_is_present
Open

TEL-892: Overriding the To user when req.ToUserOverride is present#795
genseric-ghiro wants to merge 1 commit into
mainfrom
genseric/ovewriting_user_when_ToUserOverride_is_present

Conversation

@genseric-ghiro

@genseric-ghiro genseric-ghiro commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

@genseric-ghiro genseric-ghiro self-assigned this Aug 14, 2026
@genseric-ghiro
genseric-ghiro requested a review from a team as a code owner August 14, 2026 21:53

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment thread pkg/sip/client.go
Comment on lines +318 to +320
if userOverride != "" {
su.User = userOverride
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Replacement callee name is used without the checks applied to every other callee name

The callee name in the outgoing call's destination header is replaced (su.User = userOverride at pkg/sip/client.go:318-320) after all validation has already run, so a name containing address characters produces a malformed outgoing call header that the far end can reject.
Impact: Calls with such an override value can fail with a protocol error instead of a clear, early validation message.

Override bypasses the user validation done for every other path

Every other way of populating the user part is validated: the legacy path rejects users containing @ (pkg/sip/client.go:192-194) and the values path requires a non-empty user and rejects a host with a port (pkg/sip/client.go:245-258). The new override is applied directly to su.User with no checks, so a value like 333@other.com or one containing ;/> is serialized verbatim into the To header at pkg/sip/outbound.go:1158, producing an invalid header. Adding the same strings.Contains(userOverride, "@") guard (and rejecting other URI delimiters) would keep behavior consistent.

Suggested change
if userOverride != "" {
su.User = userOverride
}
if userOverride != "" {
if strings.ContainsAny(userOverride, "@;<>") {
return nil, fmt.Errorf("to user override should be a phone number or SIP user, not a full SIP URI")
}
su.User = userOverride
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread pkg/sip/client.go
Comment on lines +318 to +320
if userOverride != "" {
su.User = userOverride
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟨 Override value for the To header user is applied without any input validation

The new ToUserOverride value is written directly into the To header's user part (pkg/sip/client.go:318-320) without the sanity checks applied on all other code paths (the legacy path rejects users containing @ at pkg/sip/client.go:192-194). A value containing SIP URI delimiters (@, ;, <, >) is serialized verbatim into the outgoing INVITE To header (pkg/sip/outbound.go:1158), allowing header/URI manipulation of the emitted SIP message.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@nishadmusthafa nishadmusthafa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if there's no way to bypass the protocol validation, I think we should be good.

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.

2 participants