Skip to content

Validate serviceurl claim matches activity ServiceUrl#545

Merged
rido-min merged 5 commits into
mainfrom
fix/SSRF-serviceUrl
Jun 4, 2026
Merged

Validate serviceurl claim matches activity ServiceUrl#545
rido-min merged 5 commits into
mainfrom
fix/SSRF-serviceUrl

Conversation

@rido-min

@rido-min rido-min commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Add validation to ensure the "serviceurl" claim in user claims matches the activity's ServiceUrl (case-insensitive) in BotApplication. Throw InvalidDataException on mismatch. Add unit tests covering matching, case-insensitivity, mismatches, and absence of the claim.

Add validation to ensure the "serviceurl" claim in user claims matches the activity's ServiceUrl (case-insensitive) in BotApplication. Throw InvalidDataException on mismatch. Add unit tests covering matching, case-insensitivity, mismatches, and absence of the claim.
@rido-min
rido-min requested review from corinagum and singhk97 June 2, 2026 00:40
@rido-min rido-min added the CORE label Jun 3, 2026
@rido-min
rido-min marked this pull request as ready for review June 3, 2026 01:18
Copilot AI review requested due to automatic review settings June 3, 2026 01:18

Copilot AI 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.

Pull request overview

Adds a security validation in BotApplication.ProcessAsync to ensure the authenticated user’s serviceurl claim matches the incoming activity’s ServiceUrl (case-insensitive), and expands unit test coverage to verify expected behavior for matching, case-only differences, mismatches, and missing claim scenarios.

Changes:

  • Add serviceurl-vs-activity ServiceUrl validation to BotApplication.ProcessAsync, throwing InvalidDataException on mismatch.
  • Add unit tests covering match, case-insensitive match, mismatch, and missing-claim behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
core/src/Microsoft.Teams.Core/BotApplication.cs Adds serviceurl claim validation in the incoming activity processing path.
core/test/Microsoft.Teams.Core.UnitTests/BotApplicationTests.cs Adds unit tests to validate the new claim/ServiceUrl matching behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/src/Microsoft.Teams.Core/BotApplication.cs Outdated
Record activity types and start spans for each turn, tagging spans with activity details (type, ID, conversation ID, channel ID, bot ID, service URL) to improve observability and diagnostics.

@heyitsaamir heyitsaamir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It'd be good to double check if this logic works in various settings:

  1. 1:1
  2. Group Chats
  3. Channels
  4. Threads

Comment thread core/src/Microsoft.Teams.Core/BotApplication.cs Outdated
Comment thread core/src/Microsoft.Teams.Core/BotApplication.cs Outdated
Comment thread core/src/Microsoft.Teams.Core/BotApplication.cs Outdated
Comment thread core/src/Microsoft.Teams.Core/BotApplication.cs Outdated
Changed service URL validation to use StringComparison.Ordinal
for a case-sensitive match instead of OrdinalIgnoreCase. This
affects how the service URL in the activity is compared to the
service URL claim.
Copilot AI review requested due to automatic review settings June 4, 2026 03:18

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread core/src/Microsoft.Teams.Core/BotApplication.cs Outdated
Comment thread core/test/Microsoft.Teams.Core.UnitTests/BotApplicationTests.cs
Comment thread core/test/Microsoft.Teams.Core.UnitTests/BotApplicationTests.cs
Add logging for ServiceUrl mismatches using LogServiceUrlClaimMismatch. Update the exception message for clarity. Refactor test to set Conversation property inline during activity initialization.
@rido-min

rido-min commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

It'd be good to double check if this logic works in various settings:

  1. 1:1
  2. Group Chats
  3. Channels
  4. Threads

how so? this is only about claims and serviceUrls, it should not affect any other fields in the payload (and yes, tested without any issue)

@rido-min
rido-min added this pull request to the merge queue Jun 4, 2026
Merged via the queue into main with commit b1f71b8 Jun 4, 2026
10 checks passed
@rido-min
rido-min deleted the fix/SSRF-serviceUrl branch June 4, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants