Skip to content

[deep-review] C8: app.settings.set over MCP accepts arbitrary keys without validation #348

Closed

Description

@codemonkeychris

Summary

AppCapability exposes app.settings.set as a node capability. Reachable from both the gateway WS and the local MCP HTTP server, the command accepts arbitrary key/value pairs and forwards them to a delegate wired in App.xaml.cs. There is no allowlist of settings that may be remotely mutated. A local MCP caller with the bearer token can flip GatewayUrl, EnableMcpServer, UseLegacyWebChat, EnableNodeMode, or any other field on SettingsData.

Where

  • Capability surface: src/OpenClaw.Shared/Capabilities/AppCapability.cs (look for settings.set handler delegate)
  • Wiring: src/OpenClaw.Tray.WinUI/App.xaml.cs (WireAppCapabilityHandlers)
  • The safeSettings allowlist set used elsewhere (e.g., gated UI editor): exists but not enforced on this code path.

Why it matters

Flipping GatewayUrl to an attacker-controlled URL with the user's saved bootstrap token completes a remote takeover. Flipping EnableMcpServer from off to on (or rotating the token via a misuse of the same surface) creates persistence.

This is the same pattern as the system.execApprovals.set defense-in-depth gap (see C7) — the capability's caller is implicitly trusted because the MCP token gates it, but the trust boundary is fragile.

Proposed fix

Introduce an allowlist of settings that may be mutated via app.settings.set. Reject anything outside the list with Error("Setting not remotely writable: {key}"). The existing safeSettings set used in the UI is a reasonable starting point.

Settings to keep writable: cosmetic toggles, notification preferences, capability enables that already have UI confirmations.

Settings to deny: GatewayUrl, BootstrapToken, Token, EnableMcpServer, EnableNodeMode, ScreenRecordingConsentGiven, anything in dpapi: prefix paths.

Add tests covering each rejected key.

Severity

High — defense-in-depth gap; combined with token compromise, enables takeover.

Activity

  1. linked a pull request that will close this issueRestrict remote app settings writes #395on May 14, 2026
  2. shanselman commented on May 18, 2026

    @shanselman
    Collaborator

    Closing this one-off deep-review issue as consolidated, not necessarily fixed. The useful signal is preserved in #372: MCP settings validation remains useful, but should be handled as one MCP hardening slice. We will take these one at a time from #372 after verifying against current master instead of keeping the issue list flooded.

  3. locked as resolved and limited conversation to collaborators on May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions