Keep a deleted-but-held account's audit and journal records under the hold #381

Merged
jcoffey-dev merged 1 commits from fix/legal-hold-audit-purge into main 2026-11-11 19:43:28 +00:00
Owner

What

Second finding from the legal-hold audit, same root shape as #377 (a deleted-but-kept account drops out of the live-account scans holds rely on), different code path.

held_accounts() — the set the retention purges keep records for — scanned only live accounts. So an account deleted while undelete still kept it (the case a hold is placed for) was absent:

  • audit_purge consults held_accounts() directly, so a deleted-but-held account's audit trail was purged once past the 90-day floor, while the hold was active.
  • The journal purge augmented the set at its own call site, so it was affected only in the narrower case where the hold covered no live account at all.

Fix

held_accounts() now folds in the accounts undelete keeps that a hold covers (through the domain and tenant their retained record carries), so every purge that trusts it — audit and journal — keeps a deleted-but-held account's records. The journal call site's now-redundant augmentation is removed, leaving one source of truth. +9/-8 across crates/common/src/hold.rs and crates/services/src/task_manager/maintenance.rs.

Clean room

Worked only against inbuxa's own tree — the held_accounts/journal-purge hooks in crates/common and crates/services, and the existing legal_hold test. No Stalwart Enterprise-licensed source was read.

Testing

legal_hold_tests now also asserts a deleted-but-held custodian is present in held_accounts() — the gate audit and journal purges use. Verified locally (RED without the fix, GREEN with it). CI does not run the #[ignore]d system suite, so this was checked locally.

Run: RUST_MIN_STACK=16777216 STORE=RocksDb cargo test -p tests legal_hold_tests -- --ignored

Pairs with #377; both are items in one compliance/data-loss advisory (spoliation under an active legal hold) — advisory + release notes to follow.

## What Second finding from the legal-hold audit, same root shape as #377 (a deleted-but-kept account drops out of the live-account scans holds rely on), different code path. `held_accounts()` — the set the retention purges keep records for — scanned only live accounts. So an account deleted while undelete still kept it (the case a hold is placed for) was absent: - `audit_purge` consults `held_accounts()` directly, so a deleted-but-held account's **audit trail** was purged once past the 90-day floor, while the hold was active. - The journal purge augmented the set at its own call site, so it was affected only in the narrower case where the hold covered no live account at all. ## Fix `held_accounts()` now folds in the accounts undelete keeps that a hold covers (through the domain and tenant their retained record carries), so every purge that trusts it — audit and journal — keeps a deleted-but-held account's records. The journal call site's now-redundant augmentation is removed, leaving one source of truth. +9/-8 across `crates/common/src/hold.rs` and `crates/services/src/task_manager/maintenance.rs`. ## Clean room Worked only against inbuxa's own tree — the `held_accounts`/journal-purge hooks in `crates/common` and `crates/services`, and the existing `legal_hold` test. No Stalwart Enterprise-licensed source was read. ## Testing `legal_hold_tests` now also asserts a deleted-but-held custodian is present in `held_accounts()` — the gate audit and journal purges use. Verified locally (RED without the fix, GREEN with it). CI does not run the `#[ignore]`d system suite, so this was checked locally. Run: `RUST_MIN_STACK=16777216 STORE=RocksDb cargo test -p tests legal_hold_tests -- --ignored` Pairs with #377; both are items in one compliance/data-loss advisory (spoliation under an active legal hold) — advisory + release notes to follow.
jcoffey-dev added 1 commit 2026-11-11 19:28:13 +00:00
Keep a deleted-but-held account's audit and journal records under the hold
ci / fork-checks (pull_request) Skipped
ci / build (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 9m6s
c884bad555
held_accounts() scanned only live accounts, so an account deleted while
undelete still kept it -- the case a legal hold is placed for -- was absent
from the set the retention purges trust. audit_purge consults it directly,
so a deleted-but-held account's audit trail was purged once past the 90-day
floor while the hold was active. The journal purge augmented the set at its
own call site, so it was affected only when a hold covered no live account.

held_accounts() now folds in the accounts undelete keeps that a hold covers,
through the domain and tenant their retained record carries, so every purge
that trusts it keeps a deleted-but-held account's records. The journal call
site's now-redundant augmentation is removed, leaving one source of truth.

Covered by legal_hold_tests: a deleted-but-held custodian is now present in
held_accounts() (LH-6, AU-7).
jcoffey-dev merged commit aee4874246 into main 2026-11-11 19:43:28 +00:00
jcoffey-dev deleted branch fix/legal-hold-audit-purge 2026-11-11 19:43:28 +00:00
jcoffey-dev referenced this issue from a commit 2026-11-11 22:53:08 +00:00
Sign in to join this conversation.