Repository navigation
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 5 minutes. View limit details
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. |
✅ SSOT Configuration Compliance: Passing🎉 No new hardcoded values of either class — Known backlog in |
mrveiss
left a comment
There was a problem hiding this comment.
code-reviewer pass: #20737 (head a61e5fa)
Verdict: CHANGES NEEDED (one Medium to settle before merge; the crypto itself is sound)
| Severity | file:line | Issue | Fix |
|---|---|---|---|
| Medium | autobot_shared/secrets_envelope.py _field_key (~L270) |
Root-key rotation (rewrap in envelope_secrets_service) rewraps grants only. Every fe1. value is sealed directly under the root-derived key, so a rotation makes all of them unreadable, and nothing rewraps them. No agent may re-seal (#17038), so the path has to be a product action. |
Add the rotation path, or file the issue and name the limitation in THREAT_MODEL.md and the rotation runbook before the first fe1. value is written. |
| Low | secrets_envelope.py _FIELD_VAULT_ID / derive_vault_key |
The field key is the vault KEK for the pseudo-vault field-encryption (info autobot-secrets-vault:field-encryption). It cannot collide with a parsed vault ref, because VaultRef only admits known kinds. But derive_vault_key takes any string, and rewrap_dek derives from grant.grantee as stored. A grant row with that grantee would hold a KEK equal to the field key. AAD kinds differ (field-value vs wrapped-dek), so no cross-open follows, but this is namespace separation, not a distinct label. |
Derive with its own info prefix (e.g. autobot-field-encryption:v1), or reject the reserved id in VaultRef/derive_vault_key. |
| Low | services/telegram_polling.py poll_once (~L184) |
TelegramBotService.from_redis() used to return an empty service (token None) on a bad stored token. It now raises FieldDecryptionError into the lease tick. I did not check whether LeaderLease.run catches it. |
Catch FieldDecryptionError in poll_once, log, return None. |
| Low | llc/sync/outbound_sync.py ~L471-490 |
An unreadable PM config is swallowed by the outer logger.exception, so the sync silently skips. test_pm_config returns a 500, and the Telegram and WhatsApp webhooks return a 503. Failing closed is right, but the signal differs by route. |
Emit one structured error naming the context, and surface "credential unreadable" in the company PM status. |
| Info | repo_tests/one_aead_core_17981_test.py _PENDING |
legacy_secret_keys.py (Fernet) and passphrase_encryption.py (AESGCM, no AAD) remain second cores in autobot_shared. They are explicitly listed, shrink-only and tracked, so (d) is met for this PR's scope, not fully. |
None; keep the issue open. |
Checks:
- (a) Contexts are stable and exist at seal time. PM config uses
organization:<uuid>:external_pm_config(UUID normalized, immutable). Telegram and WhatsApp useredis:<fixed key>. SSO usessso_provider:<id>:<field>. All four are fixed at seal time. - (b) Reads fail closed.
decrypt_fieldmaps every failure toFieldDecryptionError, andopen_taggedpasses through only values with noenc:tag (plaintext that was never encrypted). The Telegram and WhatsApp webhooks turn an unreadable secret into a 503 (not configured). The onlyNonepath is "nothing stored". - (c) Legacy values still open:
- The legacy format is byte-compatible with the old code (
nonce || ct, no AAD,AUTOBOT_FIELD_ENCRYPTION_KEY). fe1.cannot start a base64url blob, because.is outside that alphabet.- PM config (set, test and outbound sync), Telegram and WhatsApp are covered by the new tests.
- Provider-auth flow: it still stores the PKCE verifier in plaintext, so there is no encryption to open.
- SSO:
decrypt_sso_confighas no runtime caller in the tree. Only the one-shot script callsencrypt_sso_config, so SSO legacy reads are tested but not exercised by any route.
- The legacy format is byte-compatible with the old code (
- (e) Derivation is HKDF-SHA256 with an info string, but see the Low row above on label separation.
- (f) Nonces are 12 random bytes from
os.urandomper seal, under one long-lived key. That is fine at this volume. The AAD is length-prefixed with the format version and afield-valuekind, so the encoding is injective and distinct fromsecret-valueandwrapped-dek. Onefe1.blob moved to another record or field fails to open.
Not checked: I ran no tests. LeaderLease.run exception handling. Whether any agent tool or MCP route reads these stores. I found none by grep, and the routes I did find are listed above.
…eld key gets its own HKDF label; rotation limit documented (#17981)
|
Code review on PR #20737 (head 9d255d9): CHANGES NEEDED Delta a61e5fa..9d255d9. Items (a) and (b) check out; (c) has one route that still turns the error into a 200.
Verified:
Not checked: the body of |
…e token with the one 503; one HKDF helper (#17981)
|
Code review on PR #20737 (head 37ec8ca): APPROVE Delta 9d255d9..37ec8ca. The prior MEDIUM (webhook returns 200 on an unreadable token) is fixed.
Not checked: no test suite was run (read-only review). The 503 mapping was verified from |
Auto-sync: merging
|
| side | commit | subject | issue refs |
|---|---|---|---|
| main | 90911ee0c |
Merge main into issue-16333-human-admin-gate (auto-sync) [skip ci] | none |
| main | c822582f3 |
fix(auth): the service key is not an admin; one gate, a named and audited opt-in, a guard (#16333) | #16333 |
| this branch | 5f92fa470 |
Merge main into issue-17981-field-encryption-aad (auto-sync) [skip ci] | none |
| this branch | 9df294a0f |
test(secrets): record the one-AEAD-core guard's scope (#17981) | #17981 |
repo_tests/reach_scope_claim_17844_test.py
| side | commit | subject | issue refs |
|---|---|---|---|
| main | a7b2a06c4 |
Merge main into the merge train (#20788) | #20788 |
| main | 90911ee0c |
Merge main into issue-16333-human-admin-gate (auto-sync) [skip ci] | none |
| main | c822582f3 |
fix(auth): the service key is not an admin; one gate, a named and audited opt-in, a guard (#16333) | #16333 |
| this branch | 2c2d1d75b |
Merge main into issue-17981-field-encryption-aad (auto-sync) [skip ci] | none |
| this branch | 5f92fa470 |
Merge main into issue-17981-field-encryption-aad (auto-sync) [skip ci] | none |
| this branch | 9df294a0f |
test(secrets): record the one-AEAD-core guard's scope (#17981) | #17981 |
Thinking Path
autobot_shared/field_encryption.pysealed stored credentials with AES-GCM and no associated data. Its siblingsecrets_envelope.pybinds every value to where it lives. Both are live, so the same package disagreed on the property that matters: a sealed company token copied into another company's row decrypted cleanly as that company's. The two also used different keys, andAUTOBOT_FIELD_ENCRYPTION_KEYis provisioned by no install path (not Ansible, notgenerate-secrets.sh, not Dockersecrets-init). So on a standard install every field-encrypted write already failed.AUTOBOT_SECRETS_ROOT_KEYis provisioned by all three.The fix is one AEAD core with one key contract.
field_encryptionbecomes a facade over the envelope core, and every value is bound to a stable name for where it is stored.What Changed
secrets_envelopegainsseal_field/open_field(formatfe1.),open_unbound_legacy(read-only) andseal_field's binding. The key is HKDF-derived from the root key (vault idfield-encryption). The AAD kind isfield-value, distinct from thesecret-valueandwrapped-dekkinds and length-prefixed by the existing_aad.field_encryptionis a facade.encrypt_field(plaintext, *, context)anddecrypt_field(ciphertext, *, context)makecontextrequired, so no caller can forget the binding.AUTOBOT_FIELD_ENCRYPTION_KEYis set.FieldDecryptionError, naming the context and never the value.seal_tagged/open_tagged/is_plaintextreplace theenc:-prefix helper that Telegram, WhatsApp and the SSO helpers each carried separately.companiesset and test) and outbound sync (scheduler/event worker)organization:<uuid>:external_pm_configoutbound_sync.seal_pm_config/open_pm_config, and the id is normalised to one UUID spelling.redis:<key name>redis:<key name>sso_provider:<id>:<field>None, so the config view showed "not configured", which invites a save over the credential. They now raise.repo_tests/one_aead_core_17981_test.pyis AST-based. It fails on a new cipher user inautobot_shared, its pending list (legacy_secret_keys,passphrase_encryption) can only shrink, it has a prose-vs-code contrast fixture, and an instrument check confirms it still sees the canonical core. It declares a reach floor (non-test source must be at least 50% ofautobot_shared; measured at 63%), and its scope is recorded in_reach_roots_record.pyandreach_scope_claim_17844_test.py.SLM_ENCRYPTION_KEY/SLM_SECRET_KEY.companies.pyshrank by 4 lines, and its size ceiling is lowered to 1605.Verification
Run on Python 3.14 (the CI-parity venv). The default 3.10 cannot import the Telegram module because it needs
StrEnum:Per route family:
FieldDecryptionError;The Telegram test now uses real encryption with a test root key instead of stubbing
encrypt_field.A code-reviewer pass found no blocking issue. Its findings were applied: the WhatsApp 503, the restored plaintext warning, UUID normalisation in the context, and the guard's instrument check.
Risks
AUTOBOT_FIELD_ENCRYPTION_KEYby hand keeps reading its old values for as long as the key stays set. New saves move to the root key. If the key is removed before every value has been re-saved, those values raise a named error instead of decrypting. This is visible, not silent.passphrase_encryptionwith no AAD, the legacy Fernet stores, compliance_manager, the SLMagentsFernet, and the infrastructure secrets tool), plus retiring the SSOenc:script. Nothing reads what that script writes; SSO secrets live in the vault.Model Used
Claude Opus 5.5 (
claude-opus-5-5)Issue Link
Refs #17981. These criteria are delivered:
field_encryption;autobot_sharedguard.The wider cipher class is still open on the issue's list, so this PR does not close it.
🤖 Generated with Claude Code