Skip to content

network: align URL trust and IDN domain policies - #336960

Draft
Dmitriy Vasyura (dmitrivMS) wants to merge 6 commits into
mainfrom
fix/url-destination-trust
Draft

Dmitriy Vasyura (dmitrivMS) wants to merge 6 commits into
mainfrom
fix/url-destination-trust

Conversation

@dmitrivMS

@dmitrivMS Dmitriy Vasyura (dmitrivMS) commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

URL trust and approval matching

  • Resolve effective HTTP(S) authority/path boundaries and dot segments consistently across trusted domains, chat URL approvals, explicit prompt references, and web-page fetching.
  • Preserve the actual serialized destination, query/fragment contents, hostname case behavior, and existing userinfo/authorityless trust restrictions.
  • Compare escaped resource and glob paths consistently, so specific exclusions cannot fall through to broader approvals. Preserve literal escaped data when generated approval patterns are saved and parsed again.
  • Canonicalize equivalent Unicode/Punycode literal hostname labels while preserving wildcard, scheme, port, and path semantics.

The shared matcher keeps two clearly named stages: normalizeURLAuthorityAndPath establishes effective URL structure before path normalization; normalizeAuthorityForMatching canonicalizes literal DNS labels for matching. These are composed rather than treated as interchangeable helpers.

Network and sandbox policies

  • Canonicalize Unicode wildcard domain suffixes for agent network allow/deny rules.
  • Canonicalize sandbox allow/deny policies and URL hosts used by command preflight checks.
  • Log a warning and use a deny-all network policy for invalid sandbox domain entries, keeping tool registration and offline sandboxed commands available.

Performance and validation

  • Replace the recursive eager URL-by-pattern memo table with iterative deduplicated states. Preserve matching semantics while avoiding Unicode-path allocation spikes and long-path stack overflow.
  • Normalize configured approval patterns as well as request URLs. Preserve effective userinfo guards, unreserved-path equivalence, escaped-pattern round trips, and Unicode GitHub case folding. HTTP(S) drive-like paths keep their case; file/untitled/remote drive behavior is unchanged.
  • 591 tests pass, with 3 pre-existing skips; targeted typecheck, hygiene, and normal commit hooks pass. 559,585 old/new matcher comparisons preserve existing boolean semantics.
  • Real-renderer comparison including all follow-up fixes: one 128-character Unicode path approval 44.5 ms -> 0.5 ms; ten same-host long-path rules 500.9 ms -> 2 ms.
  • Code OSS 1.139.0 Dev, Windows x64: expanded core 48/48 steps (45 workflow cases, one setup check, two diagnostic-only GitHub checks); native sandbox 6/6 steps. The core run observed 28 actual loopback extractions; 11 declined fetches and two network-policy blocks produced zero extraction requests. Both native MXC marker commands ran successfully.
  • The 1,024-character Unicode UI flow stayed below the 500 ms renderer-gap budget (95.8 ms maximum). Source/output hashes and the exact validated patch were verified before committing as 85224b354e3.

Evidence is retained locally with screenshots, raw uncaptioned videos, Playwright traces, request ledgers, and runtime provenance. The two GitHub-specific checks are live-service diagnostics, not real-GitHub fetch tests. Windows native validation covers overall outbound policy, not per-host sandbox enforcement; Linux/macOS native execution is not claimed.

Normalize wildcard suffixes with the URL-aware authority helper before validating the pattern. Add matching, policy, and fetch-tool regression coverage while preserving existing domain handling.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Canonicalize sandbox domain policies and preflight URL hosts, rejecting patterns that cannot be normalized. Match equivalent Unicode and Punycode literal host labels in URL trust and approval rules while preserving existing glob semantics.

Partial Unicode wildcard labels remain outside this change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Normalize authority separators and resolved paths consistently across trusted domains, URL approval rules, and web-page fetching. Preserve hostname case semantics, escaped path data, and actual request destinations, with regression coverage for approvals, exclusions, and declined tool calls.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 20, 2026 22:33

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.

Copilot review overview

🔵 Needs a closer look

Security-sensitive URL normalization spans trust, enterprise filtering, confirmation, and network execution boundaries.

Review effort: Balanced
Findings: None

What changed in this PR

Aligns URL trust, approval, prompt-reference, and fetch behavior with effective HTTP(S) destinations.

Changes:

  • Normalizes authority separators and path traversal consistently.
  • Preserves escaped paths across approval-pattern round trips.
  • Adds regression coverage for malformed authorities, encoded paths, and declined fetches.
File Description
src/​vs/​platform/​url/​common/​urlGlob.ts Normalizes HTTP authorities and paths for matching.
src/​vs/​platform/​url/​common/​trustedDomains.ts Applies effective URL normalization to trust checks.
src/​vs/​workbench/​contrib/​chat/​common/​tools/​builtinTools/​chatUrlFetchingPatterns.ts Aligns approvals and generated patterns with normalized destinations.
src/​vs/​workbench/​contrib/​chat/​electron-browser/​builtInTools/​fetchPageTool.ts Uses normalized destinations for policy, confirmation, and fetching.
src/​vs/​platform/​url/​test/​common/​urlGlob.test.ts Tests backslash authority matching.
src/​vs/​platform/​url/​test/​common/​urlPathNormalization.test.ts Covers effective path and authority normalization.
src/​vs/​workbench/​contrib/​chat/​test/​common/​tools/​builtinTools/​chatUrlFetchingPatterns.test.ts Tests approval patterns for malformed authorities.
src/​vs/​workbench/​contrib/​chat/​test/​common/​tools/​builtinTools/​chatUrlFetchingPaths.test.ts Tests encoded paths, exclusions, and traversal.
src/​vs/​workbench/​contrib/​chat/​test/​electron-browser/​tools/​builtinTools/​fetchPageTool.test.ts Verifies consistent fetch destinations.
src/​vs/​workbench/​contrib/​chat/​test/​electron-browser/​tools/​builtinTools/​fetchPageToolPaths.test.ts Exercises complete confirmation and fetch orchestration.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​tools/​languageModelToolsService.test.ts Verifies declined URLs cause no fetch effects.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Merge the IDN network-filter and sandbox changes with effective URL destination normalization. Preserve both normalization stages and their regression coverage, and add combined IDN plus effective-path approval and exclusion tests.

Consolidates #336944 into #336960.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dmitrivMS Dmitriy Vasyura (dmitrivMS) changed the title url: align trust and approvals with effective HTTP destinations network: align URL trust and IDN domain policies Sep 20, 2026
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added security chat fetch-tool Issues concerning the fetch internal tool and web extracting service agent-sandbox labels Sep 20, 2026
Keep shell-tool registration and offline sandboxed commands available when domain patterns cannot be normalized. Log a warning and use a deny-all policy instead of throwing, with regression coverage for both lists and recovery after settings are corrected.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

Copilot review overview

🟡 Changes recommended

Dot-segment denial patterns can still miss and fall through to broader URL approvals.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)

Comment thread src/vs/platform/url/common/urlGlob.ts
Comment thread src/vs/platform/url/common/urlGlob.ts Outdated
Comment thread src/vs/platform/url/common/urlGlob.ts
Comment thread src/vs/platform/url/common/urlGlob.ts Outdated
Comment thread src/vs/platform/url/common/trustedDomains.ts Outdated
Comment thread src/vs/platform/url/common/trustedDomains.ts
Comment thread src/vs/platform/url/common/urlGlob.ts
Replace the eager recursive matcher with iterative deduplicated states to avoid Unicode path allocation spikes and stack growth. Normalize configured patterns consistently, preserve effective authority and path semantics, and retain HTTP path case without changing non-HTTP drive normalization.

Add regression coverage for the PR feedback and verify real Code OSS trust, approval, fetch, and sandbox workflows.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: c0f6c8cd Current: 2c0e7a73

Changed (1)

sessions/connectionDiagnostics/connectionDiagnostics/MobileDismissedDiscovery/Light
Before After
before after

1 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-sandbox chat fetch-tool Issues concerning the fetch internal tool and web extracting service network Network related issues security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants