Move Apple App Attest root certificate to configuration - #4081
Conversation
📝 WalkthroughWalkthroughApple App Attestation now receives its root certificate through server configuration. The verifier parses and validates the configured PEM, initialization passes the runtime value, and tests cover valid, missing, and invalid roots. ChangesApple App Attestation configuration
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/internal/system/config/config.go`:
- Around line 200-202: Document the new engine-level setting represented by
AppleAttestationConfig.RootCertificate, using the configuration key
attestation.apple.root_certificate. Add it to the relevant deployment
configuration or server settings guide under docs/, including its purpose and
default value.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b50d8608-b40d-4f1f-ba28-d606e995ca30
📒 Files selected for processing (6)
backend/cmd/server/config/default.jsonbackend/internal/attestation/app_attest.gobackend/internal/attestation/app_attest_constants.gobackend/internal/attestation/app_attest_test.gobackend/internal/attestation/init.gobackend/internal/system/config/config.go
💤 Files with no reviewable changes (1)
- backend/internal/attestation/app_attest_constants.go
The Apple App Attestation Root CA was hardcoded as a Go constant. Read it from an engine-level attestation config instead, defaulting to Apple's public root in default.json so deployments can override it. Document the new attestation.apple.root_certificate setting. Refs thunder-id#4080
5462909 to
ff5a330
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| | **Team ID** | The Apple Developer Team ID (for example, `ABCDE12345`). | | ||
| | **Bundle ID** | The iOS application bundle identifier (for example, `com.example.myapp`) that must match the attested app. | | ||
|
|
||
| The trust anchor used to validate the attestation certificate chain is a server-level setting, shared by every application, rather than a per-application one. It is configured under the `attestation.apple.root_certificate` key in `deployment.yaml` and holds the PEM-encoded Apple App Attestation Root CA certificate. <ProductName /> ships the public Apple root as the default in `config/default.json`, valid until 2045, so no configuration is required to verify iOS attestations out of the box. |
There was a problem hiding this comment.
We may have to modify the docs around this. Proceeding with this for now.
Purpose
The Apple "App Attestation Root CA" certificate was hardcoded as a Go constant (
appleAppAttestRootPEM) inbackend/internal/attestation/app_attest_constants.go, so the trust anchor could not be updated or overridden without a code change and rebuild.This PR moves the certificate out of source into deployment configuration, keeping Apple's public root as the default value in
default.jsonso the product still works out of the box.Follow-up to the review comment on #4055: #4055 (comment)
Approach
attestation.apple.root_certificateconfig section to the config schema (config.go) andbackend/cmd/server/config/default.json.newAppAttestVerifiertakes the PEM as a parameter, andInitializesources it from the server runtime config.appleAppAttestRootPEMconstant.The default certificate in
default.jsonis byte-identical to the removed constant, so behavior is unchanged out of the box while deployments can now override the trust anchor.Config resolution:
deployment.yamlis merged overdefault.jsonat load time (LoadConfig→mergeStructs), and a non-empty user value overrides the default. Operators override the cert by adding anattestation.apple.root_certificateblock todeployment.yaml; omitting it keeps the shipped Apple root.Related Issues
Related PRs
Checklist
docs/content/guides/guides/applications/application-settings.mdx(iOS App Attest section)breaking changelabel added.Security checks
Summary by CodeRabbit