Skip to content

fix(sponsord-onramp): bind the Turnstile token to the client key - #3028

Merged
alpergundogdu merged 1 commit into
mainfrom
claude/2772-turnstile-cdata-2ba922
Nov 27, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
claude/2772-turnstile-cdata-2ba922

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Refs #2772 (§1b, §1c and the informational items; §2 is the gateway PR).

What changes

  • Turnstile cdata binding (1b). The gate page sets data-cdata to the client key from its URL (new {{CDATA}} placeholder). TurnstileGate::verify refuses a siteverify answer whose cdata does not parse to the request's client, alongside the hostname and action checks. A 0x address is 42 alphanumerics, inside Turnstile's cdata limit (255 chars of [A-Za-z0-9_-]).
  • A custom ONRAMP_GATE_TEMPLATE must carry {{CDATA}}; the onramp refuses to start without it, as it does for {{ACTION}}. Operators with a custom template add data-cdata="{{CDATA}}" to the widget. This is operator config, not an installer or HTTP API contract.
  • Spend bound (1c), docs only. docs/sponsord/security.md states the keeper's top-up rate (one SPONSORD_POOL_REFILL_MICRO_USDC per SPONSORD_POOL_WATCH_INTERVAL_SECS, $100/h by default, plus one per restart) as the treasury spend bound, and why per-address limits are not one. No daily issuance budget.
  • Informational. security.md says a malicious onramp runs arbitrary code through the curl | sh installer. The sponsord image keeps 0.0.0.0:8090 (other containers must reach it); the Dockerfile comment and the hardening checklist say the port, which serves unauthenticated /metrics with pool balances, must never be published publicly.

Tests

  • New: a token whose cdata names another client is refused (and funds that other client); missing, empty or malformed cdata is refused; a template without {{CDATA}} is refused at startup; the page carries data-cdata.
  • cargo nextest run -p sponsord-onramp -p sponsord -p sponsord-e2e: 91 passed. cargo clippy --workspace --all-targets --all-features: clean. cargo fmt --check: clean.

🤖 Generated with Claude Code

The gate page sets the widget's cdata to the client key in its URL, and
TurnstileGate refuses a siteverify answer whose cdata does not parse to
the client of the request. A custom ONRAMP_GATE_TEMPLATE must carry
{{CDATA}}, checked at startup like {{ACTION}}.

docs/sponsord/security.md states the keeper's top-up rate as the
treasury spend bound and why per-address limits are not one, that a
malicious onramp runs arbitrary code through the installer, and that
the sponsord image's port (unauthenticated /metrics) stays private.

Refs #2772

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 3750aff claude/2772-turnstil... 08d49cb +/-
78% 78% 0%
View coverage of the 3 most impacted files.
File main 3750aff claude/2772-turnstil... 08d49cb +/-
crates/node/src...s/client/mod.rs 89% 89% 0%
crates/sponsord...p/src/config.rs 97% 97% 0%
crates/sponsord...te/turnstile.rs 79% 81% +2%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@alpergundogdu
alpergundogdu merged commit d769020 into main Nov 27, 2026
38 checks passed
@alpergundogdu
alpergundogdu deleted the claude/2772-turnstile-cdata-2ba922 branch November 27, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant