Skip to content

Dotnet: DevUI improve local request checks - #9575

Open
westey (westey-m) wants to merge 3 commits into
microsoft:mainfrom
westey-m:dotnet-devui-local
Open

westey (westey-m) wants to merge 3 commits into
microsoft:mainfrom
westey-m:dotnet-devui-local

Conversation

@westey-m

@westey-m westey (westey-m) commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation & Context

Improve DevUI's local request handling so its UI and standard Responses and Conversations endpoints consistently accept expected local traffic while rejecting requests that do not match the local application origin.

Description & Review Guide

  • What are the major changes? Adds shared local request validation for .NET DevUI, applies it automatically to the standard backend routes, and adds equivalent checks to the Aspire DevUI aggregator. Also updates related documentation, tests, and the basic DevUI sample registration.
  • What is the impact of these changes? Normal browser and command-line use on loopback continues to work. Applications using AllowRemoteAccess retain control of their own request policy.
  • What do you want reviewers to focus on? The local Host and browser-origin checks, middleware route scope, and preservation of existing remote-access and bearer-token behavior.

Related Issue

Fixes #9570

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: Copilot assisted with implementation, tests, documentation, and this 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 any language prefix) - a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings October 21, 2026 11:19
@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 .NET Usage: [Issues, PRs], Target: .Net labels Oct 21, 2026
@github-actions github-actions Bot changed the title DevUI improve local request checks .NET: DevUI improve local request checks Oct 21, 2026
@github-actions github-actions Bot changed the title .NET: DevUI improve local request checks Python: DevUI improve local request checks Oct 21, 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.

🟡 Changes recommended

A path-base protection bypass and compatibility failures involving aggregator origins and CORS preflights remain unresolved.

3 open issues
What changed in this PR

Strengthens .NET DevUI local-request protection and updates Python security guidance.

Changes:

  • Shares request validation across DevUI and standard backend routes.
  • Adds Aspire aggregator checks and access-control tests.
  • Updates security documentation and sample registration.
File Description
python/​packages/​devui/​README.md Warns about unauthenticated loopback access.
python/​packages/​devui/​dev.md Adds local-testing security guidance.
python/​packages/​devui/​AGENTS.md Documents unauthenticated-mode risks.
dotnet/​tests/​Microsoft.Agents.AI.DevUI.UnitTests/​DevUIAccessControlTests.cs Tests backend access controls.
dotnet/​tests/​Aspire.Hosting.AgentFramework.DevUI.UnitTests/​DevUIAggregatorHostedServiceTests.cs Tests aggregator request validation.
dotnet/​src/​Microsoft.Agents.AI.DevUI/​ServiceCollectionsExtensions.cs Registers shared validation and middleware.
dotnet/​src/​Microsoft.Agents.AI.DevUI/​README.md Explains access checks and scope.
dotnet/​src/​Microsoft.Agents.AI.DevUI/​DevUIRequestValidator.cs Centralizes local-origin and token checks.
dotnet/​src/​Microsoft.Agents.AI.DevUI/​DevUIOptions.cs Clarifies security option behavior.
dotnet/​src/​Microsoft.Agents.AI.DevUI/​DevUIAuthFilter.cs Delegates to shared validation.
dotnet/​src/​Microsoft.Agents.AI.DevUI/​DevUIAccessControlStartupFilter.cs Automatically installs access middleware.
dotnet/​src/​Microsoft.Agents.AI.DevUI/​DevUIAccessControlMiddleware.cs Guards standard backend paths.
dotnet/​src/​Aspire.Hosting.AgentFramework.DevUI/​README.md Documents aggregator protections.
dotnet/​src/​Aspire.Hosting.AgentFramework.DevUI/​DevUIAggregatorHostedService.cs Adds Host and browser-origin validation.
dotnet/​samples/​02-agents/​DevUI/​README.md Adds service registration guidance.
dotnet/​samples/​02-agents/​DevUI/​DevUI_Step01_BasicUsage/​README.md Registers DevUI before app construction.
dotnet/​samples/​02-agents/​DevUI/​DevUI_Step01_BasicUsage/​Program.cs Adds development-only DevUI registration.

Review effort: Balanced

Comment thread dotnet/src/Microsoft.Agents.AI.DevUI/DevUIAccessControlMiddleware.cs Outdated
Comment thread dotnet/src/Microsoft.Agents.AI.DevUI/DevUIRequestValidator.cs
Comment thread dotnet/src/Microsoft.Agents.AI.DevUI/DevUIRequestValidator.cs
@westey-m westey (westey-m) changed the title Python: DevUI improve local request checks Dotnet: DevUI improve local request checks Oct 21, 2026

@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: Findings reported
Scope: full PR (1 commit(s)): b146898b748e
Model: gpt-5.6-sol

Overview

The PR centralizes DevUI request validation, adds strict Host/origin checks, preserves token enforcement under remote-access mode, and covers the main direct-route and aggregator cases with focused tests. However, the automatic middleware runs before application path and proxy normalization, leaving two concrete ways to bypass the new controls. Applying the DevUI bearer token globally to separately authenticated OpenAI endpoints also creates an incompatible dual-bearer requirement.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
3 verified findings remained after source verification (2 high, 1 medium) across 3 files. Details are attached to the affected lines below.

Affected areas: dotnet/src/Microsoft.Agents.AI.DevUI/DevUIAccessControlMiddleware.cs, dotnet/src/Microsoft.Agents.AI.DevUI/DevUIAccessControlStartupFilter.cs, dotnet/src/Microsoft.Agents.AI.DevUI/ServiceCollectionsExtensions.cs

Comment thread dotnet/src/Microsoft.Agents.AI.DevUI/DevUIAccessControlMiddleware.cs Outdated
@westey-m
westey (westey-m) added this pull request to the merge queue Oct 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 21, 2026
@westey-m
westey (westey-m) added this pull request to the merge queue Oct 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 21, 2026

This branch was successfully deployed

1 active deployment
github-app-auth — dff934b2 Deployed Oct 21, 2026 by westey-m via add_label #25869
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 .NET Usage: [Issues, PRs], Target: .Net python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Bug]: DevUI_Step01_BasicUsage sample never calls AddDevUI(), so app.MapDevUI() throws on startup

3 participants