locize Client SDK Cross-Origin DOM XSS and Handler Hijack Vulnerability
The locize client SDK versions prior to 4.0.21 are vulnerable to cross-origin DOM XSS and handler hijack due to missing origin validation in the InContext Editor, allowing attackers to inject malicious code and exfiltrate data via crafted postMessage events.
The locize client SDK, a browser module integrating the locize InContext translation editor, contains a cross-origin vulnerability in versions prior to 4.0.21. The vulnerability stems from the SDK’s failure to validate the event.origin property when handling window.addEventListener("message") events. This allows a malicious webpage sharing a window reference with a locize-enabled host (e.g., via an iframe) to send crafted postMessage calls, triggering internal handlers without proper authorization. Successful exploitation can lead to DOM-based XSS, hijacking of the api.source and api.origin properties, and CSS injection, potentially compromising the confidentiality and integrity of the application. This vulnerability was discovered via an internal security audit of the locize ecosystem.
Attack Chain
- An attacker hosts a malicious webpage with the intent to exploit a locize-enabled application.
- The locize-enabled application embeds the attacker’s page as an iframe or has a
window.opener/window.openrelationship with it. - The attacker crafts a
postMessagewith asenderfield equal to"i18next-editor-frame"and a malicious payload targeted at specific handlers. - The locize SDK’s
window.addEventListener("message")handler receives the message and, without validatingevent.origin, dispatches it to the internal handlers. - If the attacker targets the
editKeyorcommitKeyshandlers, the attacker-controlled payload values are assigned toitem.node.innerHTMLoritem.node.setAttribute(attr, value), injecting malicious scripts or HTML. - If the attacker targets the
isLocizeEnabledhandler, theapi.sourceandapi.originare hijacked, redirecting subsequent messages to the attacker’s window and exfiltrating translation content. - If the attacker targets the
requestPopupChangeshandler, malicious CSS code is injected into the popup’s inline style. - The attacker gains unauthorized access to sensitive data or injects malicious content into the locize-enabled application, impacting its integrity and confidentiality.
Impact
Successful exploitation of this vulnerability can lead to several critical consequences. Cross-origin DOM XSS allows arbitrary code execution within the context of the vulnerable application. Hijacking api.source and api.origin results in the leakage of translation content and metadata to the attacker, compromising sensitive information. CSS injection can alter the visual appearance of the application, potentially leading to phishing attacks or further exploitation. The number of victims depends on the adoption rate of vulnerable locize SDK versions prior to 4.0.21.
Recommendation
- Upgrade to
locizeclient SDK version 4.0.21 or later to patch the vulnerability. This version implementsevent.originvalidation insrc/api/postMessage.js, mitigating the risk of cross-origin attacks. - Deploy the Sigma rule “Detect Locize Client SDK DOM XSS Attempt via postMessage” to identify exploitation attempts based on manipulation of
innerHTMLorsetAttributein the locize context. - Enable web server logging and monitor for suspicious
postMessageevents originating from unexpected domains to detect potential exploitation attempts targeting the locize SDK.
Detection coverage 2
Detect Locize Client SDK DOM XSS Attempt via postMessage
highDetects potential DOM XSS attempts in the locize client SDK by monitoring for postMessage events that manipulate innerHTML or attributes.
Detect Locize API Hijack via postMessage
mediumDetects attempts to hijack the locize API source/origin by monitoring postMessage events to the isLocizeEnabled handler.
Detection queries are kept inside the platform. Get full rules →