A window message handler never reads where the event came from
What it finds
A window receives message events from every page that holds a reference to it: its opener, frames inside it, or any page that opened it. A handler that acts on event.data without looking at event.origin lets any of them drive it.
Reported are function literals given to window.addEventListener("message", ...) or assigned to window.onmessage that never mention origin or source. Message handlers of workers, which only hear from the code that created them, are not on window and are left alone.
From the rule's source, message_origin_unchecked.rs.
export function listen(handle: (data: unknown) => void) { window.addEventListener("message", (event) => {tx0 reports: never checks event.origin handle(event.data); }); window.addEventListener("message", (event) => { if (event.origin !== "https://app.example.org") return; handle(event.data); }); window.onmessage = function (event) {tx0 reports: never checks event.origin handle(event.data); }; self.addEventListener("message", (event) => handle(event.data));} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:message-origin-unchecked" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:message-origin-unchecked] reason="..."tx0 explain tx0/ts:message-origin-unchecked shows the same in the terminal. Found a false positive? Report it.