-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxyinterceptor.js
More file actions
31 lines (28 loc) · 1.45 KB
/
Copy pathproxyinterceptor.js
File metadata and controls
31 lines (28 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(function() {
console.log("Initializing active postMessage proxy interceptor.");
let sensitiveDataDisclosed = false;
const originalPostMessage = window.postMessage;
window.postMessage = function(message, targetOrigin, transfer) {
console.log(" OUTGOING postMessage detected:");
console.log(" Target Origin:", targetOrigin);
console.log(" Payload:", message);
if (typeof message === 'string' && message.includes('access_token')) {
console.error("TRUE POSITIVE: Sensitive token being broadcasted to a cross-origin target.");
sensitiveDataDisclosed = true;
}
return originalPostMessage.call(this, message, targetOrigin, transfer);
};
window.addEventListener('message', function(event) {
console.log(" INCOMING postMessage intercepted:");
console.log(" Source Origin:", event.origin);
console.log(" Source Frame:", event.source ? window.location.origin : "Unknown/CSP Blocked");
console.log(" Payload:", event.data);
if (event.origin !== window.location.origin) {
console.warn("Cross-origin message received from: " + event.origin);
if (event.data && event.data.type === "render" && typeof event.data.html === "string") {
console.error("TRUE POSITIVE: External origin attempting DOM injection via postMessage.");
sensitiveDataDisclosed = true;
}
}
}, true);
})();