Repository navigation
fix: validate caller app on Entra inbound Agent ID tokens - #628
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The current fallback can incorrectly accept v2 tokens with an invalid or missing authoritative azp claim.
1 open finding
What changed in this PR
Adds caller-app validation for inbound Entra Agent ID tokens while preserving Bot Framework authentication.
Changes:
- Validates
azp/appidagainst the Agent 365 platform app ID. - Adds coverage for accepted, rejected, precedence, and Bot Framework cases.
| File | Description |
|---|---|
packages/apps/src/microsoft_teams/apps/auth/token_validator.py |
Adds Entra caller-app validation. |
packages/apps/tests/test_token_validator.py |
Tests caller-app validation behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Mehak Bindra (MehakBindra)
approved these changes
Oct 14, 2026
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, or fromappidwhenazpis absent (v1 tokens), and compared case-insensitively. Tokens from any other client app are rejected with 401. Bot Framework tokens are unaffected.Changes
TokenValidatorchecks the caller app after Entra token validation succeeds and raisesjwt.InvalidTokenErroron mismatch.A disallowed caller app is logged at warning level, matching TS and .NET.
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.