Repository navigation
docs(embedding): re-measure what style-src breaks, and name Turnstile's refused eval - #271
Conversation
…costs Three passages told hosts that omitting `style-src 'unsafe-inline'` renders the widget "completely unstyled". That was measured before #236 moved the stylesheet into the shadow root, and the mechanism it rested on is gone: the sheet is a constructed `CSSStyleSheet` now, and `style-src` has no hook on `replaceSync`. Measured against the real embed rather than re-reasoned from the source. Chromium 141, a built `map=false` embed served from one origin with the documented policy and `'unsafe-inline'` removed from `style-src` alone: - The widget's own sheet applied in full, and kept applying under `style-src 'none'`. - The `sahaj-atlas-fonts` `<style>` was refused, so no `@font-face` registered and `document.fonts` held none of ours. - The place-search field's library reads back the stylesheet it installs and threw on the null `sheet`, taking the field's chrome and its geocoder with it. - React's `style={}` props survived, because React writes through the CSSOM and CSP gates the attribute, not the property. Splitting the directive splits the cost cleanly, so the note records it: `style-src-elem` carries both failures, while `style-src-attr` refused only a scrollbar-width probe inside the scroll-lock library with nothing visible behind it. The note says to add `style-src-attr 'none'` beside `style-src 'unsafe-inline'` rather than writing `style-src-elem` alone, since an engine without the split falls back to `style-src`. `style-src` leaves the load-bearing list, which is now five entries: losing a typeface and place search is a degradation, and that list promises a widget that does not work at all. The row, the summary and the troubleshooting entry now say the same thing, and the `font-src` row points at the second route to the same missing typeface. The recommended policy is unchanged, so `CHANGELOG.md` is untouched — nothing a host can observe changed. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ADME A review pass pushed back on two claims in the previous commit, and a second measurement settled both. `style-src-attr 'none'` was offered as a safe tightening on the strength of a refusal attributed to a scrollbar-width probe. Wrong site: the refusal comes from the place-search library's screen-reader live region, which `Mapbox/aria-live.ts` hoists into the host's `<body>` and which is clipped to 1x1 by a `style` attribute. Measured under `style-src-elem 'unsafe-inline'` alone, the attribute applies zero declarations and the region computes to `position: static`, `overflow: visible`, 1280px wide, in the host page's flow — so its announcements would land on the page as visible text. The note now says not to split the directive, and the `aria-live` bullet under "what the widget does to your page" carries the same warning where a host meets that region. The `style-src` row enumerated the two `<style>` elements whose cost was measured as though it were the whole set. It describes the class now rather than listing it, since a third refusal does come from the interface chunk and no scroll-lock difference was reproducible either way. The troubleshooting row was keyed on the field losing its box, which is the one effect that cannot happen: `GeocoderBoundary` swaps in a plain styled input, so the box survives and the places do not. Keyed on the symptom now. The README's CSP bullet repeated the pre-#236 mechanism on the shortest path a host takes to a policy, so it moves with the guide. Its "locale-JSON origins" goes too — #198 left nothing there to allow. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas with
|
| Latest commit: |
215735b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://771aa6a9.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-docs-263-style-src-co.sahajatlas.pages.dev |
|
@sydevs-bot fold #272 into this PR: document in |
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
…atal row A host sending the recommended policy verbatim gets one `script-src` violation with a blocked URI of `eval`, from Turnstile's own script. The guide said nothing about it, so the only row a host could match it against was the blocked-Turnstile one, which is fatal and looks nothing like this. The note states what was measured and what was not: no challenge has been solved under this policy, and every write the widget makes is captcha-gated. A fresh probe today also ruled out the shortcut that would have settled it — the always-passes test site key returns `XXXX.DUMMY.TOKEN.XXXX` without rendering a challenge iframe and without tripping any violation, so it never reaches the code path the refusal comes from. That gap is the PR's open question. `CHANGELOG.md` stays untouched: the recommended policy block is unchanged, so nothing a host can observe changed. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
style-src 'unsafe-inline' actually breaksstyle-src breaks, and name Turnstile's refused eval
|
Folded #272 in — Adopted. Could not measure the challenge. Asked. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
Right-sized, and the fold-in earns itself: two files, one table, and both tickets land on the same four passages. The mechanism checks out against the source — src/styles/sheet.ts:74-85 builds the constructed sheet, src/styles/fonts.ts:131 is the one <style> left in a host's <head> — and the guide now agrees with itself and with font-src about what a host loses.
Two things hold it back. The evidence is one engine, where #263's second ⚠ asked for the support floor precisely because the mechanism is contested there. And Closes #272 retires a ticket this PR states it cannot finish.
Findings
- should-fix —
Five notes on that tablenow introduces six (docs/embedding.md:828) - should-fix — the constructed-sheet claim is unconditional on single-engine evidence (
:845) - should-fix —
Closes #272leaves the note's own promise unowned (:839) - consider — name the browser that lacks the
style-src-elemsplit (:855) - consider — the live region is hoisted by us, not placed by the library (
:851)
What was checked. Diff against origin/main; #263 and #272 read for scope and acceptance criteria; styles/sheet.ts, styles/fonts.ts, Mapbox/aria-live.ts and Mapbox/MapSearch.tsx (its GeocoderBoundary is what makes "falls back to a plain input" true); docs/embedding.md whole, including the support table and the exceptions list; grep for unstyled and unsafe-inline across src/ and every Markdown file — no stale CSP claim left behind. Consumer side: SahajCloud and the WordPress plugin hold no copy of the CSP contract (zero hits for style-src), so this guide is still its only home. CHANGELOG.md untouched is right — the policy block is unchanged.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The heading said five while six bold paragraphs followed it, including the load-bearing summary the pre-#263 version already counted as a note. A wrong count one table above the one this PR corrects reads as the same defect. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019kqZtGGcdZr3tst9QeFW7L
The claim that `style-src` cannot reach an adopted `CSSStyleSheet` was stated unconditionally on one engine, and dropping the directive from the load-bearing list rests on it. Firefox 128 and Safari 16.4 are in the support floor and were not measured, so the note now says which engine answered and what a different answer on the other two would cost. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019kqZtGGcdZr3tst9QeFW7L
Two corrections to the style-src-elem note. The region is created inside the widget's root beside the library's own input, and `hoistGeocoderLiveRegion` (src/components/organisms/Mapbox/aria-live.ts) is what moves it to the host's body — the library only clips it. The split-support warning named no browser, so a host could not tell whether it applied to them. Chrome 75, Firefox 108 and Safari 15.4 all sit below this guide's own support floor, so the fallback hazard is outside what the widget supports rather than a reason not to split. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019kqZtGGcdZr3tst9QeFW7L
|
Addressed all five review findings — Adopted by commit. The note count is six, not five. The constructed-sheet claim is scoped to Chromium 141, with what a different Firefox or Safari answer costs stated beside it. The live region is hoisted by us, clipped by the library. Adopted, premise corrected. Which browser lacks the split: none we support. Chrome 75, Firefox 108 and Safari 15.4 all sit below this guide's floor, so the note names versions instead of an unidentified browser. Adopted by filing. Two things still need you, both in the body: Firefox and Safari are unmeasured, and option 3 on the 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
style-src 'unsafe-inline'no longer makes the widget "completely unstyled" — fix(ui): host CSS without !important still restyles widget text #236 moved the sheet into the shadow root, and the four passages that said so are now what a browser actually does.evalon the recommended policy is named as expected and harmless, and told apart from the blocked-Turnstile row it currently looks like (docs(embedding): settle whether Turnstile needs'unsafe-eval'inscript-src#272, folded in on request).style-srcvaried, in Chromium 141 — and every claim that rests on it now says so, since the floor's other two engines were not measured.Change outline
Contract — the
style-srcrow's premise and consequencedocs/embedding.md, "Why each one, and what breaks without it". Paraphrased, one rule per line:Contract — the load-bearing list
Same file, the "allow these if nothing else" table. The list promises a widget that does not work
at all, and
style-srcno longer qualifies:Contract — the notes, and where they land
Contract — Turnstile's refused
eval(folds in #272)The policy block is unchanged, and so is the fatal
script-src challenges.cloudflare.comrow. What is new is one note and one symptom row, so therefusal has somewhere to land other than the row that means the widget is dead:
Contract — the two rows a host reaches from a symptom
Files — the second place a host reads the CSP claim
Open questions
Does a Turnstile challenge actually solve under the documented
script-src?Unsettled, and this PR does not settle it — but #274 now owns it. The refusal is harmless in
every run we have, and no run has ever solved a challenge under that policy. Registration and
the report form are both captcha-gated, so this is the half that matters.
Measured today, and it closes the cheap route rather than the question. An isolated probe
(Chromium 141 headless, 2026-10-10, the documented policy with the widget origin replaced by the
probe's own,
api.js?render=explicitexactly asuse-turnstile.tsloads it, 3 runs per policy):api.jsturnstile.render'unsafe-eval'XXXX.DUMMY.TOKEN.XXXX'unsafe-eval'So
.env's always-passes test site key (1x00000000000000000000AA) short-circuits: it handsback the literal dummy token without rendering a challenge and without tripping any violation —
including the
evalone this PR documents. #272 warned that the test key might not exercise thesame code path; it does not, and that is now measured rather than suspected. The production key
lives only in the Cloudflare Pages environment, and solving a real challenge against production
would be a write, which a routine may not make.
Option 1 below is executed: #274 carries the attended measurement, with the production-key
and client-key preconditions written into its checklist, so
Closes #272no longer retires thegap along with the ticket. The remaining choice is whether you want option 3 instead:
states what is and is not known, so no host is misled.
fatal row exists to prevent: a visitor who browses classes and then silently fails to sign up.
'unsafe-eval'to thescript-srcblock now. Removes the risk, and costs every hostthe weakest directive in the list on an unmeasured hunch. Needs a
CHANGELOG.mdentry, sincea host can observe it.
Recommended: 1. The observation behind option 3 is an
EvalErrorwith nothing visibly brokenin 3 of 3 runs, which is not evidence that the eval was load-bearing — and
'unsafe-eval'is theone directive a security reviewer will challenge a host on.
Preview
https://claude-docs-263-style-src-co.sahajatlas.pages.dev— nothing in this diff is deployed:docs/embedding.mdandREADME.mdare read on GitHub, not served by the Pages build.Test results
test:run(136 files, 1682 tests), re-run on the three reviewcommits
pnpm build(run twice: once for thedist/thestyle-srcmeasurement used, once tore-check the "no
eval, noFunctionconstructor in the shipped chunks" claim against 23emitted files — zero hits)
Manual verification
The guide's claims now rest on browser sessions, not on a spec. To re-run them:
pnpm build, then servedist/and a host page from one origin with aContent-Security-Policyresponse header —pnpm review:embedhas no header, so front itwith a proxy or a throwaway server.
'unsafe-inline'removed fromstyle-srcalone. Expect: theinterface fully styled,
document.fontsholding none of ours, and the place-search fieldfalling back to a plain input.
style-src-elem 'unsafe-inline'alone, thenstyle-src-attr 'unsafe-inline'alone, andconfirm the split still falls the way the note says.
evalnote: send the policy verbatim and read the console. Expect onescript-src/evalviolation with no source file, and a widget that works.and the whole
style-srcre-measurement rests on what an adopted sheet does there.Notes for reviewer
style-src 'unsafe-inline'actually breaks #263's second ⚠ askedfor the support floor. Only Chromium 141 is installed in a routine environment, so every claim
that rests on an adopted
CSSStyleSheetescapingstyle-srcis now scoped to Chromium in thetext, with what a different Firefox or Safari answer would cost stated beside it: the directive
is load-bearing again on that engine. Step 6 above is the attended pass that settles it. If you
would rather the entry stayed on the load-bearing list until then, say so and I will put it
back.
style-src-elemandstyle-src-attrship inChrome 75, Firefox 108 and Safari 15.4 — all three below this guide's own floor (111 / 128 /
16.4), per MDN's compatibility data. The note now says so instead of warning about an
unnamed browser, and the reason not to split is the attribute half alone.
the routine environment has no
VITE_MAPBOX_ACCESSTOKENand no.env.localkey, so thebackend was stubbed per
docs/rules/mapbox.mdand the map never ran. mapbox-gl's chunkcontains no
setAttribute("style"or.style.cssText, which is consistent with the note butis not an observation. The note names its scope.
CHANGELOG.mdis untouched, deliberately — the recommended policy block is unchanged byeither half of this PR, so nothing a host can observe changed. docs(embedding): re-measure what a missing
style-src 'unsafe-inline'actually breaks #263's fourth acceptancecriterion and docs(embedding): settle whether Turnstile needs
'unsafe-eval'inscript-src#272's third both say so.The note count, the unconditional constructed-sheet claim, and the live region's attribution —
it is created inside the widget's root beside the library's input, and
hoistGeocoderLiveRegion(src/components/organisms/Mapbox/aria-live.ts) is what moves it tothe host's
<body>. The library only clips it.evalrefusal itself. The note's 3-of-3 observationis the embed-level one recorded in docs(embedding): settle whether Turnstile needs
'unsafe-eval'inscript-src#272, with its console text andblockedURI: "eval"; theisolated probe above loaded the same
api.jsand saw no violation at all. That is consistentwith the test key short-circuiting before the code path that evals, but it is not proof, so the
note is worded as what was observed and not as something every page view must produce. If you
would rather the guide said nothing until the refusal is reproduced outside that one harness,
say so and I will cut the note.
What was measured
Chromium 141.0.7390.37, 2026-10-10. A
pnpm buildoutput plus host pages served from onelocalhost origin, the documented policy on the host document, the SahajCloud reads stubbed with
Playwright routes per
docs/rules/mapbox.md. Onlystyle-srcvaried.@font-facestyleattributes'self' 'unsafe-inline''self''none'style-src-elem 'unsafe-inline'onlystyle-src-attr 'unsafe-inline'onlyAn isolated probe, same browser, pins the mechanism:
new CSSStyleSheet()+replaceSync()+adoptedStyleSheetsapplies understyle-src 'none'with no violation, in both the document anda shadow root;
document.head.appendChild(<style>)is refused and leavesstyle.sheetnull;el.style.prop = …applies (CSP gates the attribute, not the CSSOM, which is why React'sstyle={}props survive);setAttribute('style', …)and astyle="…"in served markup are bothrefused as
style-src-attr.Why the live region settled the
style-src-attrquestion. Understyle-src-elem 'unsafe-inline'alone the attribute on the hoisted[aria-live]element applied 0declarations, and the element computed to
position: static,overflow: visible,clip: auto,1280px wide — against 31 declarations and a clipped 1×1 box under the allowing policy.
One review finding did not reproduce. Opening the filter drawer left
document.bodyatoverflow: visibleand the host page still scrollable under every policy, baseline included,and the host
<head>held exactly one<style>(ours). So no scroll-lock cost is claimed. Athird
style-src-elemrefusal does come from the interface chunk; what it costs was notestablished, which is why the row describes the class of thing the directive governs rather than
enumerating it.
The Turnstile half. The probe behind "Open questions" is its own page — a same-origin script,
the documented policy as a response header,
api.js?render=explicit, the test site key, and asecuritypolicyviolationlistener. Both policies, 6 runs in total, produced a token and noviolation.
grepover the 23 emitted files indist/fornew Function(, a bareeval(,(0,eval)andFunction("returnreturns zero, which is how we know the refusal recorded in #272is not ours.
The
style-src-elem/style-src-attrsupport floor is MDN's compatibility data, not ameasurement: Chrome 75, Edge 79, Firefox 108, Safari and iOS Safari 15.4. This guide's own floor
is Chrome 111, Firefox 128, Safari 16.4, so every browser it supports implements the split.
Closes #263
Closes #272
🤖 Generated with Claude Code
https://claude.ai/code/session_019kqZtGGcdZr3tst9QeFW7L