Uh oh!
There was an error while loading. Please reload this page.
.NET: Add allow listing for WebBrowsingTool - #5605
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the Harness Step01 “WebBrowsingTool” sample by introducing an explicit access policy object (WebBrowsingToolOptions) and enforcing host/network allow rules before fetching content.
Changes:
- Added
WebBrowsingToolOptionsto configure host allow listing and public/private network access controls. - Updated
WebBrowsingToolto require options and to validate access (allow list + DNS-based public/private classification) before downloading. - Updated the sample
Program.csto constructWebBrowsingToolwith a default policy.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| dotnet/samples/02-agents/Harness/Harness_Step01_Research/WebBrowsingToolOptions.cs | Introduces configuration surface for URL access control (allow list + network toggles). |
| dotnet/samples/02-agents/Harness/Harness_Step01_Research/WebBrowsingTool.cs | Enforces the configured access policy before issuing HTTP requests. |
| dotnet/samples/02-agents/Harness/Harness_Step01_Research/Program.cs | Updates sample wiring to pass policy options into the tool. |
Comments suppressed due to low confidence (1)
dotnet/samples/02-agents/Harness/Harness_Step01_Research/WebBrowsingTool.cs:73
- The access check resolves DNS once, but HttpClient will resolve the hostname again when establishing the connection. That means this policy can be bypassed via DNS rebinding (host initially resolves to a public IP, then to a private IP at connect time). If the intent is to demonstrate SSRF-safe allow listing, consider enforcing the resolved IP at connect time (e.g., custom SocketsHttpHandler/ConnectCallback) or explicitly document this as a best-effort check.
try
{
string html = await s_httpClient.GetStringAsync(parsedUri, cancellationToken);
return HtmlToMarkdownConverter.Convert(html);
}
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Motivation and Context
#5271
While the WebBrowsingTool is a sample, it's important to demonstrate best practices in samples.
Description
Contribution Checklist