Skip to content

match foundry project endpoint host by suffix not substring#47412

Open
alhudz wants to merge 1 commit into
Azure:mainfrom
alhudz:ghcopilot-resource-url-host-suffix
Open

match foundry project endpoint host by suffix not substring#47412
alhudz wants to merge 1 commit into
Azure:mainfrom
alhudz:ghcopilot-resource-url-host-suffix

Conversation

@alhudz

@alhudz alhudz commented Jun 9, 2026

Copy link
Copy Markdown

Description

_derive_resource_url_from_project_endpoint derives the Foundry resource URL that later receives a Managed Identity token (cognitiveservices.azure.com scope) 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 via str.replace, so a look-alike host that merely contains .services.ai.azure.com passes and yields victim.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:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copilot AI review requested due to automatic review settings June 9, 2026 11:22
@github-actions github-actions Bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Hosted Agents sdk/agentserver/* labels Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @alhudz! We will review the pull request and get back to you soon.

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.

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_endpoint to 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}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Hosted Agents sdk/agentserver/*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants