Skip to content

fix: validate caller app on Entra inbound Agent ID tokens - #628

Merged
Corina (corinagum) merged 4 commits into
mainfrom
cg/entra-caller-app-validation
Oct 14, 2026
Merged

Corina (corinagum) merged 4 commits into
mainfrom
cg/entra-caller-app-validation

Conversation

@corinagum

@corinagum Corina (corinagum) commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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 from appid when azp is absent (v1 tokens), and compared case-insensitively. Tokens from any other client app are rejected with 401. Bot Framework tokens are unaffected.

Changes

TokenValidator checks the caller app after Entra token validation succeeds and raises jwt.InvalidTokenError on 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

  • Unit tests for allowed azp, allowed appid, case-insensitive match, azp precedence, disallowed azp, disallowed appid, missing caller claims, and Bot Framework tokens unaffected.
  • Verified locally end to end: an Entra token from a different app registration with the bot as audience returns 401, and the activity is not processed.

Copilot AI balanced review requested due to automatic review settings October 9, 2026 17:10

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.

🟡 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/appid against 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.

Comment thread packages/apps/src/microsoft_teams/apps/auth/token_validator.py Outdated
Corina (corinagum) and others added 3 commits October 9, 2026 10:44
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@corinagum
Corina (corinagum) merged commit 9d19ac8 into main Oct 14, 2026
8 checks passed
@corinagum
Corina (corinagum) deleted the cg/entra-caller-app-validation branch October 14, 2026 17:12
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.

3 participants