BuilderIO / BuilderIO/builder

Security: Cross-origin code execution via unvalidated postMessage in builder-block (CWE-346)

Open
#4,501 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
8.8k
Forks
1.2k
Avg merge
1d 6h
Merged PRs (30d)
17

Description

Hi,

I found a cross-origin code execution issue in the Builder React SDK. Two pieces chain together.

**Missing origin validation on postMessage**

In `builder-block.component.tsx` around line 255, the `onWindowMessage` handler processes `builder.patchUpdates` messages without checking the sender's origin. The adjacent components do validate:

- `builder-component.component.tsx:532` — calls `Builder.isTrustedHostForEvent(event)` before processing
- `builder-content.component.tsx:126` — calls `Builder.isTrustedHostForEvent(event)` before processing
- `builder-block.component.tsx:255` — **does NOT validate**

An attacker who can send a postMessage to the window (via iframe or window.open) can patch the `bindings` property on any block. Bindings go through `stringToFunction` -> `new Function()` -> arbitrary JavaScript execution in the host page context.

**Editing mode via query parameter**

In `builder.class.ts:1166`, editing mode is toggled by checking for `builder.frameEditing=` in the query string. Any page can be iframed with that parameter to force editing mode, activating the unvalidated message listener.

**Chain:** attacker iframes victim page with `?builder.frameEditing=true`, sends crafted postMessage with malicious binding, gets code execution.

**Fix:** Add the same `Builder.isTrustedHostForEvent(event)` check to `builder-block.component.tsx:onWindowMessage` that the other components already have.

---

*Reported by ProScan AppSec (https://proscan.one)*

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.