Skip to content

[Repo Assist] fix(security): stop leaking ex.Message in CanvasCapability and BrowserProxyCapability - #294

Merged
shanselman merged 2 commits into
masterfrom
repo-assist/fix-canvas-proxy-exception-message-leaks-2026-05-08-185ebfefe7f69c8e
May 10, 2026
Merged

[Repo Assist] fix(security): stop leaking ex.Message in CanvasCapability and BrowserProxyCapability#294
shanselman merged 2 commits into
masterfrom
repo-assist/fix-canvas-proxy-exception-message-leaks-2026-05-08-185ebfefe7f69c8e

Conversation

@github-actions

@github-actions github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

🤖 Repo Assist — automated AI assistant.

Summary

PR #291 fixed exception message leaks across SystemCapability, CameraCapability, ScreenCapability, and LocationCapability. This PR closes the remaining gaps in CanvasCapability and BrowserProxyCapability.

Root cause

Both capabilities echoed raw ex.Message values from external code (WebView2 handlers, OS APIs, network stack) directly into node response payloads. Any exception thrown by a handler — including messages that might contain internal paths, system state, or error detail — was forwarded to the gateway caller.

CanvasCapability — affected commands:

  • canvas.navigate — handler exception message leaked
  • canvas.eval — handler exception message leaked
  • canvas.snapshot — handler exception message leaked
  • canvas.a2ui.dump — handler exception message leaked
  • canvas.a2ui.caps — handler exception message leaked
  • canvas.a2ui.push (jsonlPath) — system exception message could propagate via InvalidOperationException wrapper

BrowserProxyCapability — affected exceptions:

  • HttpRequestException — connection error detail leaked
  • JsonException — JSON structure detail leaked
  • IOException — file read error (potential path disclosure) leaked
  • UnauthorizedAccessException — access denied detail leaked

Fix

All affected sites now log the exception internally (preserving full diagnostics) and return generic error codes. The jsonlPath path-validation path is unchanged — its exceptions originate from our own private method with controlled message strings.

BrowserProxyCapability exception handlers now follow the existing pattern from PR #291: log with Logger.Warn (message + ex.Message for internal diagnostics), return sanitized error string.

Test Status

  • dotnet test OpenClaw.Shared.Tests1405 passed / 20 skipped / 4 pre-existing failures (same 4 as baseline: ExecApprovalV2NormalizationTests × 3 and McpHttpServerTests × 1, all pre-existing on Linux)
  • dotnet test OpenClaw.Tray.Tests465 passed / 1 skipped
  • build.ps1 — requires Windows; infrastructure limitation on Linux runner

Handler-throws tests updated to assert on generic error codes and verify raw exception messages are absent from responses.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a

…rProxyCapability

CanvasCapability leaked raw exception messages (from WebView2/OS handlers)
in navigate, eval, snapshot, a2ui.dump, and a2ui.caps error responses.
BrowserProxyCapability leaked HttpRequestException, JsonException, IOException,
and UnauthorizedAccessException messages through its error responses.

All now log exceptions internally and return generic error codes. The
jsonlPath path-validation path is preserved as-is since its exceptions
are thrown by our own private method with controlled message strings.

Tests updated: handler-throws tests now assert on the generic error
code and verify the raw exception message is absent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@shanselman
shanselman marked this pull request as ready for review May 10, 2026 22:06
@shanselman

Copy link
Copy Markdown
Collaborator

Validated locally on Windows after latest changes: \.\build.ps1, \dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore, and \dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore\ all passed. Note: build.ps1 still reports the existing Windows 10 SDK detection warning, but the build completed successfully.

@shanselman
shanselman merged commit 990395c into master May 10, 2026
11 checks passed
@shanselman
shanselman deleted the repo-assist/fix-canvas-proxy-exception-message-leaks-2026-05-08-185ebfefe7f69c8e branch May 10, 2026 22:16
github-actions Bot added a commit that referenced this pull request May 13, 2026
PR #294 sanitised the main canvas command handlers (navigate, eval,
snapshot, a2ui) but left one ex.Message leak at the jsonlPath read
path: Error($"Failed to read jsonlPath: {ex.Message}").  The
exception detail was already written to the local logger on the line
above, so diagnostic fidelity is preserved; only the gateway-bound
error string is stripped.

Closes: the residual canvas capability gap identified post-#294.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant