Skip to content

onramp/gateway: web-facing pages lack framing and cross-site spend protections #2772

Todo

Description

@yigitdot

1. The onramp gate page can be framed, so other sites' visitors solve the captcha for an attacker's keys

  • crates/sponsord-onramp/src/http/fund.rs:19-27 returns bare Html; src/http/mod.rs:18-27 adds no security-header layer; no frame-ancestors / X-Frame-Options anywhere in the crate. assets/turnstile.html:30-37 auto-POSTs /v1/fund for whatever client is in the URL; the Turnstile checks (src/gate/turnstile.rs:146-161, hostname + action) pass for a framed copy of the page.
  • Attack: an attacker site iframes https://onramp/fund?client=0xA_n with a fresh key per visitor; Turnstile's managed mode passes most real browsers non-interactively; the attacker polls the capability out of the public GET /v1/capability?client=… (src/http/capability.rs:18-41). Per-IP limits don't bind — every visitor brings their own IP. Cash-out is self-dealing: publish content only the attacker's bonded node holds and pull it with the farmed keys; the keeper refills the pool from the treasury (keeper.rs:230-233, default $100/h) until the wallet is empty.
  • (Framing behavior of the Turnstile widget inside a nested iframe is plausible, not proven; the missing headers are confirmed.)
  • Send Content-Security-Policy: frame-ancestors 'none' and X-Frame-Options: DENY on every onramp response
  • Bind the Turnstile token to the client key via cdata
  • Consider a global daily issuance budget in the daemon (per-IP limits are not a spend bound)

2. decdn gateway: any web page can drain the user's * capability via a cross-site navigation

  • crates/cli/src/gateway/site.rs:181-203 — may_spend allows "a top-level navigation from anywhere". gateway.rs:1483-1486 + site.rs:64-66 — the site host is <hash32>.localhost:<port> (port included), while valid_host (gateway.rs:702-717) rejects :, so no host-specific scope can ever match a site host — in practice only a Scope::Any (*) capability pays for bundle sites. Same-origin /_decdn/<hash> requests are then paid (gateway.rs:1501-1513).
  • Attack: with a * capability registered (required for sites to work), any web page sets location = "http://<b32(B)>.localhost:8484/" (default port, crates/common/src/cli/gateway.rs:18) for an attacker bundle whose index.html loops fetch('/_decdn/<big attacker-held blob>') — each fetch is same-origin, allowed, and paid to the attacker's provider, up to the capability's cap.
  • Gate a site's first paid request on Sec-Fetch-Site: same-origin/none, or show a click-through interstitial
  • Give site hosts their own budget instead of falling through to *
  • Fix the host:port mismatch so a bundle's own scope can pay for its site

3. The shipped env example invites a spoofable client-IP header

  • deploy/sponsord/sponsord-onramp.env.example:24-27 sets ONRAMP_CLIENT_IP_HEADER=X-Forwarded-For and says nginx appends to it. nginx only appends with an explicit proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; by default the client's own header passes through, so the rightmost value is attacker-chosen (src/net.rs:46-54) — a fresh "IP" per request bypasses the fund/poll rate limits and spoofs Turnstile remoteip.
  • Document the exact nginx directive, or prefer X-Real-IP / CF-Connecting-IP set by the proxy

4. Gateway PUT /_capability doesn't check who minted the delegate; delegate slots are exhaustible (partly speculative)

  • crates/cli/src/gateway.rs:1735-1749 — the grant is attached by delegates.get_mut(&grant.signer) with no delegate.site == caller.site() check, so a page that learns another caller's delegate address and capability can attach it first under its own scope. gateway.rs:215 — MAX_PAGE_DELEGATES = 1024 can be filled by ~128 sites on public-suffix domains, denying minting to every other page for 15 min.
  • Bind delegates to the minting site; per-site delegate quota

Also worth fixing while here (informational): docs/sponsord/security.md:73-75 understates a malicious onramp — it serves the curl | sh installer, i.e. arbitrary code on the user's machine, not just "a different pool or release pin"; and the sponsord image binds 0.0.0.0:8090 (Dockerfile:94,97) with an unauthenticated /metrics, so a stray -p 8090:8090 exposes pool balances.

Activity

  1. added
    kind:security
    prio:medium
    area:cli
    area:sponsord
    on Oct 30, 2026
  2. yigitdot commented on Nov 26, 2026

    @yigitdot
    ContributorAuthor

    Status on main (e720fbb):

  3. alpergundogdu commented on Nov 26, 2026

    @alpergundogdu
    Contributor

    #3011 covers §3: the env example now names nginx's proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; directive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:cliarea:sponsordkind:securityprio:medium

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions