Skip to content

Sandbox mediator posts and accepts messages without checking event.origin #16152

Backlog

Description

@vtushar06

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Target branch: develop

Observed behavior

The sandbox message bridge in packages/kolibri-sandbox/src/mediator.js (develop, 646b04dd) only filters incoming messages by message.source:

if (this.source && message.source !== this.source) {
  return;
}

It never checks message.origin. The same file also sends every outbound message with a wildcard target origin: sendLocalMessage, sendMessage, and request all call postMessage(..., '*') (around lines 74-79 and 92).

MainClient uses this mediator to talk to the content iframe, including the initial MAINREADY payload and later USERDATAUPDATE messages. That payload includes the real userData object, which carries userId and userFullName.

Expected behavior

The mediator should only accept messages from the zipcontent origin (or whatever origin the sandbox iframe is served from), and pass that origin into postMessage instead of '*'.

It may also be worth not sending the real userId into the iframe and using a per-resource pseudonymous id instead, so sandboxed content does not need the learner's actual user id. Not sure if anything in the current handlers depends on the real id, so happy to discuss.

User-facing consequences

The sandbox iframe is meant to be isolated from the main Kolibri origin. Without an origin check, and with outbound messages sent to '*', the bridge is looser than it needs to be. Sending the real userId into the iframe also exposes more learner identity to sandboxed content than necessary.

Steps to reproduce

  1. Open packages/kolibri-sandbox/src/mediator.js on develop.
  2. In handleMessage, confirm the only sender check is message.source.
  3. In sendLocalMessage, sendMessage, and request, confirm the target origin is '*'.
  4. In packages/kolibri-sandbox/src/mainClient.js, initialize and _sendUserData forward userData (including userId) across the bridge.

Context

Kolibri version: develop (646b04dd)
Came up while reading through the sandbox handler work from PR #15036.

Activity

  1. added theissue type on Dec 3, 2026
  2. added
    bug
    on Dec 3, 2026
  3. learning-equality-bot commented on Dec 3, 2026

    @learning-equality-bot
    Contributor

    📝 This issue doesn't follow one of our issue templates yet. It is closest to Report a bug. Please edit the description to fix:

    • ## AI usage is missing.

    The check runs again when you save, and this comment goes away once it passes. We review the issue after that. If it still doesn't follow a template in 7 days, it will be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-template

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions