Skip to content

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

Open
Corina (corinagum) wants to merge 2 commits into
mainfrom
cg/entra-caller-app-validation
Open

Corina (corinagum) wants to merge 2 commits into
mainfrom
cg/entra-caller-app-validation

Conversation

@corinagum

Copy link
Copy Markdown
Collaborator

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 to appid for v1 tokens, and compared case-insensitively. Tokens from any other client app are rejected with 401. Bot Framework tokens are unaffected.

Changes

InboundActivityTokenValidator checks the caller app after Entra token validation succeeds.

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

Malformed azp values can incorrectly fall back to an allowed appid.

1 open finding
What changed in this PR

Restricts Entra-authenticated inbound activities to the Agent 365 platform.

Changes:

  • Validates azp, with appid fallback.
  • Adds caller-validation and Bot Framework regression tests.
File Description
inbound-activity-token-validator.ts Adds caller-app authorization.
inbound-activity-token-validator.spec.ts Tests accepted and rejected callers.

🧠 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/middleware/auth/inbound-activity-token-validator.ts Outdated

This branch has not been deployed

No deployments
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