Skip to content

Python: narrow unscoped Copilot URL session approvals - #10149

Merged
Jose Alvarez (jpalvarezl) merged 1 commit into
mainfrom
fix-copilot-url-session-scope
Nov 6, 2026
Merged

Jose Alvarez (jpalvarezl) merged 1 commit into
mainfrom
fix-copilot-url-session-scope

Conversation

@jpalvarezl

Copy link
Copy Markdown
Member

Motivation & Context

A bare PermissionDecisionApproveForSession() does not specify a URL permission scope. Deriving that scope from only the requested hostname can discard meaningful URL boundaries such as the scheme and explicit port, allowing the resulting session approval to cover more than the triggering request.

This change keeps the existing crash avoidance for under-specified decisions while ensuring URL permissions fail closed to a single request unless the caller provides an explicit domain= scope.

Description & Review Guide

  • What are the major changes? Bare session approvals for URL permission requests now become PermissionDecisionApproveOnce() instead of a framework-derived hostname approval. Explicit caller-supplied domain= values remain unchanged. The regression matrix covers protocol, default and non-default ports, IPv4, IPv6, IDNA, trailing dots, userinfo, parser ambiguity, malformed URLs, and explicit domains. The package README documents the behavior.
  • What is the impact of these changes? Callers returning a bare session decision for a URL prompt receive one-time approval for that request. Callers that intentionally want session-scoped URL access must provide an explicit domain=. Structured tool session approvals and public API signatures are unchanged.
  • What do you want reviewers to focus on? Confirm that the fail-closed URL behavior preserves explicit-domain pass-through and the original under-specified-decision crash avoidance.

Related Issue

N/A - maintainer-directed correction to URL permission scope normalization; no public issue or competing pull request.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Implementation, regression tests, documentation, and PR description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after a language prefix such as "Python:" or ".NET:") — a workflow keeps the label and the title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 13:03
@jpalvarezl
Jose Alvarez (jpalvarezl) marked this pull request as ready for review November 6, 2026 13:03
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Nov 6, 2026

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.

🟢 Approval recommended

No active review issues block the change that limits unscoped URL approvals to a single request.

No open issues 🎉

What changed in this PR

This PR narrows unscoped URL permission approvals in the Python GitHub Copilot integration, preventing inferred hostname scopes from granting broader session access than intended.

Changes:

  • Converts bare URL session approvals to one-time approvals while preserving explicit domain= scopes and structured tool approvals.
  • Expands regression coverage for URL variants and explicit-domain pass-through.
  • Documents the fallback behavior and removes URL-domain inference code.
File Description
python/​packages/​github_copilot/​tests/​test_github_copilot_agent.py Tests one-time URL approvals and preservation of explicit domains.
python/​packages/​github_copilot/​README.md Explains URL approval fallback and explicit session scopes.
python/​packages/​github_copilot/​agent_framework_github_copilot/​_agent.py Removes hostname inference and narrows unscoped URL approvals to one request.

Review effort: Balanced

@github-code-quality

Copy link
Copy Markdown
Contributor

Code coverage overview

Languages: Python

Python / code-coverage/python

main 9db7efb fix-copilot-url-sess... 9ff75e1 +/-
92% 92% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@github-actions github-actions Bot 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.

MAF Automated Review — Iteration 1

Result: No findings
Scope: full PR (1 commit(s)): 9ff75e163c93
Model: gpt-5.6-sol

Overview

The change fails closed by converting bare URL session approvals to one-time approvals while preserving explicit domains and structured non-URL session scopes. The wrapper remains applied across new and resumed sessions, and the regression matrix covers URL parsing boundaries, malformed input, explicit scopes, and decision pass-through. No publishable Critical, High, or Medium issue was established.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

@jpalvarezl
Jose Alvarez (jpalvarezl) added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit c04fecd Nov 6, 2026
62 of 66 checks passed
@jpalvarezl
Jose Alvarez (jpalvarezl) deleted the fix-copilot-url-session-scope branch November 6, 2026 13:23

This branch was successfully deployed

1 active deployment
github-app-auth — 9ff75e16 Deployed Nov 6, 2026 by jpalvarezl via team_check #8898
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants