Skip to content

vue-doctor/security/postmessage-origin-check ​

Check event.origin against an allowlist before using event.data, and pass an explicit target origin to postMessage

PropertyValue
CategorySecurity
Default Severitywarning
Confidencemedium
FixableNo
Engineoxlint
Sincev2.0.0
Frameworksvue, nuxt
CWECWE-346
OWASPA01:2021

Why it matters ​

Check event.origin against an allowlist before using event.data, and pass an explicit target origin to postMessage

How to fix ​

Review the finding and update the code according to best practices below.

Agent Guidance ​

In every message listener, verify the sender first: if (event.origin !== "https://trusted.example") return; (compare against an exact origin or an allowlist, never includes/startsWith) before reading event.data; checking event.source === iframe.contentWindow also counts. When sending, pass the receiver's exact origin as the second argument of postMessage, never "*" for tokens, sessions or personal data.


Rule source: vue-doctor/security/postmessage-origin-check

Released under the MIT License.