mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-10-20 18:56:16 +00:00
Signup had no bot protection. The account itself was never the prize — GoTrue refuses a session until the address is confirmed, and 0 of the 2 unconfirmed accounts on record ever signed in. The prize is our mail: /signup and /recover send to whatever address the caller types, so a stranger could make pezkuwichain.io mail thousands of people who never asked for it. Sending reputation takes months to rebuild and every product on the domain shares it. Rate limiting alone was not enough. GoTrue defaults to 30 emails/hour, which is 720 a day to attacker-chosen recipients; tightening it to 15 halves the number without changing what is possible. Verification runs inside GoTrue, not here. It POSTs to siteverify with the widget secret before /signup, /recover, /resend, /magiclink, /otp and /token with grant_type=password. Adding our own check in the frontend or a proxy would protect nothing, because /auth/v1/signup is reachable directly. One shared widget in execute mode rather than one per form: some of these are buttons with nowhere to put a checkbox, and interaction-only appearance keeps the challenge invisible unless Cloudflare asks for one. Tokens are single-use, so each call renders fresh and tears down the previous widget. Six call sites, matching the six protected endpoints — password login included, since /token with grant_type=password is enforced. Refresh-token grants are exempt, so open sessions are unaffected. Site key travels as a build arg like the WalletConnect id: it is public by construction, visible in the bundle. Only the secret is privileged and it lives in GoTrue's env on the auth host. Ships ahead of enforcement. Turning captcha on server-side before the frontend sends tokens would break every login and signup in the same instant.
58 lines
2.7 KiB
Docker
58 lines
2.7 KiB
Docker
# pwap/web — Static SPA build for distribution.
|
|
# Build context is the pwap repo ROOT (not web/) because vite aliases like
|
|
# @pezkuwi/utils, @shared/* resolve to ../shared/* — both web/ and shared/
|
|
# must be in the build context.
|
|
# Stage 1: build with Node. Stage 2: pure dist/ in busybox (smallest possible
|
|
# attacker surface — no shell, no package manager, no node runtime).
|
|
# Tag the resulting image with the git SHA in CI so rollback is just
|
|
# "pull pwap-web:<old-sha>".
|
|
|
|
# ─── Stage 1: Build ────────────────────────────────────────────
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /build/web
|
|
|
|
# Copy package files first to leverage Docker layer cache when only src changes
|
|
COPY web/package.json web/package-lock.json ./
|
|
RUN npm ci
|
|
|
|
# Copy shared/ first (less frequently changed), then web/ source
|
|
COPY shared/ /build/shared/
|
|
COPY web/ /build/web/
|
|
|
|
# Build args for environment-specific values (passed from CI)
|
|
ARG VITE_NETWORK=MAINNET
|
|
ARG VITE_WS_ENDPOINT=wss://rpc.pezkuwichain.io
|
|
ARG VITE_WS_ENDPOINT_FALLBACK_1=wss://mainnet.pezkuwichain.io
|
|
ARG VITE_ASSET_HUB_ENDPOINT=wss://asset-hub-rpc.pezkuwichain.io
|
|
ARG VITE_PEOPLE_CHAIN_ENDPOINT=wss://people-rpc.pezkuwichain.io
|
|
ARG VITE_WALLETCONNECT_PROJECT_ID=8292a793b7640e8364c378e331e76d04
|
|
# Public by design — the site key is visible in the shipped bundle. The
|
|
# matching secret lives only in GoTrue's env on the auth host.
|
|
ARG VITE_TURNSTILE_SITE_KEY=0x4AAAAAAEDkUkbsUgw2D9zN
|
|
ARG VITE_SUPABASE_URL
|
|
ARG VITE_SUPABASE_ANON_KEY
|
|
|
|
ENV VITE_NETWORK=$VITE_NETWORK
|
|
ENV VITE_WS_ENDPOINT=$VITE_WS_ENDPOINT
|
|
ENV VITE_WS_ENDPOINT_FALLBACK_1=$VITE_WS_ENDPOINT_FALLBACK_1
|
|
ENV VITE_ASSET_HUB_ENDPOINT=$VITE_ASSET_HUB_ENDPOINT
|
|
ENV VITE_PEOPLE_CHAIN_ENDPOINT=$VITE_PEOPLE_CHAIN_ENDPOINT
|
|
ENV VITE_WALLETCONNECT_PROJECT_ID=$VITE_WALLETCONNECT_PROJECT_ID
|
|
ENV VITE_TURNSTILE_SITE_KEY=$VITE_TURNSTILE_SITE_KEY
|
|
ENV VITE_SUPABASE_URL=$VITE_SUPABASE_URL
|
|
ENV VITE_SUPABASE_ANON_KEY=$VITE_SUPABASE_ANON_KEY
|
|
|
|
RUN npm run build
|
|
|
|
# ─── Stage 2: Distribution image ───────────────────────────────
|
|
# busybox:musl gives us a tiny base (~1.5MB) with a shell for `cp` operations
|
|
# during deploy extraction, but no npm/curl/wget/ssh — minimal attack surface
|
|
# if the image were ever exposed.
|
|
FROM busybox:musl
|
|
WORKDIR /dist
|
|
COPY --from=builder /build/web/dist /dist
|
|
LABEL org.opencontainers.image.source="https://github.com/pezkuwichain/pwap"
|
|
LABEL org.opencontainers.image.description="pwap/web static SPA — Pezkuwi wallet/exchange frontend"
|
|
LABEL org.opencontainers.image.licenses="MIT"
|
|
CMD ["sh", "-c", "echo 'pwap-web image — extract /dist via: docker create + docker cp'; sleep infinity"]
|