Permissive origin in postMessage

Description

Using "*" (any) as the target origin of a postMessage call allows third-parties to read the message.

Remediations

❌ Avoid using "*" as the target origin:

window.postMessage(message, '*')

✅ Specify the origin for your target application:

window.postMessage(message, 'https://myapp.example.com')

Associated CWE

OWASP Top 10

Configuration

To skip this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --skip-rule=javascript_lang_post_message_origin

To run only this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --only-rule=javascript_lang_post_message_origin