Code review 2026-12-02 WP1: Trust boundary and audit durability #152

Closed
opened 2026-12-02 16:06:52 -05:00 by dohertj2 · 1 comment
Owner

From the 2026-12-02 full code review (commit 28b6651a).

  • Findings: docs/plans/2026-12-02-full-code-review.md
  • Plan: docs/plans/2026-12-02-full-code-review-remediation.md → WP1
Task Findings Change Verify
1.1 CMN-1 Add a VisitMemberBindingExpression override to HardeningWalker. It applies the ReflectionGatewayMembers check to ?.. Add CreateDelegate to the gateway members. Regression tests: the ?. form of every existing .-form rejection test must also be rejected. Include the probe script from the report.
1.2 CMN-2 Deny the System.AppDomain assembly-loading members. ScriptTrustValidator tests.
1.3 CMN-5 Key TrustVerdictCache on (code, extraReferences digest, degraded flag). Unit test.
1.4 DEP-1, MGT-1, TPL-3 Fix the shared root cause. Add IAuditService.LogAndSaveAsync. It stays best-effort: it swallows and logs its own failure. Switch every post-save audit call site in the report to it: DeploymentService, ArtifactDeploymentService, InstanceService, and the ManagementActor API-key, shared-schema, ES-method and move-connection handlers. Then grep for any other LogAsync that follows a final save. One real-context test per family asserting that the AuditLogEntries row exists. The current mocks only check LogAsync was called. Live-check on the rig: disable/enable/delete an instance and run Deploy Artifacts, and confirm the rows appear.
1.5 MGT-3, MGT-4 Bundle export of secret-bearing config (SMTP/SMS/ES credentials) requires Administrator. Scrub the reply of data-connection move. Update the authz matrix test. Unit test for the scrubbed reply.
1.6 MGT-2, UI-5 Audit query/export/tree and the Audit Log grid scope by site identifier, not by the numeric id. Fix the execution-tree scope comparison. Scoped-caller tests on both surfaces.
1.7 UI-7, UI-9, UI-10 Push the site-scope filter (and the Secured Writes status filter) into the server query so it runs before paging. Scope the Notification KPI breakdown. Paging tests with mixed-site data.
1.8 CDB-1 Encrypt the data-connection protocol JSON in deployed snapshots and pending rows (Data Protection, as with other secrets). Write a one-time migration that re-protects existing rows. Round-trip test. Check the rig DB for no plaintext after the migration. Needs a migration and a QA/DEV deploy gate.
From the 2026-12-02 full code review (commit 28b6651a). - Findings: `docs/plans/2026-12-02-full-code-review.md` - Plan: `docs/plans/2026-12-02-full-code-review-remediation.md` → WP1 | Task | Findings | Change | Verify | |---|---|---|---| | 1.1 | CMN-1 | Add a `VisitMemberBindingExpression` override to `HardeningWalker`. It applies the `ReflectionGatewayMembers` check to `?.`. Add `CreateDelegate` to the gateway members. | Regression tests: the `?.` form of every existing `.`-form rejection test must also be rejected. Include the probe script from the report. | | 1.2 | CMN-2 | Deny the `System.AppDomain` assembly-loading members. | `ScriptTrustValidator` tests. | | 1.3 | CMN-5 | Key `TrustVerdictCache` on (code, extraReferences digest, degraded flag). | Unit test. | | 1.4 | DEP-1, MGT-1, TPL-3 | **Fix the shared root cause.** Add `IAuditService.LogAndSaveAsync`. It stays best-effort: it swallows and logs its own failure. Switch every post-save audit call site in the report to it: `DeploymentService`, `ArtifactDeploymentService`, `InstanceService`, and the `ManagementActor` API-key, shared-schema, ES-method and move-connection handlers. Then grep for any other `LogAsync` that follows a final save. | One real-context test per family asserting that the `AuditLogEntries` row exists. The current mocks only check `LogAsync` was called. Live-check on the rig: disable/enable/delete an instance and run Deploy Artifacts, and confirm the rows appear. | | 1.5 | MGT-3, MGT-4 | Bundle export of secret-bearing config (SMTP/SMS/ES credentials) requires Administrator. Scrub the reply of `data-connection move`. | Update the authz matrix test. Unit test for the scrubbed reply. | | 1.6 | MGT-2, UI-5 | Audit query/export/tree and the Audit Log grid scope by site **identifier**, not by the numeric id. Fix the execution-tree scope comparison. | Scoped-caller tests on both surfaces. | | 1.7 | UI-7, UI-9, UI-10 | Push the site-scope filter (and the Secured Writes status filter) into the server query so it runs before paging. Scope the Notification KPI breakdown. | Paging tests with mixed-site data. | | 1.8 | CDB-1 | Encrypt the data-connection protocol JSON in deployed snapshots and pending rows (Data Protection, as with other secrets). Write a one-time migration that re-protects existing rows. | Round-trip test. Check the rig DB for no plaintext after the migration. **Needs a migration and a QA/DEV deploy gate.** |
dohertj2 added the type:review-findingpriority:p0 labels 2026-12-02 16:06:52 -05:00
Author
Owner

Fixed on main (pushed, 922021c4). Plan: docs/plans/2026-12-02-full-code-review-remediation.md (see its Outcome section).

All 8 tasks done. Highlights:

  • 1.1: ?. member bindings and Delegate.CreateDelegate are now checked by the trust gate. The related using static bare-name hole is closed too.
  • 1.4: new IAuditService.LogAndSaveAsync (best-effort); all post-save audit sites switched, plus AreaService/SiteService and the DeployReconciled row found by grep. A duplicate Create Instance audit row was removed.
  • 1.5: exporting a bundle that carries secrets needs Administrator (authz matrix updated); data-connection move replies scrubbed.
  • 1.8: done without an EF migration, because Data Protection keys can't be reached from SQL. A startup backfill re-protects plaintext rows, and reads still accept plaintext.

Rig:

  • Deployed snapshots: 10/10 encrypted, 0 plaintext; a redeploy fetches the encrypted config.
  • AuditLogEntries rows appear for disable, enable, artifact deploy and API key create/delete.

QA/DEV: both central nodes must be upgraded together; see #160.

Commits:

  • b065ffa9 test(integration): share one key ring across the fetch harness contexts (CDB-1, WP1 task 1.8)
  • d4e13d3a fix(config-db): encrypt deployment configuration JSON at rest (CDB-1, WP1 task 1.8)
  • 5a052c63 fix(ui): apply site scope and the history status filter in the server query, before paging (UI-7, UI-9, UI-10, WP1 task 1.7)
  • 2162fad8 fix(audit): scope audit reads by site identifier, not numeric site id (MGT-2, UI-5, WP1 task 1.6)
  • 8c5d70f6 fix(transport): secret-bearing bundle export needs Administrator; scrub data-connection move reply (MGT-3, MGT-4, WP1 task 1.5)
  • 5ca998dc fix(audit): persist config audit rows written after the final save (DEP-1, MGT-1, TPL-3, WP1 task 1.4)
  • 5469ece0 fix(script-analysis): key the trust verdict cache on every verdict input (CMN-5, WP1 task 1.3)
  • a9549fbc fix(script-analysis): forbid System.AppDomain in scripts (CMN-2, WP1 task 1.2)
  • 29192eeb fix(script-analysis): inspect ?. member bindings and CreateDelegate in the trust gate (CMN-1, WP1 task 1.1)
  • 18311eb3 test(deployment): race-delete test asserts LogAndSaveAsync (merge fix)

Deploying to QA and DEV is tracked in #160. Closing.

Fixed on `main` (pushed, `922021c4`). Plan: `docs/plans/2026-12-02-full-code-review-remediation.md` (see its Outcome section). All 8 tasks done. Highlights: - **1.1:** `?.` member bindings and `Delegate.CreateDelegate` are now checked by the trust gate. The related `using static` bare-name hole is closed too. - **1.4:** new `IAuditService.LogAndSaveAsync` (best-effort); all post-save audit sites switched, plus `AreaService`/`SiteService` and the DeployReconciled row found by grep. A duplicate Create Instance audit row was removed. - **1.5:** exporting a bundle that carries secrets needs Administrator (authz matrix updated); `data-connection move` replies scrubbed. - **1.8:** done without an EF migration, because Data Protection keys can't be reached from SQL. A startup backfill re-protects plaintext rows, and reads still accept plaintext. **Rig:** - Deployed snapshots: 10/10 encrypted, 0 plaintext; a redeploy fetches the encrypted config. - `AuditLogEntries` rows appear for disable, enable, artifact deploy and API key create/delete. **QA/DEV:** both central nodes must be upgraded together; see #160. **Commits:** - b065ffa9 test(integration): share one key ring across the fetch harness contexts (CDB-1, WP1 task 1.8) - d4e13d3a fix(config-db): encrypt deployment configuration JSON at rest (CDB-1, WP1 task 1.8) - 5a052c63 fix(ui): apply site scope and the history status filter in the server query, before paging (UI-7, UI-9, UI-10, WP1 task 1.7) - 2162fad8 fix(audit): scope audit reads by site identifier, not numeric site id (MGT-2, UI-5, WP1 task 1.6) - 8c5d70f6 fix(transport): secret-bearing bundle export needs Administrator; scrub data-connection move reply (MGT-3, MGT-4, WP1 task 1.5) - 5ca998dc fix(audit): persist config audit rows written after the final save (DEP-1, MGT-1, TPL-3, WP1 task 1.4) - 5469ece0 fix(script-analysis): key the trust verdict cache on every verdict input (CMN-5, WP1 task 1.3) - a9549fbc fix(script-analysis): forbid System.AppDomain in scripts (CMN-2, WP1 task 1.2) - 29192eeb fix(script-analysis): inspect ?. member bindings and CreateDelegate in the trust gate (CMN-1, WP1 task 1.1) - 18311eb3 test(deployment): race-delete test asserts LogAndSaveAsync (merge fix) Deploying to QA and DEV is tracked in #160. Closing.
Sign in to join this conversation.