Skip to content

fix(turnstile): partner hosts fail the captcha with 110200 (unknown domain) #343

Closed

Description

@Ardnived

Summary

The production Turnstile widget (site key 0x4AAAAAAEFpp8n3BBZfG0KF, "wemeditate.com +1 (Spin)") only allows the hostnames sahajatlas.com, wemeditate.com, localhost, 127.0.0.1 and, since the stop-gap, shrimataji.org. The script embed renders Turnstile inside the host's page, and Turnstile validates that page's hostname. So every registration and issue report on any other partner site using the script embed fails its captcha with error 110200 (unknown domain), and the visitor sees the captcha-blocked screen. Iframe embeds are not affected, because there the challenge renders on sahajatlas.com.

Approach

Render the challenge in a small frame served from the widget's own origin, so Turnstile always sees sahajatlas.com, whatever page hosts the widget. One widget, one hostname list, no per-partner step, no SahajCloud change.

  • Challenge page. Add a static page on the widget origin (e.g. challenge.html, a Vite input beside the others at vite.config.ts:309) that loads api.js?render=explicit, renders the production site key with the theme and language it is given on its query string, and postMessages to its parent: token (with the value), expired, error, and a ready handshake once window.turnstile exists. It accepts a reset message back. The token is single-use and obtainable by anyone who frames the page, so '*' as the target origin leaks nothing new.
  • useTurnstile (src/hooks/use-turnstile.ts:145): keep its public shape (challengeRef, token, status, reset) so RegistrationForm and ReportIssueForm do not change. Replace the script load and turnstile.render (:53, :182) with an <iframe> (≈300×65, border: 0, title, referrerpolicy="strict-origin") appended to challengeRef, its URL resolved against import.meta.url as src/styles/fonts.ts:121 does, so previews and localhost frame their own origin. Accept only messages whose event.source is that frame's contentWindow and whose event.origin is the frame's origin. reset (:225) posts reset instead of calling turnstile.reset. Keep the existing semantics: blocked is not a latch, a later token wins the form back, and the frame is removed on unmount.
  • probeTurnstile / useTurnstileGuard (src/hooks/use-turnstile.ts:101, src/hooks/use-turnstile-guard.ts:44): the probe mounts a hidden frame and resolves true on its ready message, false on a timeout or a securitypolicyviolation for the frame. Update CSP_ADVICE (use-turnstile-guard.ts:14) to name frame-src https://sahajatlas.com. Still eager, still from the interface, never the shell.
  • One code path. Use the frame in every mode, including the app served on sahajatlas.com itself and the iframe embed, rather than branching on embed mode.
  • Embed contract (docs/embedding.md + CHANGELOG.md, same PR): in the CSP block (docs/embedding.md:788-795) and the "why each one" table (:810, :823, :826), challenges.cloudflare.com leaves script-src, connect-src and frame-src; the widget's origin joins frame-src. Drop the note about Turnstile's api.js evaluating strings in the host document (:836-850 and the troubleshooting row), since that script no longer runs there. Add a "nothing to configure per site for the captcha" line to the onboarding text. Update docs/environment.md:22 for the new mechanism.
  • Hosts: WeMeditateWeb's lib/atlas-embed.ts and the WordPress plugin set no CSP, so neither needs a change. Check both after deploy.
  • After rollout (dashboard, by hand): remove wemeditate.com and shrimataji.org from the widget's hostname list, leaving sahajatlas.com, localhost, 127.0.0.1.

Acceptance criteria

  • A Turnstile challenge rendered with the production site key by the script embed on a host not on the widget's hostname list completes without 110200.
  • The script embed no longer loads challenges.cloudflare.com into the host document. Only the widget-origin frame does.
  • A host whose CSP blocks the challenge frame gets the captcha-blocked screen and a console line naming frame-src, as before.
  • docs/embedding.md and CHANGELOG.md describe the new CSP requirement, and say that onboarding a partner needs no Turnstile step.

Verification checklist

  • Probe: in Playwright, fulfil https://www.example.org/probe (not on the hostname list) with a page that loads the built auto.js with the production key. Opening a registration form raises no 110200, and page.frames() shows challenges.cloudflare.com only under the widget-origin frame.
  • Same probe with Content-Security-Policy: frame-src 'none' on the host page: the widget shows the captcha-blocked screen and logs the frame-src advice.
  • pnpm test for the touched hooks and forms (use-turnstile, use-turnstile-guard, ReportIssueForm, CompactEmbedView.mount) passes.
  • On https://shrimataji.org/test/kn/meditation-centers-in-uk/, open a class, register with a test address, and get a success, not captcha_failed.
  • On https://wemeditate.com/map, the report-issue form's challenge solves and submits.

Decisions

  • How should partner sites pass Turnstile's hostname check? → Render the challenge in a frame on sahajatlas.com. One widget covers every host, with no per-partner step and no Enterprise plan. The other options were: keep adding hosts by hand (caps at 10), one widget per client synced through the Cloudflare API (free plan caps at 20 widgets × 10 hostnames, needs SahajCloud schema, API token and stored secrets), the Enterprise any-hostname widget (cost), and replacing Turnstile with self-hosted ALTCHA (weaker gate, new server endpoint and replay store). (Ardnived, 2026-11-01)

Notes

  • Probe, 2026-11-01 (Playwright, new headless Chromium, production key, every page a fulfilled route):

    Where the challenge renders Result
    directly on https://www.example.org (not listed) error-callback 110200 ×2
    directly on https://sahajatlas.com no error
    in a https://sahajatlas.com frame inside https://www.example.org no error; the challenges.cloudflare.com frame loaded

    Turnstile checks the hostname of the document that renders it, not the top-level page. Headless cannot solve the managed challenge, so a real solve in the nested frame is the shrimataji.org check above. The iframe embed already nests the challenge the same way.

  • Turnstile free plan: 20 widgets per account, 10 hostnames per widget (a hostname covers its subdomains), no any-hostname option. https://developers.cloudflare.com/turnstile/plans/

  • SahajCloud already records each reported embed's mode (inline | iframe) in embedMetadata (sydevs/SahajCloud src/lib/clients/embedMetadata.ts:36). This approach does not need it.

  • Optional follow-up, not in scope: SahajCloud could check siteverify's hostname against the widget origin.

  • Stop-gap, 2026-10-30: shrimataji.org was added to the widget's hostname list by hand when the real key went live with the chore(build): cut sahajatlas.com over to Workers and delete Pages #283 cutover. 5 of 10 slots are used.

  • Related goal: One safe intake for everything visitors submit #259 (production Turnstile key).

  • Found while preparing chore(build): cut sahajatlas.com over to Workers and delete Pages #283; not caused by the Workers cutover.

Activity

  1. added theissue type on Oct 29, 2026
  2. Ardnived commented on Nov 1, 2026

    @Ardnived
    ContributorAuthor

    @sydevs-bot implement

  3. added
    bot:working
    on Nov 1, 2026
  4. sydevs-bot commented on Nov 1, 2026

    @sydevs-bot
    Contributor

    🤖 no session running
    approved by Ardnived

    recent dispatches
    • 19:20Z implement · attempt 1 · session · done
    • 19:20Z implement · attempt 1 · session

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

  5. moved this from Awaiting to Working in SYDevelopers Technical Roadmapon Nov 1, 2026
  6. removed
    bot:working
    on Nov 1, 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

    High

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions