Tighten AdditionalAllowedDomains API contract#450
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the AdditionalAllowedDomains allowlist plumbing in Microsoft.Teams.Apps by clarifying the API contract and preventing post-construction mutation of caller-provided domain lists from affecting service URL validation behavior.
Changes:
- Clarifies
AppOptions.AdditionalAllowedDomainsdocumentation (hostnames only;["*"]disables validation). - Makes
Appdefensively materialize/copyAdditionalAllowedDomainsat construction time. - Adds unit tests to guard against regressions involving mutable/lazy enumerables.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Tests/Microsoft.Teams.Apps.Tests/AppTests.cs | Adds tests asserting AdditionalAllowedDomains is materialized/defensively copied. |
| Libraries/Microsoft.Teams.Apps/AppOptions.cs | Updates XML docs for AdditionalAllowedDomains contract and sentinel behavior. |
| Libraries/Microsoft.Teams.Apps/App.cs | Changes internal storage to a materialized list via ToList() to prevent caller-side mutations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3 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 - `ServiceUrlValidator` class and `ServiceUrlValidatorTests` - `AppOptions.AdditionalAllowedDomains`, `App._additionalAllowedDomains` field, related warn log, and the `IsAllowed` check in `App.Process` - `TeamsSettings.AdditionalAllowedDomains` and its `Apply()` assignment - `CloudEnvironment.AllowedServiceUrls` property, per-cloud entries (Public/USGov/USGovDoD/China), constructor parameter, and `WithOverrides` parameter ## Preserved (other security work bundled into PR #418) - DevTools production guard (`DevToolsPlugin`, `TeamsValidationSettings`) ## Preserved (sovereign cloud, separate work) `CloudEnvironment` presets, `WithOverrides`, `FromName`, `AppOptions.Cloud`, and the per-cloud `Bots.Token.ActiveBotScope` / `ActiveGraphScope` / `TokenServiceUrl` wiring in `App` are unchanged. ## Note on related open PRs PR #450 (`Tighten AdditionalAllowedDomains API contract`) and PR #413 (sovereign cloud next/core, which carries this plumbing) are intentionally left open for separate decisions. ## Test plan - [x] `dotnet build` clean (0 errors, 5 unrelated pre-existing warnings) - [x] `dotnet test` net10.0 passes (net8.0 testhost aborted on local machine due to missing SDK, environmental, not code) - [x] Smoke test: `Samples/Samples.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.
Follow-up to the allowlist feature (shipped via #418). No runtime behavior change for correct callers. Adds hardening informed by review feedback on the sibling Python PR (microsoft/teams.py#404):
AppOptions.AdditionalAllowedDomainsXML doc now documents 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.Appno longer stores the caller'sIEnumerable<string>by reference. A post-construction mutation of the collection would previously have changed validator behavior at runtime; now it is isolated.