Skip to content

feat(security): 本地控制台签名的备份退役证明(#68 切片) - #154

Merged
LIghtJUNction merged 1 commit into
mainfrom
fix/backup-retire-attest-20260928
Sep 28, 2026
Merged

LIghtJUNction merged 1 commit into
mainfrom
fix/backup-retire-attest-20260928

Conversation

@LIghtJUNction

Copy link
Copy Markdown
Contributor

概要

这是 #68 的一个切片:本地控制台签名的备份退役证明。本 PR 不关闭 #68,也不声称生产备份已销毁。

  • 新增 msg.security.backup_retirement:root 签名记录(purpose custodial-backup-retirement-v1)绑定主体、旧签名钥 id、旧加密钥 id、非空的备份集清单,以及最长 400 天的有效期。每次读取都会用当前有效且未吊销的 root 凭据(active root certificate 对应的凭据)重新验签。
  • 新增 msg.admin.backup_retirement.import_record,以及 RootAdmin.sign_backup_retirement / RootAdmin.import_backup_retirement,两者都经过 require_local_console,并要求输入摘要确认。导入只接受已签名的记录,不接受调用方传入的布尔值;导入时还要求存在该主体下与旧钥精确匹配的 completed 迁移,并写入审计 root.custodial.backup_retirement。
  • retirement_view / retirement_evidence / snapshot:只有针对这一条精确记录验签通过,才返回 backup_retired=True;没有记录时仍为 False。server_key_retired 只有在线退役与备份证明同时成立时才为 True(phase server_key_retired)。网络可写的迁移 body 里的 backup_retirement 字段会被忽略,也不再回显。
  • fail closed:记录被篡改、签名者不对、与旧钥绑定不匹配、已过期或尚未生效、有效期过长、root 已轮换或吊销、没有可信时钟(now=None)时,一律视为未退役,backup_status 为 local_attestation_invalid 或 local_attestation_expired。
  • 网络路径没有新增任何操作,只把 ctx.now 传入 snapshot 用于判断是否过期。

证明的范围仅限所列备份集的操作者声明,不能证明其他副本不存在。按约束没有改 cli.py,所以暂时没有 msg-admin 命令行接线。

测试

  • 新增 tests/test_backup_retirement_attestation.py(20 个用例,含一个 PostgreSQL 集成用例:网络 inventory 只在本地导入后才报告 backup_retired=True,篡改后回落为 False,网络请求带入的记录会被拒绝)。
  • 全量 pytest:1797 passed。test_legacy_ledger_snapshot.py 需设置 MSG_TEST_LEGACY_SOURCE 指向 ac083b3 的检出后单独运行。

Refs #68(不关闭)

…ement records

backup_retired now needs one exact root-signed record bound to the subject and
both old key IDs, imported behind require_local_console and re-verified on every
read; server_key_retired additionally needs online retirement. Missing, altered,
expired, misbound or pre-rotation records fail closed. Slice of #68.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI lite review requested due to automatic review settings September 28, 2026 18:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-09-28T18:49:54.168997Z 3490750 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@LIghtJUNction
LIghtJUNction merged commit 476e64f into main Sep 28, 2026
11 checks passed
@LIghtJUNction
LIghtJUNction deleted the fix/backup-retire-attest-20260928 branch September 28, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants