2022-01-03 07:51:44 +00:00
|
|
|
id: postmessage-outgoing-tracker
|
|
|
|
|
|
|
|
info:
|
|
|
|
name: Postmessage Outgoing Tracker
|
|
|
|
author: LogicalHunter
|
|
|
|
severity: info
|
2022-04-22 10:38:41 +00:00
|
|
|
reference:
|
|
|
|
- https://appcheck-ng.com/html5-cross-document-messaging-vulnerabilities/
|
2022-01-03 07:51:44 +00:00
|
|
|
tags: headless,postmessage
|
|
|
|
|
|
|
|
headless:
|
|
|
|
- steps:
|
|
|
|
- action: setheader
|
|
|
|
args:
|
|
|
|
part: response
|
|
|
|
key: Content-Security-Policy
|
|
|
|
value: "default-src * 'unsafe-inline' 'unsafe-eval' data: blob:;"
|
|
|
|
- action: script
|
|
|
|
args:
|
|
|
|
hook: true
|
|
|
|
code: |
|
2022-07-28 11:21:08 +00:00
|
|
|
() => {
|
|
|
|
window.alerts = [];
|
2022-01-03 07:51:44 +00:00
|
|
|
|
2022-07-28 11:21:08 +00:00
|
|
|
logger = found => window.alerts.push(found);
|
2022-01-03 07:51:44 +00:00
|
|
|
|
2022-07-28 11:21:08 +00:00
|
|
|
function getStackTrace() {
|
|
|
|
var stack;
|
|
|
|
try {
|
|
|
|
throw new Error('');
|
|
|
|
} catch (error) {
|
|
|
|
stack = error.stack || '';
|
|
|
|
}
|
|
|
|
|
|
|
|
stack = stack.split('\n').map(line => line.trim());
|
|
|
|
return stack.splice(stack[0] == 'Error' ? 2 : 1);
|
2022-01-03 07:51:44 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 11:21:08 +00:00
|
|
|
var oldSender = window.postMessage;
|
2022-01-03 07:51:44 +00:00
|
|
|
|
2022-07-28 11:21:08 +00:00
|
|
|
window.postMessage = (data, origin) => {
|
|
|
|
if (origin == '*') {
|
|
|
|
logger({stack: getStackTrace(), args: {data, origin}});
|
|
|
|
return oldSender.apply(this, arguments);
|
2022-01-03 07:51:44 +00:00
|
|
|
}
|
|
|
|
};
|
2022-07-28 11:21:08 +00:00
|
|
|
}
|
2022-01-03 07:51:44 +00:00
|
|
|
- args:
|
|
|
|
url: "{{BaseURL}}"
|
|
|
|
action: navigate
|
|
|
|
- action: waitload
|
|
|
|
- action: script
|
|
|
|
name: alerts
|
|
|
|
args:
|
2022-07-28 11:21:08 +00:00
|
|
|
code: window.alerts
|
2022-01-03 07:51:44 +00:00
|
|
|
matchers:
|
|
|
|
- type: word
|
|
|
|
part: alerts
|
|
|
|
words:
|
|
|
|
- "at window.postMessage"
|
|
|
|
extractors:
|
|
|
|
- type: kval
|
|
|
|
part: alerts
|
|
|
|
kval:
|
|
|
|
- alerts
|