feat(build-sdk)!: verify trigger deliveries with Ed25519 public keys only

MA
1h ago
+375-148

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

What this changes

Reflex Build's trigger deliveries are signed with Ed25519 instead of a shared HMAC secret. The platform signs each delivery with a key pair of the app's own, one pair per environment, in Standard Webhooks' asymmetric format (v1a). The app receives only the public half, in REFLEX_TRIGGER_PUBLIC_KEY. A public key cannot sign anything, so a sandbox .env or a deployed app's environment holds no credential that could forge a delivery, for that app or any other.

HMAC is removed rather than kept beside it: the platform never sent an HMAC-signed delivery, so no app depends on it, and keeping it would leave a path where a secret in an app's environment signs something the app accepts.

reflex_build_sdk.triggers:

  • verify and parse_delivery take public_key=, or read REFLEX_TRIGGER_PUBLIC_KEY. Only v1a signatures are accepted. With several keys separated by spaces, any of them verifies, which is how a key is rotated out.
  • Removed: the secret= argument, SECRET_ENV (REFLEX_TRIGGER_SECRET) and v1 signatures.
  • sign takes whsk_ signing keys only and makes one v1a signature per key; public_key(signing_key) gives the whpk_ half. Keys are base64 of the 32 raw Ed25519 bytes.
  • Ed25519 comes from cryptography, which the new triggers extra installs. It is imported when a key is first used, so the package keeps no required dependencies; without it, signing or verifying raises an ImportError that names the extra.

The pinned wire test now pins the v1a headers (Ed25519 signatures are deterministic), which flexgen's delivery tests match on the platform side. The old pinned HMAC headers stay as a vector that is refused.

Testing

  • uv run pytest tests/units/reflex_build_sdk: 825 passed. The trigger tests cover the pinned v1a headers, refusal of v1 signatures (including an HMAC made with the app's own public key, under either version), rotation across two keys, malformed keys and signatures, a tampered body, id or timestamp, and the missing-cryptography error.
  • ruff check, ruff format, pyright on the package and tests, pre-commit on the changed files, and scripts/check_min_deps.py reflex-build-sdk pass.

Releasing this needs a reflex-hosting-cli release that widens its cap on reflex-build-sdk in the same dispatch, as with 0.1.2.

Linear: ENG-14674


Generated by Claude Code