This lab shows how weak or missing event.origin validation in LWC message handlers can let attacker-controlled frames inject payloads, abuse trust assumptions, and trigger unauthorized application behavior.
Executive Summary
LWC components that use window.addEventListener('message', ...) often process cross-window messages for iframe integrations. If the handler trusts message data without strict origin validation, the component can become a cross-origin command or data injection surface.
In managed package deployments, this risk is amplified because subscriber orgs may embed package components into varied page contexts, increasing untrusted frame interaction opportunities.
Salesforce Attack Surface
LWC message listeners: handlers accepting postMessage events from iframes or parent windows
Weak origin checks: wildcard trust, suffix matching, or partial string checks on event.origin
Untrusted iframe sources: dynamic or user-influenced iframe URLs
Command-style payloads: client-side operations executed directly from message content
Bridge components: VF-LWC or Aura-LWC integrations forwarding unvalidated messages