Repository navigation
fix: validate caller app on Entra inbound Agent ID tokens - #695
Open
Corina (corinagum) wants to merge 2 commits into
Open
Corina (corinagum) wants to merge 2 commits into
Corina (corinagum) wants to merge 2 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The authentication behavior and tests are sound; only a minor documentation correction remains.
1 open finding
What changed in this PR
Restricts Entra-authenticated bot activities to tokens requested by Agent 365 while leaving Bot Framework and non-activity endpoints unaffected.
Changes:
- Validates
azp/appidcaller claims. - Rejects marked activity requests with HTTP 401.
- Adds logging and unit coverage.
| File | Description |
|---|---|
src/Microsoft.Teams.Core/Hosting/JwtExtensions.cs |
Identifies unauthorized Entra callers. |
src/Microsoft.Teams.Core/BotApplication.cs |
Rejects marked requests before deserialization. |
src/Microsoft.Teams.Core/Log.cs |
Adds rejection logging. |
test/Microsoft.Teams.Core.UnitTests/Hosting/JwtExtensionsTests.cs |
Tests caller-claim validation. |
test/Microsoft.Teams.Core.UnitTests/BotApplicationTests.cs |
Tests early 401 behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Inbound activities authenticated with an Entra (Agent ID) token are now accepted only when the token was requested by the Agent 365 platform. The caller app is read from
azp, falling back toappidfor v1 tokens, and compared case-insensitively. Tokens from any other client app are rejected with 401. Bot Framework tokens are unaffected.Changes
Authentication marks Entra tokens whose caller app is not the Agent 365 platform, and
BotApplication.ProcessAsyncreturns 401 for marked requests before reading the body. The check is scoped to the activity endpoint so tab and function endpoints protected byAddBotAuthorization()keep accepting user tokens.Behavior change
Entra-authenticated activities sent from any app other than the Agent 365 platform (for example, a custom client or another bot calling the bot's endpoint directly with an Entra token) now receive 401.
Testing
azp, allowedappid, case-insensitive match,azpprecedence, disallowedazp, disallowedappid, missing caller claims, and Bot Framework tokens unaffected.