Repository navigation
feat(backup): keep backups in an S3 bucket, encrypted - #3401
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (6)
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b8c4ac278
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: 4b8c4ac278
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: 9cce3de354
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
|
Major validation impact: this PR adds encryption/decryption to uploaded restore parts, and that reader is used again during selective restore. PR #3400 mapped this path to:
Those recorded passes predate this encrypted-part path and do not demonstrate it. The PR should explain why this previously validated flow changes, and these cases need re-validation after merge.
Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
There was a problem hiding this comment.

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
202c10c4-2a52-40f6-a6c9-c1d533d53304
Files ignored due to path filters: 1-
go.sumis excluded by!**/*.sum
Files selected for processing: 66-
cmd/silo/backup_command.gocmd/silo/backup_command_test.gocmd/silo/backup_interrupt_test.gocmd/silo/backup_wiring.gocmd/silo/main_test.gocontracts/api/v2/breaking-approvals.jsoncontracts/api/v2/openapi.jsondocs/architecture/backups.mddocs/architecture/blob-storage.mddocs/architecture/secret-encryption.mddocs/backups-api.mdgo.modinternal/api/handlers/admin.gointernal/api/handlers/admin_backup_destination_test.gointernal/api/router.gointernal/api/testdata/media_routes.txtinternal/apiv2/admin_backup_s3.gointernal/apiv2/admin_backup_uploads.gointernal/apiv2/admin_backups.gointernal/apiv2/admin_backups_test.gointernal/backup/backup_postgres_test.gointernal/backup/destination.gointernal/backup/downloads.gointernal/backup/dump.gointernal/backup/encryption.gointernal/backup/encryption_test.gointernal/backup/listing.gointernal/backup/lock.gointernal/backup/manifest.gointernal/backup/manifest_test.gointernal/backup/restore.gointernal/backup/s3destination.gointernal/backup/s3destination_test.gointernal/backup/selective.gointernal/backup/selective_apply_test.gointernal/backup/service.gointernal/backup/settings.gointernal/backup/status_test.gointernal/backup/stored.gointernal/backup/upload.gointernal/backup/upload_postgres_test.gointernal/blobstore/s3.gointernal/catalog/encrypted_settings_repo.gointernal/catalog/encrypted_settings_repo_test.gointernal/config/admin_settings.gointernal/contractledger/ledger_test.gointernal/s3client/client.gointernal/s3client/s3test/server.gointernal/secret/cipher.gointernal/secret/cipher_test.goscripts/ci/db-contracts.txtweb/src/api/v2/adminBackups.tsweb/src/api/v2/operations.tsweb/src/api/v2/schema.tsweb/src/hooks/queries/admin/backups.tsweb/src/pages/AdminBackups.tsxweb/src/pages/admin-backups/BackupS3Dialogs.tsxweb/src/pages/admin-backups/BackupSettings.tsxweb/src/pages/admin-backups/BackupTable.tsxweb/src/pages/admin-backups/UploadBackupDialog.tsxweb/src/pages/admin-backups/backupPresentation.test.tsweb/src/pages/admin-backups/backupPresentation.tsweb/src/pages/admin-backups/s3SetupModel.test.tsweb/src/pages/admin-backups/s3SetupModel.tsweb/src/pages/admin-backups/uploadModel.test.tsweb/src/pages/admin-backups/uploadModel.ts
Files with no reviewable changes: 2-
- internal/backup/selective_apply_test.go
- internal/backup/stored.go
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
-
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a751c0ec11
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: adb2acade1
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
1 similar comment
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
e42540e to
9461aee
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
3667e7b to
7c04a12
Compare
9461aee to
614b99b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 614b99b1a3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: 614b99b1a3
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
7c04a12 to
e809f8f
Compare
614b99b to
fb687f5
Compare
e809f8f to
9d42e81
Compare
fb687f5 to
1b35d70
Compare
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: 1b35d70938
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
9d42e81 to
671c47c
Compare
1b35d70 to
8631c81
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8631c818b2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
671c47c to
b6f6b1a
Compare
8631c81 to
86774f4
Compare
b6f6b1a to
5d3212d
Compare
Adds a dedicated S3 bucket as a backup destination, and encrypts every backup object written to a bucket (the dedicated one or the private operational bucket) with age under a key derived from SECRET_KEY, once the admin confirms they keep a copy of the key. `silo backup restore|verify` read s3:// folders, `silo backup decrypt` decrypts one object, listings of a bucket are bounded, and folders are deleted manifest first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A restore set encrypted with another server's SECRET_KEY was refused with the page's advice and decrypt command, then the server's message saying the same. The dialog now shows the server's message alone for that rejection, and keeps the page's line, with the server's detail under it, for the others. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The manifest MAC covers the manifest's JSON encoding, and `encrypted`, added with encrypted destinations, always encoded, as false for an unencrypted backup. A manifest written by a build from before it therefore re-encoded with "encrypted":false, its MAC no longer matched, and every such backup was refused as tampered: downloads, previews, and full and selective restores, with no flag to accept it. `encrypted` is now omitted when false, the only manifest field added since the first build (the restore set summary and the rest already were). Unencrypted manifests that builds since then signed with "encrypted":false must keep verifying too, so the check also tries that encoding when the manifest's own does not verify. Manifests signed by both kinds of earlier build, byte for byte, now verify (TestManifestsOfEarlierBuildsStillVerify). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ting reads The bucket connection test now reads its probe back before deleting it, so credentials that can write but not read fail the test instead of taking backups nobody can restore. One listing reads at most 256 MiB of manifests; past that the remaining folders are unreadable and kept, so a destination full of large manifests cannot take the process's memory. Co-Authored-By: Claude Opus 5.5 <[email protected]>
86774f4 to
1c775de
Compare
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: 1c775dec4f
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
| // Manifests are kept while the listing is built. A destination | ||
| // holding many large ones, or one a writer filled, must not take | ||
| // the process's memory: the rest are unknown, never swept. | ||
| if read += manifestObject.Size; read > maxListedManifestBytes { |
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Security: Budget manifests by bytes actually read
Required conditions: backups use S3 and the compatible endpoint is malicious or compromised, or a bucket writer can race listing against reads. This cap trusts the endpoint’s reported Size, but each later GET accepts up to 16 MiB without reconciling actual bytes. Fresh evidence beyond the earlier aggregate-manifest report is that the fix itself relies on attacker-controlled metadata: an endpoint can advertise zero-byte manifests while returning large valid encrypted:true manifests with another key check, which are retained as unverified. With 2,000 folders, scheduled backups or admin listing can retain gigabytes and OOM. Charge the budget from bytes actually read and reject negative or mismatched sizes.
Useful? React with 👍 / 👎.
Problem
Related issue: #2313
Validation tasks: changes #1197 C1; changes #1235 C1 and C2 (restoring accounts from an encrypted bucket backup or upload is one more path into the same account restore; the admin account-creation and notification flows those cases tested are unchanged, so a re-check after merge is enough)
Backups kept on the server's own disk survive a bad upgrade or a mistake, but
not a failed disk. Admins need to keep them off the server, and a backup in
someone else's storage holds password hashes and watch history, so it must
be encrypted. This adds an S3 destination for backups, whatever storage the
server's artwork uses, and encrypts every backup kept in a bucket.
Stacked on #3400.
Approach
backup.s3.*, with its owncredentials and a connection test). When a private bucket is configured,
the existing destination also keeps backups there. One destination at a
time; switching leaves earlier copies where they are.
derived from
SECRET_KEY(HKDF, its own label), using scrypt at 2^10 towrite. Uploads must name a work factor of 2^15 or lower.
manifest.jsonstays readable and records the key's check value, never the key. Reads
check the stored SHA-256 before releasing plaintext. Uploaded restore sets
are encrypted at rest in a bucket too.
they keep a copy of
SECRET_KEYoff the server. The page shows a checkvalue that
silo secret checkreproduces, and never shows the key. IfSECRET_KEYchanges, bucket backups pause until the new key is confirmed.silo backup decrypt, ands3://sources forsilo backup restoreandverify, with credentials fromSILO_BACKUP_S3_*.Downloads go to a private working folder with a space check and are
removed on interrupt. The manifest's MAC is checked before anything is
fetched, and
decryptrefuses an object whose manifest doesn't verify.A copy restored with
--intogets no backup bucket settings, because itkeeps the original server's id and would rotate away the original's backups.
A
--blobs-intokey prefix must be empty.folders it doesn't need to read, so a bucket full of junk keys can't
exhaust memory. Every destination deletes a backup's manifest first, and a
folder whose manifest lists missing objects counts as incomplete.
.agerestore set andlets the server decide. The server reads a file made with its own
SECRET_KEYand rejects any other with the decrypt command.Validation
go vet, and changed-line golangci-lint against feat(backup): restore from a backup uploaded from another server #3400's branch: pass.verify-apiv2-openapi,-web-types,-fixtures,-contract(additive only),verify-migrations,verify-migration-ledger,verify-size-ratchet,verify-local-paths,verify-settings-bindings,verify-route-inventory: pass.tsc -b, eslint and prettier on changed files, and vitest: pass.scripts/ci/db-contracts.txtpass, including an encrypted round trip against a fake S3 server and the command line reading from it.manifest.jsonstarts with the age header, the restore set downloads decrypted, andsilo backup verifyrestored a backup straight from the bucket into a scratch database.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-3401/
Risks
SECRET_KEYnow also loses every backup kept in abucket.
docs/architecture/secret-encryption.mdsays so, and theconfirmation step asks for an off-server copy.
filippo.io/agev1.3.2.15 GB backup took 44 minutes against about 8 locally.
Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Add encrypted backup system with S3 destination, selective restore, and admin UI
userdatacontract, plus a separate profile export/import feature atyour-data./admin/backups.backup_status,backup_uploads,backup_restore_items,backup_restore_followups, and restored-account mapping tables; check migrations/sql for the full list. Docker images now installpostgresql-client-18, and the artwork signer refuses keys in thebackupsnamespace, so existing signed URLs for those keys stop verifying.Macroscope summarized 86774f4.