Files
buzz/deploy/charts/buzz-push-gateway/values.yaml
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

137 lines
5.1 KiB
YAML

replicaCount: 2
image:
repository: ghcr.io/block/buzz-push-gateway
# `main` is published by the push-gateway lane on every main push.
tag: main
digest: ""
pullPolicy: IfNotPresent
pullSecrets: []
existingSecret: buzz-push-gateway
# DDL-capable credentials are used only by the pre-install/pre-upgrade migration
# Job. Runtime DATABASE_URL in existingSecret should have DML-only privileges.
migration:
# Applies only to migration Pods, independently of runtime podAnnotations.
podAnnotations: {}
existingSecret: buzz-push-gateway-migrations
databaseUrlKey: DATABASE_URL
# Existing LOGIN role used by runtime DATABASE_URL. Migrations grant it only
# CONNECT plus DML on the six gateway tables in this dedicated database.
runtimeDatabaseRole: buzz_push_gateway_runtime
resources:
requests: {cpu: 50m, memory: 64Mi}
limits: {cpu: 250m, memory: 128Mi}
# Routing origin used only when httpRoute.enabled=true. Not passed to the binary.
gatewayOrigin: ""
maxGrantLifetimeSeconds: 2592000
application:
# Production MUST override this with the exact Apple TEAMID.bundle-id.
appAttestAppId: TEAMID.com.example.buzz
apnsTopic: com.example.buzz
apnsEnvironment: production
apnsCert:
secretName: buzz-push-gateway
secretKey: apns-identity.pem
# Android is off unless enabled. Enabling it needs the package, at least one
# signing certificate digest and the Firebase project and service account.
android:
enabled: false
# Exact application package the attestation must name.
packageName: com.example.buzz
# SHA-256 digests (64 hex characters each) of the app's signing certificates.
signingCertDigests: []
# Verified boot keys (SHA-256 digests, 64 hex characters each) accepted when
# the hardware reports a self-signed boot state. Empty accepts stock Android
# only. Add the published keys of a custom operating system to support it.
bootKeyDigests: []
# Seconds the attestation revocation list may go without a successful refresh
# before Android enrollment fails closed.
revocationGraceSeconds: 604800
fcmProjectId: example-project
fcmServiceAccount:
secretName: buzz-push-gateway
secretKey: fcm-service-account.json
# Optional PEM bundle replacing the built-in Google attestation roots, for a
# reviewed root rollout. Empty secretName keeps the built-in roots.
attestationRoots:
secretName: ""
secretKey: android-attestation-roots.pem
# Rate limit on signed installation calls, per attested key and replica.
signedCallRateLimit:
windowSeconds: 60
maxCalls: 30
appAttestRoot:
secretName: buzz-push-gateway
secretKey: app-attest-root.pem
service:
port: 8080
# Optional Deployment metadata, independent of runtime and migration Pods.
# The chart owns buzz.block.xyz/release-namespace and external-network-policy.
deploymentAnnotations: {}
podAnnotations: {}
httpRoute:
# Disabled by default so a generic install cannot claim an unattached route.
# Enable only when this chart owns a Gateway API route. Environments with an
# existing ingress or service mesh route should keep this disabled.
enabled: false
parentRefs: []
resources:
requests: {cpu: 100m, memory: 128Mi}
limits: {cpu: "1", memory: 512Mi}
podDisruptionBudget:
enabled: true
minAvailable: 1
networkPolicy:
# Parent chart must supply this named replacement when enabled is false.
externalPolicyName: ""
enabled: true
# Kubernetes NetworkPolicy cannot allow DNS names. Production operators must
# narrow these CIDRs to their PostgreSQL/NAT destinations where supported.
apnsEgressCidrs: [0.0.0.0/0]
# Override with the actual database network. This example private range is
# intentionally separate from broad APNs HTTPS egress.
postgresEgressCidrs: [10.0.0.0/8]
dns:
namespaceSelector:
kubernetes.io/metadata.name: kube-system
podSelector:
k8s-app: kube-dns
# Scoped ingress to the private metrics port (8081). Off by default so 8081
# has no pod ingress at all; enable alongside podMonitor or an external
# annotation-discovered scraper and name its namespace/pod so reachability
# stays narrow.
monitoring:
enabled: false
namespaceSelector: {}
podSelector: {}
# Prometheus-operator PodMonitor scraping the private /metrics on port 8081.
# Off by default; requires networkPolicy.monitoring to also be enabled.
podMonitor:
enabled: false
interval: 30s
scrapeTimeout: 10s
labels: {}
# Prometheus-operator alerting rules. Off by default.
prometheusRule:
enabled: false
labels: {}
# Retryable-outcome fraction (0..1] that fires PushGatewayHighApnsRetryRate.
apnsRetryRatioThreshold: 0.25
# Minimum APNs attempts in the 10m window before the retry-ratio alert can
# fire, so a couple of retries at trivial volume cannot trip it.
apnsRetryMinSamples: 20
nodeSelector: {}
tolerations: []
affinity: {}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app.kubernetes.io/name: buzz-push-gateway
# Runtime-only mesh integration. Migration settings remain separate.
podLabels: {}
serviceAccountName: ""
terminationGracePeriodSeconds: 60