Skip to content

Security: iframe sandbox allows both allow-scripts and allow-same-origin in WASM fallback path #376

Open

Description

@oli217

Description

In packages/widget/cap.min.js (widget@0.1.63), the instrumentation iframe is created with:

d.setAttribute("sandbox", c ? "allow-scripts" : "allow-scripts allow-same-origin")

When c is falsy (WASM fallback path — Safari Lockdown Mode, restrictive CSP), the iframe receives both allow-scripts and allow-same-origin.

Why this is a problem

The HTML spec explicitly warns that combining allow-scripts and allow-same-origin on a same-origin iframe allows the embedded document to remove its own sandbox attribute via JavaScript, escaping the sandbox entirely:

"Setting both the allow-scripts and allow-same-origin keywords together when the embedded page has the same origin as the embedding page allows the embedded page to simply remove the sandbox attribute."

Impact

If an attacker can control content injected into the sandboxed iframe (e.g. via the srcdoc attribute construction or a XSS elsewhere), the sandbox provides no isolation.

The allow-scripts-only path (when c is truthy) is safe.

Suggested fix

Remove allow-same-origin from the fallback path, or serve the iframe content from a data URI / separate origin so allow-same-origin is a no-op.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions