# VNX-941: Message sent without specifying its intended recipient

Reports postMessage(data, '*') to another window, and Android implicit broadcasts that carry extras with no receiver permission or target package.

| Field | Value |
|---|---|
| Rule ID | `VNX-941` |
| Severity | Medium |
| SARIF level | `warning` |
| Kind | `sast` |
| Languages | JavaScript / TypeScript, Java, Kotlin |
| CWE | [CWE-941](https://cwe.mitre.org/data/definitions/941.html) |
| CAPEC | [CAPEC-66](https://capec.mitre.org/data/definitions/66.html) |
| ATT&CK | [T1190](https://attack.mitre.org/techniques/T1190/) |
| CWSS vector | `CWSS:1.0/TI:M/AP:RU/AL:S/IC:N/FC:LT/RP:RU/RL:S/AV:L/AS:N/IN:A/SC:A/BI:M/DI:H/EX:M/EC:N/P:C` |
| Tags | `postmessage` `android` `broadcast` `cwe-941` |
| Source | [`internal/sast/rules/vnx-941.rego`](https://github.com/Vulnesis/cli/blob/main/internal/sast/rules/vnx-941.rego) |

## Overview

VNX-941 maps to [CWE-941: Incorrectly Specified Destination in a Communication Channel](https://cwe.mitre.org/data/definitions/941.html). Data sent over a channel whose destination is left open is delivered to whoever is listening: the page a popup or iframe now shows, or any installed app that registers for a broadcast action.

## What gets flagged

```javascript
window.opener.postMessage({ type: 'oauth', token }, '*');   // flagged
frame.contentWindow.postMessage(session, '*');               // flagged
```

```java
Intent changed = new Intent("com.example.PASSWORD_CHANGED");
changed.putExtra("password", newPassword);
sendBroadcast(changed);                                      // flagged
```

Not flagged: `postMessage` with an explicit target origin; `postMessage` to the page's own window and Worker/MessagePort `postMessage`; explicit Intents (`new Intent(ctx, X.class)`, `setPackage`, `setComponent`); broadcasts with a receiver permission; `LocalBroadcastManager`; intents without extras; comments and string literals.

## Remediation

Name the recipient: pass the expected origin to `postMessage`, and send broadcasts with `setPackage(...)`, a receiver permission, or `LocalBroadcastManager`.

```javascript
window.opener.postMessage({ type: 'oauth', token }, 'https://app.example.com');
```

## References

- [CWE-941: Incorrectly Specified Destination in a Communication Channel](https://cwe.mitre.org/data/definitions/941.html)
- [Android: Broadcasts security considerations](https://developer.android.com/develop/background-work/background-tasks/broadcasts#security-and-best-practices)

## Suppressing this rule

Put a `nosec` comment on the line, or on line 1 to cover the whole file. Use the comment marker of the file's language (`#`, `//`, `--` or `;`):

```text
# nosec vnx-941
// nosec vnx-941
```

Or record an ignore rule: `vulnetix ignore add --rule vnx-941 --reason "..."`. See [Suppressing findings](/sast/guides/suppressing-findings.md).
