Repository navigation
feat(enterprise/dbcrypt): encrypt workspace secrets - #30249
Conversation
a970b35 to
daf45ed
Compare
87d458e to
e66489e
Compare
e66489e to
d8181da
Compare
35c7bbb to
e214652
Compare
d8181da to
23c9372
Compare
e214652 to
f9db4b2
Compare
e4c9015 to
192d209
Compare
88c4bfd to
21dacb4
Compare
21dacb4 to
f21bd7c
Compare
a7199ed to
89ea493
Compare
|
/coder-agents-review |
|
Chat: Review posted | View chat Review history
deep-review v0.13.0 | Round 1 | Last posted: Round 1, 18 findings (1 P1, 1 P2, 5 P3, 4 P4, 7 Nit), REQUEST_CHANGES. Review Finding inventoryFindings
Contested and acknowledgedRound logRound 1Full panel (round 1). Netero first pass: 1 P2, 1 P3, 1 P4, 2 Notes, no P0, so panel proceeded. Panel: ging-go, ryosuke, knuckle, kurapika, pariston, mafuuu, bisky, gon, leorio, hisoka, mafu-san, wildcard kite (12; multi-domain target 9-12: Go plus SQL, security-sensitive encryption). Orchestrator verified the copy-forward in #30250 ( About deep-reviewCRF = Coder Review Finding (P0-P4, Nit, Note)
|
f21bd7c to
2eb9e1b
Compare
Documentation CheckUpdates Needed
Automated review via Coder Agents |
There was a problem hiding this comment.
This PR encrypts workspace_secrets.value through dbcrypt and adds the table to dbcrypt rotate, decrypt, and delete. Findings: 1 P1, 1 P2, 5 P3, 4 P4, 7 Nit.
The wrapper set is complete: every query that reads or writes value is wrapped, and GetWorkspaceSecretsHistory selects no value. The P1 is the interaction between encryption and the per-build byte caps in the enforce_workspace_secrets_per_build_limits trigger.
Out of scope (needs a ticket or explicit acceptance by a human):
enterprise/dbcrypt/dbcrypt.go:1038: about 20 hand-written decrypt loops over slices repeat the same shape; each new encrypted table adds another copy.coderd/database/migrations/000509_user_secrets_limits.up.sql:103:user_secretscaps also measure stored bytes and runBEFORE INSERT OR UPDATE, sodbcrypt rotatemay stop with a check violation at a user whose plaintext env secrets exceed about 18.4 KiB (inferred, not run).coderd/database/migrations/000613_workspace_secrets.up.sql:124: the per-build trigger runsBEFORE INSERTonly, so anyUPDATEthat rewritesvalueskips the caps.enterprise/dbcrypt/cliutil_test.go:1815: the lifecycle test's table list is maintained by hand and already misseschat_mcp_servers; deriving it from foreign keys todbcrypt_keyswould keep it current.enterprise/cli/server_dbcrypt.go:201: the delete prompt already omitted user secrets, Git SSH keys, MCP server headers, and AI provider keys, so operators confirm without the full list of what is destroyed.docs/admin/security/database-encryption.md:22: the encrypted-fields list already omitted theai_providersand AI provider key columns.enterprise/dbcrypt/cliutil.go:517:sqlDeleteEncryptedUserTokensand theDecryptdoc describe only user tokens, but both cover many more tables.
Notes:
enterprise/dbcrypt/cliutil.go:531:dbcrypt deletesetscleared_aton the latest build's live rows, socleared_atno longer means only "superseded by a later build" as the column comment in 000613 says, and history readers cannot tell the two apart.
docs/admin/security/database-encryption.md:22
P3 [CRF-8] The list of encrypted fields does not include workspace_secrets.value, and no PR in this stack adds it. (Gon, Leorio, Mafu-san, Mafuuu)
Operators use this list to see what rotate, decrypt, and delete touch. #30252 changes only docs/admin/security/secrets.md. Add - `workspace_secrets.value` here, in the PR that adds the encryption.
🤖
enterprise/cli/server_dbcrypt.go:201
P3 [CRF-9] The dbcrypt delete confirmation prompt does not say the command now clears workspace secret values. (Leorio, Mafu-san)
After confirming, running workspaces lose the secrets in their agent manifest until a build supplies them again, and the prompt lists only OAuth and Git auth tokens. Add a line such as - Encrypted workspace secret values (rows are kept; values are cleared), and update database-encryption.md:185, which says the command "will delete all encrypted user tokens".
🤖
enterprise/dbcrypt/cliutil_test.go:1815
P3 [CRF-11] TestFullLifecycleAllHandledTables does not seed a workspace_secrets row, so its doc comment ("seeds one row in every table Rotate/Decrypt/Delete actually loop over") is false after this PR. (Bisky)
With workspaceSecrets = nil inserted before the decrypt loop, this test passes and only TestDecryptWorkspaceSecrets fails. Seed a workspace secret through cryptDBA and assert it is under cipherB after rotate and plaintext after decrypt.
🤖
enterprise/dbcrypt/cliutil.go:554
Nit [CRF-10] The Delete doc comment says it "deletes all user tokens", and after this PR it also clears workspace secret values in place. (Leorio)
Suggested: "Delete removes or clears every encrypted value and revokes all ciphers. Rows in gitsshkeys, ai_providers, and workspace_secrets are kept with their encrypted columns cleared; rows in the other tables are deleted."
🤖
🤖 This review was automatically generated with Coder Agents.
2eb9e1b to
d9f1c3b
Compare
0e26c17 to
97253a3
Compare
e1c97c8 to
8e4631d
Compare
4999a47 to
8e32030
Compare
8e4631d to
6ddd097
Compare
8e32030 to
4c6093f
Compare
4c6093f to
a72ce46
Compare
9a091b9 to
f2c82bf
Compare
a72ce46 to
31c6268
Compare
f2c82bf to
7aef110
Compare
31c6268 to
84cc16c
Compare
84cc16c to
22b2580
Compare
Resolved all feedback

Encrypts workspace secret values at rest with the existing database encryption keys, and adds workspace secrets to the
coder server dbcryptcommands. Part of RELAY-7.Stack (design decisions in #30248)
dbcrypt rotateanddbcrypt decryptre-encrypt or decrypt workspace secrets, 1,000 at a time.dbcrypt deleteclears workspace secret values instead of deleting the rows, so build history is kept.Implementation details
InsertWorkspaceSecretandUpdateEncryptedWorkspaceSecretValueencrypt, andListActiveWorkspaceSecretsandGetWorkspaceSecretsdecrypt. Only live rows reach these paths, so there is no NULL handling.GetWorkspaceSecretsbyid, so memory is bounded on large deployments. Only live rows are listed, about one set per workspace.Created by Coder Agents on behalf of @Emyrk.