Summary
The locize client SDK previously registered a window.postMessage handler that dispatched powerful internal actions based solely on attacker-controlled message data, without validating the browser-enforced event.origin.
Any web page that could embed or be embedded by a locize-enabled site could send crafted messages to invoke internal handlers, potentially leading to content manipulation or script injection in the victim context.
Affected context
This vulnerability affects web applications that integrate the locize client SDK and run in a browser environment where:
- The page can be embedded in or can embed other pages (iframes, popups, window.open, or parent/child frames).
- The SDK's postMessage-based editor or integration features are enabled.
- Cross-window communication is relied on for editor, key management, or initialization flows.
In such setups, the message handler trusts a sender flag inside event.data rather than the browser-verified origin, making it possible for external frames or windows under an attacker's control to interact with internal locize handlers.
Exploit preconditions
- Attack surface: Browser postMessage API between the locize-enabled page and any frame or window it embeds or is embedded within.
- Required access: Ability to control a web page that:
- Embeds a locize-enabled page as an iframe, or
- Is embedded by a locize-enabled page, or
- Opens a locize-enabled page via window.open, or
- Acts as a parent or ancestor frame.
- Trigger point: Sending a crafted window.postMessage() to the target window, with event.data shaped to satisfy the internal dispatch condition (e.g., data.sender set to the expected value).
- Why exploitation is possible: The message handler gates access on an attacker-controlled field within event.data (
sender === "i18next-editor-frame") instead of validating event.origin or using an explicit, trusted communication channel. This allows untrusted pages to invoke internal actions available through the registered handlers.
Why this happens
The root cause is improper origin validation for cross-window communication, mapping to CWE-346: Origin Validation Error.
The locize SDK registers a window.addEventListener("message", ...) handler that:
- Treats event.data.sender as proof that the message comes from the intended editor frame.
- Does not verify event.origin against a whitelist of trusted domains or enforce a strict message-channel binding.
Because event.data is fully controlled by the sender, an attacker in another frame or window can craft messages that satisfy the sender check and reach internal handlers (editKey, commitKey, commitKeys, isLocizeEnabled, requestInitialize, etc.).
Depending on how these handlers manipulate the DOM, application state, or translation content, this can lead to cross-context manipulation and, in some integrations, cross-site scripting behaviors, intersecting with CWE-79 when user-facing content is influenced in unsafe ways.
Potential impact
- Attacker-controlled frames may trigger internal editor or key-commit operations in the locize-enabled application.
- Localization keys or content could be modified in ways that mislead users or inject hostile data into rendered pages.
- Application state related to internationalization settings may be altered without user consent.
- In deployments where translations or keys are rendered without proper output encoding, this could contribute to cross-site scripting-like outcomes.
- Abuse of initialization or configuration requests could interfere with the normal operation of the localization workflow.
General mitigation guidance
Effective mitigation focuses on securing cross-window messaging and treating all postMessage data as untrusted until proven otherwise:
- Validate event.origin against a strict allowlist of trusted domains before dispatching any action.
- Use structured message formats that include a type and version, and enforce strict schema validation for event.data.
- Bind communication through explicitly established channels (e.g., using MessageChannel or known frame references) rather than relying on self-asserted identifiers in the payload.
- Limit the capabilities exposed via postMessage handlers to only what is necessary, and gate sensitive actions with additional checks (such as user interaction or explicit opt-in).
- Ensure that any data reaching the DOM from translations or remote content is passed through appropriate output encoding and context-aware escaping to reduce XSS risk.
Designing messaging APIs with "deny by default" semantics and strong peer verification significantly reduces the chance of similar issues.
How teams detect issues like this
Organizations can detect this and similar vulnerabilities through a combination of review and automation:
- Static analysis and linting:
- Search for
window.addEventListener("message", ...)andonmessagehandlers that do not checkevent.originor use an overly broad origin policy (e.g.,"*"). - Flag handlers that rely on values inside
event.dataas trust signals (e.g.,data.senderordata.source) without verifying origin. - Code review checklists:
- Include explicit review items for cross-window messaging, ensuring origin validation and strict message schemas.
- Ensure that internal handlers reachable via postMessage do not expose privileged operations beyond what is necessary.
- Runtime and browser-level monitoring:
- Use browser devtools or automated tests to simulate cross-origin frames sending messages and verify that unauthorized messages are rejected.
- Incorporate security tests that attempt to call postMessage handlers from untrusted origins as part of integration testing.
- Automated tooling:
- Integrate security-focused linters or SAST tools that have rules for postMessage misuse, origin validation, and DOM-based XSS sinks.

