Skip to content

fix(security): authenticate session-recorder relay postMessage (RQ-3095, RQ-3096) - #18

Open
dinex-dev wants to merge 1 commit into
masterfrom
fix/websdk-relay-origin-validation
Open

fix(security): authenticate session-recorder relay postMessage (RQ-3095, RQ-3096)#18
dinex-dev wants to merge 1 commit into
masterfrom
fix/websdk-relay-origin-validation

Conversation

@dinex-dev

Copy link
Copy Markdown
Member

What & why

Hardens the SessionRecorder cross-frame relay against two postMessage weaknesses (RQ-3095, RQ-3096):

  • Send (RQ-3096): relayed events were posted to window.top with a wildcard '*' target origin, so any embedding or co-resident frame could receive them. Now posts to an explicit trustedOrigin when provided (falls back to '*' only when it is unset), and attaches a per-recording relayToken.
  • Receive (RQ-3095): the top-frame message listener only checked the attacker-controllable message.data.source. It now validates the shared relayToken and guards eventType against RQSessionEventType before buffering. Origin is intentionally not checked on the receive side — relayed events legitimately arrive from cross-origin child frames, so the origin restriction is enforced on the send side instead.

Both new options (trustedOrigin, relayToken) are opt-in and backward compatible — behavior is unchanged when they are not passed.

Testing

Two-origin browser harness (top ⇄ cross-origin iframe):

  • Correct trustedOrigin → iframe network + console events still relay into the session (no regression).
  • Mismatched trustedOrigin → nothing is delivered (leak closed).
  • Missing/incorrect relayToken → injected events are rejected.

Notes

Consumers must pass the new options to benefit; see the paired change in requestly/interceptor.

🤖 Generated with Claude Code

…95, RQ-3096)

Send side: post relayed events to trustedOrigin (falls back to '*') and attach a relayToken, instead of an unconditional wildcard target (RQ-3096). Receive side: validate relayToken and guard eventType before buffering, instead of trusting the attacker-controlled message.data.source (RQ-3095). Both options are opt-in and backward compatible.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant