# Hunt Xss Postmessage

> Web-message expert of the xss split: the SOURCE is not a URL param but

- Skill: `encod3d-sec/hunt-xss-postmessage` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx get-skill add encod3d-sec/hunt-xss-postmessage`
- Raw SKILL.md: https://api.skillmd.com/api/skills/encod3d-sec/hunt-xss-postmessage/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: Encod3d-Sec (https://skillmd.com/u/encod3d-sec)
- Updated: 2026-11-16
- Page: https://skillmd.com/skills/encod3d-sec/hunt-xss-postmessage

---


# Hunt: XSS - postMessage expert (microskill)

Web-message expert of the xss split: the SOURCE is not a URL param but
a cross-window message. The attacker page owns the sender; the victim
listener owns the sink. The verdict turns on origin verification, and
most verifications are string checks - bypassable by construction.

## Wiki

Hub: [[wiki/techniques/web/xss]] - qmd on hint only: "postmessage web
message origin bypass addEventListener iframe innerHTML eval".

## Paths (binding - shared with the mapper run)

    RUN=$ENG_DIR/hunt/xss/<host>          # SHARED with hunt-xss
    Experts write probes/xss-msg*.jsonl into the mapper's $RUN tree.

## Step 1 - Listener inventory (JS corpus, read-first)

Full-read the corpus; every `addEventListener('message', ...)` /
`onmessage =` handler gets:

```
handler location (file:line)
what it reads: e.data / e.data.html / nested field paths
which sink receives each field (innerHTML, eval, document.write,
  location, el.src, JSON.parse->render)
the origin check (exact code, not a summary)
frames that host the listener (main page vs iframe)
```

Record @ $RUN/raw/msg-listeners.md rows `listener | origin check | data path | sink`.

## Step 2 - Origin-check verdict

```
no check ..................... directly exploitable
indexOf/startsWith/endsWith/substring on e.origin
  -> bypassable: attacker origin like victim-com.evil.example
  (startsWith) or evilvictim-com (endsWith)
regex match .................. check anchors (^https?://exact-host$)
allowlist Set/switch ......... enumerate every allowed origin
e.isTrusted ................. false for postMessage - never a control
```

## Step 3 - Payload delivery (attacker page harness)

```html
<iframe src="https://victim/page" onload="this.contentWindow.postMessage(
  {html:'<img src=x onerror=alert(window.origin)>'},'*')"></iframe>
```

- [ ] Shape-confused probes: html-bearing objects, arrays, unexpected
      field types reaching the sink (the CVE-2026-27246 Adobe Connect
      shape: an html field routed to innerHTML).
- [ ] Sink-specific payloads per hunt-xss-dom sink table.
- [ ] Harness hosted on an attacker-controlled origin (lab domain /
      burp collab-hosted page); never a third-party victim.

## Step 4 - Validation + exit

- [ ] `alert(window.origin)` executed in the victim frame; console +
      screenshot into targets/<eng>/poc/.
- [ ] Rows appended to $RUN/candidates.jsonl (class=postmessage);
      pointer `XSS-MSG-DONE listeners=<n> bypassed=<n> fired=<n>`
      appended to $ENG_DIR/hunt-xss-<host>.md; Deadends per listener
      (row names the check that held).

Blocked implies research: before any Deadend is claimable on a held
row, (a) walk the shared arsenal (`hunt-xss/references/waf-bypass.md`)
rows for that control class, and (b) run one wiki query AND one
`mcp__wigolo__search` for `postMessage origin check bypass <target
framework>`. Results, or a genuine null, land in `coverage-depth.md`.
"No research tried" is not a claimable state.

### Depth walk (mandatory)

Walk EVERY applicable row: every enumerated message handler against its DOM sinks. Record each
row in `$RUN/coverage-depth.md` as a table `| row | state | evidence |`
where state is `probed`, `blocked`, or `N/A`, and evidence is a probe
path or a Deadends.md line. A bare `probed` with no evidence reference
fails the completion gate.

## Validation

Proof = attacker-origin message driving a live sink in the target page (harness page + captured execution/exfil) - a listener missing an origin check but reaching no dangerous sink is a hardening note.

## False Positives

- Listener without origin check that only writes to console or benign state.
- `event.origin` check present but you tested from the same origin (self-XSS, not exploitable).
- Sink reachable only from an origin you control but the target frames never embed (no delivery path).

## Cross-routing

- hunt-xss (mapper) for the injection-point context; hunt-xss-dom for the sink-side traversal; hunt-ssrf when the handler fetches attacker-supplied URLs.

## Attack surface

**APPROACH:** Enumerate `addEventListener('message')` handlers in the bundle read-first; trace origin checks against attacker-controllable origins (wildcard, weak regex, no check); validate with a benign marker post before payload chains.
**AVOID:** A message listener without an origin check is a sink candidate - impact needs the handler writing attacker data into a DOM sink.

## Stop conditions

Every listener terminal; every bypass claim cites the exact check code;
nothing written into skill dirs.

