Skip to content

docs(embedding): re-measure what a missing style-src 'unsafe-inline' actually breaks #263

Closed

Description

@sydevs-bot

Summary

docs/embedding.md tells hosts in three places that omitting style-src 'unsafe-inline' renders
the widget "completely unstyled". That consequence was measured before #236 moved the stylesheet
into the shadow root, and the mechanism it rests on no longer exists.

The widget's stylesheet is now a constructed CSSStyleSheet (src/styles/sheet.ts:74-85:
new CSSStyleSheet(), replaceSync(chunk.css), assigned to adoptedStyleSheets). CSP's
style-src has no hook on replaceSync, so that sheet is not gated by the policy at all. The
only inline <style> the widget still appends to the host document is sahaj-atlas-fonts
(src/styles/fonts.ts:131, document.head.appendChild).

So the stated cause and the stated consequence have come apart, and a host reading the CSP table
cannot tell what they are actually trading away.

Found incidentally while fixing the troubleshooting row in #261.

Approach

The three passages that assert it, all of which move together or not at all:

  • docs/embedding.md:813 — the CSP table's style-src row: "The hard ask. The widget has no
    stylesheet to link — it appends <style> elements at runtime, which carry no nonce." →
    consequence "the widget renders completely unstyled, and does not degrade". The premise is
    now false for everything except the font faces.
  • docs/embedding.md:849 — the consequence summary table: "style-src 'unsafe-inline' → renders
    completely unstyled".
  • docs/embedding.md:1169 — the troubleshooting row: "The widget renders completely unstyled |
    style-src 'unsafe-inline' is missing from your CSP."

⚠ Do not rewrite these from the source read above. Two things make the real answer
non-obvious, and both need a browser:

  1. Style attributes are still gated. 'unsafe-inline' in style-src also licenses style
    attributes, and this widget sets a lot of them — every React style={} prop, vaul's drawer
    transforms and snap offsets, Radix's positioning, the aria-live region's inline clipping
    styles (docs/embedding.md:973-976), and mapbox-gl's own marker and canvas positioning. A
    policy without 'unsafe-inline' therefore breaks far more than the typeface, even while the
    adopted sheet keeps applying. Whether the result reads as "unstyled", "laid out wrong", or
    "mostly fine" is an observation, not a deduction.
  2. Constructed-stylesheet gating is a moving target. Whether replaceSync is subject to
    style-src has been argued both ways in the CSP spec. Confirm against the browsers in
    docs/embedding.md's support floor rather than against this ticket.

So: reproduce it, then write what you saw.

pnpm review:embed serves dist/ as real host-page embeds, which is the right harness — it needs
a response header, so add the policy there or front it with a proxy that sets one. Also check
whether style-src-attr and style-src-elem split the two halves cleanly enough to be worth
naming in the table, since a host who only needs the font faces could then keep a tighter policy.

Update font-src's row too if the font faces turn out to be the part style-src governs — the
two rows currently describe the typeface's failure independently (:814, "text falls back to your
system sans, everything works").

Acceptance criteria

  • Each of the three passages states a consequence that was observed in a browser against a
    policy without 'unsafe-inline', at the support floor the guide already names.
  • The style-src row's rationale describes how the widget actually installs styles — a
    constructed sheet plus one <style> for the font faces plus style attributes — not a
    stylesheet it "appends at runtime".
  • The three passages agree with each other, and with the font-src row, about what a host
    loses.
  • CHANGELOG.md gets an entry only if the recommended policy changes. A corrected description
    of an unchanged policy is guide accuracy, not something a host can observe.

Verification checklist

  • Reproduce with pnpm build && pnpm review:embed, serving a Content-Security-Policy header
    that omits 'unsafe-inline' from style-src, and screenshot the result.
  • Repeat with style-src-elem and style-src-attr set separately, and record which half each
    one costs.
  • Confirm from the network panel and the console which blocked-directive reports the browser
    emits, so the troubleshooting row can tell a host what to look for.
  • grep -n "unsafe-inline" docs/embedding.md — every hit agrees with what was measured.
  • pnpm lint && pnpm typecheck && pnpm test:run pass.

Notes

No automated lane can hold this. The smoke lane reads deployed file content over fetch, so
it cannot observe a CSP decision made by a rendering engine — docs/testing.md states the same
limit for the widget rendering at all. The guard here is that the claim was observed once and
dated, not that a spec pins it.

Related, same root cause: #261 fixed the troubleshooting row that still
denied the shadow root, and the style-src rows are the same class of claim left behind by #236.
#262 is a code defect found in the same sweep.

🤖 Written by the sydevs autonomous loop — see what this is

Activity

  1. added theissue type on Oct 9, 2026
  2. added
    proposal
    on Oct 9, 2026
  3. Ardnived commented on Oct 10, 2026

    @Ardnived
    Contributor

    @sydevs-bot implement

  4. removed
    proposal
    on Oct 10, 2026
  5. moved this from Proposed to Approved in SYDevelopers Technical Roadmapon Oct 10, 2026
  6. sydevs-bot commented on Oct 10, 2026

    @sydevs-bot
    ContributorAuthor

    🤖 no session running

    recent dispatches
    • 17:11Z implement · attempt 1 · session · done
    • 17:11Z implement · attempt 1 · session

    Written by the sydevs dispatcher. Sessions never edit this comment.

  7. added
    bot:working
    on Oct 10, 2026
  8. removed
    bot:working
    on Oct 10, 2026
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

    Fields

    Priority

    Medium

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions