match foundry project endpoint host by suffix not substring#47412
Open
alhudz wants to merge 1 commit into
Open
match foundry project endpoint host by suffix not substring#47412alhudz wants to merge 1 commit into
alhudz wants to merge 1 commit into
Conversation
Contributor
|
Thank you for your contribution @alhudz! We will review the pull request and get back to you soon. |
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Tightens validation when deriving the Azure AI Foundry resource URL from a project endpoint by preventing substring-based matches that could accept look‑alike/attacker-controlled hosts.
Changes:
- Update
_derive_resource_url_from_project_endpointto match hostnames by suffix (endswith) rather than substring. - Add a unit test covering rejection of look-alike hosts.
- Document the security-related bug fix in the changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/agentserver/azure-ai-agentserver-ghcopilot/tests/unit_tests/test_replat_features.py | Adds regression coverage for look‑alike host rejection. |
| sdk/agentserver/azure-ai-agentserver-ghcopilot/azure/ai/agentserver/githubcopilot/_copilot_adapter.py | Fixes hostname matching logic to avoid substring matches. |
| sdk/agentserver/azure-ai-agentserver-ghcopilot/CHANGELOG.md | Notes the behavioral/security fix for the upcoming release. |
Comment on lines
+131
to
+133
| if hostname.endswith(project_pat): | ||
| resource_host = hostname[: -len(project_pat)] + resource_pat | ||
| return f"https://{resource_host}" |
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.
Description
_derive_resource_url_from_project_endpointderives the Foundry resource URL that later receives a Managed Identity token (cognitiveservices.azure.comscope) as the bearer token, so the host it returns is where that credential is sent.Repro: point the project endpoint host at
victim.services.ai.azure.com.attacker.example.Cause: the host is matched with
project_pat in hostname(substring) and rewritten viastr.replace, so a look-alike host that merely contains.services.ai.azure.compasses and yieldsvictim.cognitiveservices.azure.com.attacker.example, an attacker-controlled domain.Fix: require the host to end with the expected suffix and rewrite only that trailing suffix, so the derived resource host stays under the intended domain. Legitimate endpoints derive the same URL as before.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines