Skip to content

fix: configurable CSP frame-ancestors for dashboard embedding#17

Merged
fabianbaier merged 1 commit intoyourclawfrom
fix/configurable-frame-ancestors
Mar 3, 2026
Merged

fix: configurable CSP frame-ancestors for dashboard embedding#17
fabianbaier merged 1 commit intoyourclawfrom
fix/configurable-frame-ancestors

Conversation

@fabianbaier
Copy link
Copy Markdown

Summary

  • Makes the CSP frame-ancestors directive configurable via OPENCLAW_FRAME_ANCESTORS env var
  • Defaults to 'none' (no embedding) when unset — preserves upstream security posture
  • Only omits X-Frame-Options: DENY when custom frame ancestors are configured (CSP takes precedence)
  • Includes a reapplicable patch file in yourclaw-patches/ for upstream sync

Why

The YourClaw dashboard embeds the gateway Control UI in an iframe ("Legacy Dashboard" tab). The hardcoded frame-ancestors 'none' + X-Frame-Options: DENY blocks this. The companion backend PR (yourclaw/backend#55) sets the env var in the systemd service.

Patch reapplication

The patch is stored at yourclaw-patches/frame-ancestors-configurable.patch and can be reapplied after upstream syncs:

git apply yourclaw-patches/frame-ancestors-configurable.patch

Test plan

  • Without env var → frame-ancestors 'none' + X-Frame-Options: DENY (unchanged behavior)
  • With OPENCLAW_FRAME_ANCESTORS="https://www.yourclaw.ai" → allows embedding from that origin
  • Unit tests pass (new test cases added for env var behavior)
  • Dashboard Legacy Dashboard tab loads gateway UI in iframe

🤖 Generated with Claude Code

The Control UI hardcodes `frame-ancestors 'none'` which blocks iframe
embedding. For managed deployments (like YourClaw) where the gateway
UI is embedded in a dashboard, this needs to be overridable.

Changes:
- control-ui-csp.ts: Read OPENCLAW_FRAME_ANCESTORS env var for the
  frame-ancestors directive, defaulting to 'none' when unset
- control-ui.ts: Only set X-Frame-Options: DENY when framing is fully
  blocked (CSP frame-ancestors takes precedence when configured)
- Added patch file in yourclaw-patches/ for reapplying after upstream sync

Usage:
  OPENCLAW_FRAME_ANCESTORS="https://example.com" openclaw gateway run

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fabianbaier fabianbaier requested a review from leopold16 March 3, 2026 07:50
@fabianbaier fabianbaier enabled auto-merge March 3, 2026 07:50
@fabianbaier fabianbaier merged commit 2ad70b0 into yourclaw Mar 3, 2026
@fabianbaier fabianbaier deleted the fix/configurable-frame-ancestors branch March 3, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants