Security hardening: token validation and service URL improvements#515
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Security hardening across the auth pipeline and developer tooling by tightening validation rules and preventing unsafe defaults.
Changes:
- Added allowlist-based validation for inbound
serviceUrlbefore it’s used in outbound calls (with customization hooks). - Hardened JWT validation (exact scope matching; enforce tenantId when restricting issuers).
- Fixed MCP tool-result type guard and blocked DevTools from running in production; added unit tests.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/dev/src/plugin.ts | Throws early to prevent DevTools plugin use in production (NODE_ENV=production). |
| packages/dev/src/plugin.spec.ts | Adds unit tests for the production guard behavior. |
| packages/apps/src/middleware/jwt-validation-middleware.ts | Updates ServiceTokenValidator instantiation for new constructor parameter. |
| packages/apps/src/middleware/auth/service-token-validator.ts | Introduces serviceUrl allowlist validation and exposes isAllowedServiceUrl. |
| packages/apps/src/middleware/auth/service-token-validator.spec.ts | Adds extensive unit coverage for service URL allowlist behavior and new constructor signature. |
| packages/apps/src/middleware/auth/jwt-validator.ts | Enforces tenantId when allowedTenantIds is used; switches to exact scope matching. |
| packages/apps/src/middleware/auth/jwt-validator.spec.ts | Adds tests for new tenant/scope validation behavior. |
| packages/apps/src/http/http-server.ts | Threads additionalAllowedDomains and validates serviceUrl even when auth is skipped. |
| packages/apps/src/app.ts | Exposes additionalAllowedDomains at the App options level. |
| external/mcp/src/plugin.ts | Fixes isCallToolResult guard to correctly accept valid results. |
| external/mcp/src/plugin.spec.ts | Adds unit tests for isCallToolResult guard. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
heyitsaamir
reviewed
Apr 20, 2026
heyitsaamir
previously approved these changes
Apr 20, 2026
heyitsaamir
approved these changes
Apr 21, 2026
corinagum
added a commit
to microsoft/teams-sdk
that referenced
this pull request
Apr 22, 2026
## Summary Documentation for security hardening changes shipping in the SDK PRs: - microsoft/teams.ts#515 - microsoft/teams.py#370 - microsoft/teams.net#418 ### New page: Service URL Validation `src/pages/templates/essentials/service-url-validation.mdx` + per-language include files Documents the service URL domain allowlist: - Allowed hostnames by cloud environment preset - How to add custom domains via `additionalAllowedDomains` - Sovereign cloud FQDNs that require manual configuration - How to disable validation with wildcard `*` - Note on proactive messaging ## Test plan - [x] Docusaurus builds without errors - [x] New page renders correctly for all 3 languages - [x] Admonitions render correctly
corinagum
added a commit
that referenced
this pull request
Apr 27, 2026
Follow-up to the allowlist feature (shipped via #515). No runtime behavior change for correct callers. Adds hardening informed by review feedback on the sibling Python PR (microsoft/teams.py#404): 1. **Docstring clarity.** `App.additionalAllowedDomains`, `HttpServerOptions`, and `ServiceTokenValidator` constructor all document that entries must be bare hostnames matched exactly (case-insensitive); wildcard patterns like `*.example.com`, URL suffixes, and full URLs are NOT supported. `['*']` is the sole wildcard, used as a disable-validation sentinel. 2. **Defensive copy.** `HttpServer` and `ServiceTokenValidator` no longer store the caller's array by reference. A post-construction mutation of the caller's array would previously have changed validator behavior at runtime; now it is isolated. 3. **Tests** covering the class of bug Python shipped in #404: plumbing from `HttpServerOptions` through `HttpServer.initialize()` into the `ServiceTokenValidator` constructor. --------- Co-authored-by: Copilot <[email protected]>
5 tasks
corinagum
added a commit
that referenced
this pull request
Apr 28, 2026
## Summary Reverting the serviceUrl allowlist defense-in-depth feature before public release. Open design questions on the work item (default sovereign cloud domains, narrowing of `*.botframework.com`, applying to proactive `ConversationReference`s, consultation with APX) should be resolved before this becomes part of the public API surface. This feature has not shipped in any release. Removing the public `additionalAllowedDomains` option is a breaking change for anyone building from `main`, which is not ideal but acceptable since no release has been cut. Reverting now buys time to discuss without breaking customers later. ## Removed - `isAllowedServiceUrl` helper - `additionalAllowedDomains` option on `AppOptions` and `HttpServerOptions`, plus plumbing through `App` -> `HttpServer` -> `ServiceTokenValidator` - `CloudEnvironment.allowedServiceUrls` field, per-cloud entries (Public/USGov/USGovDoD/China), and `withOverrides` parameter - Service URL hostname check in the skip-auth path of `HttpServer.authorize` - All allowlist tests (`additionalAllowedDomains plumbing`, cloud preset acceptance/rejection, wildcard, defensive copy, etc.) ## Preserved (other security work bundled into PR #515) - Scope validation (exact set membership) - `isCallToolResult` fix in `external/mcp` ## Preserved (sovereign cloud, separate work) `CloudEnvironment` presets, `withOverrides`, `cloudFromName`, `cloud` option on `App`, and the `cloud` parameter on `ServiceTokenValidator` are unchanged. ## Test plan - [x] `npm run build` clean (full workspace) - [x] `npm run lint` clean - [x] `npx jest` in `packages/apps`: 19 suites, 245 tests pass - [x] `tsc --noEmit` clean for `packages/apps` and `packages/api` - [x] Smoke test: `examples/echo` starts and binds to port
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
Security hardening for token validation, service URL handling, and development tooling.
serviceUrlagainst allowed hostnames from the configured cloud environment preset. Configurable viaadditionalAllowedDomainsfor non-standard channels or sovereign clouds without presets.isCallToolResultreturning incorrect results for valid tool responses.Test plan
isCallToolResult(valid results, null, primitives, unknown types)NODE_ENV=production