Files
buzz/deploy/charts/buzz-push-gateway
Tom Brow 25b58ab98f feat(push-gateway): verify Android Key Attestation (#9562)
## What and why

Ticket 3 of the Android push plan ([design PR
#9555](https://github.com/block/buzz/pull/9555)). The gateway now
verifies Android Key Attestation at enrollment instead of rejecting
every Android chain, and rate limits signed installation calls per
attested key.

Stacked on [#9560](https://github.com/block/buzz/pull/9560) (Android
enrollment and FCM wakes). This PR's base is that branch; it will be
retargeted once that merges.

- **Chain.** It must end at a configured Google attestation root
(Google's [published hardware
roots](https://developer.android.com/privacy-and-security/security-key-attestation#root_certificate)
are built in, pinned by public key), with valid signatures and issuer
links, CA issuers above the attestation key certificate, and no SHA-1
signatures. The attestation key certificate itself is exempt from the CA
flags, because some factory keyboxes issue it with CA:FALSE and
digitalSignature only (Google's Sony Xperia 10 III sample); a Keystore
leaf still cannot act as an issuer, since the extension is refused above
the leaf. Validity is enforced for Remote Key Provisioning chains;
Google tells verifiers to keep trusting the long-expired factory chains,
which the revocation list covers instead. The attestation extension must
be in the leaf and nowhere else. The leaf key must be EC P-256; it
becomes the installation's signing key.
- **KeyDescription.** Attestation and KeyMint security levels must be
TrustedEnvironment or StrongBox. The challenge must equal SHA-256 of the
enrollment transcript. Key properties (generated, EC, P-256, sign-only)
and the root of trust come only from the hardware-enforced list. The
bootloader must be locked, and the boot state Verified, or SelfSigned
with a verified boot key on an operator-configured list. The application
id (the one software-enforced value) must name exactly the configured
package with a configured signing digest.
- **Revocation.** A background task fetches Google's status list at
startup and then on its cache lifetime (5 minutes to 1 day), with a 30
second timeout, an 8 MiB size cap, capped exponential backoff and
jitter. Any REVOKED or SUSPENDED serial in the chain is rejected. With
no list yet, or a list older than the grace period, enrollment fails
closed. Enrollment reads an in-memory snapshot and never waits on a
fetch.
- **Rate limit.** Signed installation calls (delegate, revoke
delegation, rotate endpoint, revoke installation, on both platforms) are
limited per attested key. A call is counted only after its signature
verifies, so forged requests cannot spend another installation's
allowance. Counters are in memory per replica, bounded to 100,000 keys.
- **Dependencies.** None added. `x509-parser` gains its `verify-aws`
feature, which uses the `aws-lc-rs` the crate already depends on.

## Configuration

All optional; Android stays off unless the ticket 2 settings are
present. Documented in `docs/push-gateway-deployment.md` and
`.env.example` with example values only, and passed through
`deploy/charts/buzz-push-gateway` (disabled by default, schema-checked,
covered by `tests/runtime-options.sh`).

- `BUZZ_PUSH_ANDROID_BOOT_KEY_DIGESTS`: SHA-256 digests of verified boot
keys accepted with a SelfSigned boot state. Empty by default, so a
default gateway accepts stock Android only.
- `BUZZ_PUSH_ANDROID_ATTESTATION_ROOTS_PATH`: PEM bundle replacing the
built-in roots, for a reviewed root rollout. In the chart,
`android.attestationRoots.secretName` and `secretKey` mount it from a
Secret; an empty name keeps the built-in roots.
- `BUZZ_PUSH_ANDROID_REVOCATION_GRACE_SECONDS`: default 604800 (7 days),
minimum 3600.
- `BUZZ_PUSH_SIGNED_CALL_WINDOW_SECONDS` and
`BUZZ_PUSH_SIGNED_CALL_MAX_CALLS`: defaults 60 and 30.

## Tests

- `cargo test -p buzz-push-gateway` (all pass, 18 ignored), `cargo fmt
--all --check`, `cargo clippy -p buzz-push-gateway --all-targets -- -D
warnings`, and the chart tests (`render.sh`, `release-contract.sh`).
- Key Attestation chains are generated in the tests with a test root
injected as the configured root, and run through the production
verifier. One table rejects: unlocked bootloader, Unverified, Failed,
SelfSigned with an unlisted key, boot key only in the software list (two
variants), key properties only in the software list, extra key purposes,
wrong curve, wrong package, two packages, wrong signing digest, wrong
challenge, software-backed key (two variants), unknown root, forged leaf
signature, expired provisioned intermediate, extension repeated above
the leaf, non-P-256 leaf, a CA:FALSE certificate issuing the attestation
key certificate. Another accepts Verified with any boot key, SelfSigned
with a listed key, StrongBox and TrustedEnvironment, an expired factory
intermediate, and a CA:FALSE, digitalSignature attestation key
certificate. Revoked leaf, intermediate and root, a missing list and a
stale list are rejected. The status list parser and refresh (backoff,
cap, keeping the last list through failures) run against a scripted fake
source; no test touches the network.
- The per-key rate limit runs through the public router: forged calls do
not spend the allowance, the fourth authentic call is refused whatever
its kind, and another installation is unaffected.
- Break check: disabling the locked-bootloader guard and the rate limit
turned `rejected_attestations` and the rate limit test red; restored.

## Not here

The app side (ticket 7) generates the Keystore key and sends the chain.
The end to end run on a physical Android phone against a test gateway is
also still to do.

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
2026-11-17 19:18:35 -08:00
..

Buzz push gateway chart

0.4.0 release

This release configures one Apple application per gateway through application, replacing the profile map. Use it with the gateway implementing buzz-push-v1; clients must enroll again using the new capability. Configure the App Attest application ID and APNs topic explicitly before enabling the gateway.

Stop old gateway instances and verify the migration prerequisites before activation. The gateway migration refuses existing installations, and the relay migration refuses active legacy leases; neither deletes registration state.

Platform-managed runtime integration

podLabels, serviceAccountName, and terminationGracePeriodSeconds configure only runtime pods. Defaults retain the existing pod specification; the grace period cannot be shorter than 60 seconds. Additional labels cannot override the chart's name, instance, or component selectors. Migration settings remain separate.

A parent chart that supplies its own runtime NetworkPolicy can set networkPolicy.enabled=false and networkPolicy.externalPolicyName to that policy's name. The name is an explicit acknowledgement, not a cluster existence check: the parent must render and validate a policy selecting the runtime pods before deployment. Supplying a replacement name while the upstream policy is enabled is rejected. The migration NetworkPolicy remains enabled independently.

External-policy releases must run tests/check-external-policy.rb on the complete parent render including hooks, before install or upgrade. Helm 3 excludes hooks from its post-renderer input, so --post-renderer alone is not a sufficient gate. Render without --no-hooks or resource filtering, using the same chart, release name, namespace, values and capabilities as the deployment:

set -o pipefail
helm template RELEASE PARENT_CHART --namespace NAMESPACE -f VALUES.yaml \
  | ruby tests/check-external-policy.rb --expect DEPLOYMENT POLICY NAMESPACE > validated-release.yaml

--expect is mandatory for external-policy deployment and CI invocations. Provide the intended Deployment name, replacement policy name and release namespace from deployment configuration, not by extracting the annotations being checked. Repeat it for each external-policy Deployment. Missing Deployments or removed or overwritten markers then fail closed. No-argument mode is only for renders that intentionally have no external-policy requirement, such as default-mode tests.

For upgrade preflight, include --is-upgrade. Deployment automation must stop if this pipeline fails and must not change the chart or rendering inputs between validation and deployment. Run the post-renderer additionally during Helm install/upgrade to check ordinary resources, but retain the full-render preflight to detect hook collisions. GitOps render pipelines must validate the complete hook-inclusive output before submitting it to their reconciler. The Deployment records the required policy name. The gate rejects a missing, misspelled, duplicate, wrong-namespace or non-selecting replacement, and requires both ingress and egress isolation. It emits no manifests on failure and preserves successful output byte-for-byte. Parent CI must run this same gate on its complete render; a subchart-only render intentionally fails in external-policy mode. The deployment owner must separately validate the allowed traffic and rolling drain.

Deployment annotations

Use deploymentAnnotations for Deployment metadata such as secret.reloader.stakater.com/reload. These do not apply to runtime Pods or migration Jobs. Values must be strings; buzz.block.xyz/release-namespace and buzz.block.xyz/external-network-policy are reserved for chart policy ownership.