Clears all 15 advisories pnpm audit --prod reported (13 high): the fastify
trustProxy CVE, the find-my-way HTTP/2 DDoS, and 12 fast-uri findings. None
were reachable here -- trustProxy is off and test-guarded, http2 is not
enabled, and fast-uri is only used by ajv for $ref parsing -- so this is
noise reduction, not an incident.
@fastify/compress is deliberately held at ^8: its 9.x major changes
behaviour that static-pages.ts precompression and the Content-Encoding
handoff in index.ts depend on.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
clientIp() read CF-Connecting-IP / X-Forwarded-For unconditionally. Origins
are reachable directly by IP, so anyone bypassing the Worker could set a
fresh header per request and land in a fresh rate-limit bucket every time --
the login, register and invite-peek limiters were effectively off against
the one attacker they exist to stop. server-options.ts already refuses
trustProxy for exactly this reason; the explicit header read reintroduced
what disabling trustProxy avoided.
The Worker has been stamping X-WeChat-AI-Proxy-Secret on every proxied
request since it was written (cloudflare-worker/src/proxy.ts). The origin
just never read it. resolveClientIp() now uses it as the provenance proof,
compared with timingSafeEqual.
When ORIGIN_PROXY_SECRET is empty the old behaviour is kept and a warning is
logged at boot, so existing Cloudflare deployments do not collapse every
visitor into one shared socket-IP bucket on upgrade. Set it on both sides to
close the hole.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Both halves of #7 were the frontend disagreeing with auth logic the backend
already had.
/app forced a non-empty invite code before it would POST /api/v1/auth/register,
so a fresh local-only deployment could never register anyone: the backend
waives the invite for the first user when no admin is configured, but nobody
exists yet who could issue a code. /api/v1/auth/config now publishes that
waiver as `bootstrapAvailable`, and the register form only requires a code when
the backend actually wants one — marking the field optional and explaining that
the first account becomes the admin. The same field also fixes an invite being
demanded under INVITE_REQUIRED_FOR_LOCAL=false.
The predicate is extracted to canBootstrapFirstAdmin() and used by both the
config and register endpoints, since the two computing it separately is how
they drifted apart in the first place.
/admin bounced every 401 to /api/v1/auth/login, which answers 503 under
LINUXDO_AUTH_ENABLED=false — a dead end on a page that already has a password
form. It now stays put and shows that form whenever local auth is enabled,
keeping the OAuth redirect for OAuth-only setups, and shapes the gate (buttons
and subtitle) to the methods actually available.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>