Skip to content

fix(audit): redact NotificationChannel secret config fields in audit log#200

Merged
TerrifiedBug merged 2 commits intomainfrom
fix/audit-redact-channel-secrets
Apr 28, 2026
Merged

fix(audit): redact NotificationChannel secret config fields in audit log#200
TerrifiedBug merged 2 commits intomainfrom
fix/audit-redact-channel-secrets

Conversation

@TerrifiedBug
Copy link
Copy Markdown
Owner

@TerrifiedBug TerrifiedBug commented Apr 28, 2026

Summary

Two related post-#198/#199 fixes:

1. Audit log redaction (primary) — audit-log side channel that survived the encrypt-at-rest fix in #198. The middleware sanitizer (src/server/middleware/audit.ts) only redacted exact-key matches (password, token, secret, …). Channel-config secret sub-fields (hmacSecret, smtpPass, integrationKey, webhookUrl) slipped through, so AuditLog.metadata stored plaintext webhook signing secrets, SMTP passwords, PagerDuty routing keys, and webhook URLs (which often embed auth tokens) for every `notificationChannel.created` / `.updated` / `.deleted` action.

2. Settings sidebar entry#199 relocated Outbound Webhooks back to `/settings/webhooks` and added an overview card, but never wired it into `settings-sidebar-nav.tsx`. The page was reachable via the overview card but missing from the sidebar.

Changes

  • Add `hmacSecret`, `smtpPass`, `integrationKey`, `webhookUrl` to `SENSITIVE_KEYS`.
  • Extract `SENSITIVE_KEYS` / `sanitizeInput` / `computeDiff` into `audit-sanitize.ts` so they can be unit-tested without pulling the full Prisma + NextAuth runtime through the middleware barrel. `audit.ts` re-exports them.
  • Add unit tests: top-level redaction, nested channel config, arrays of channels, primitive passthrough, null/undefined, presence of the new keys.
  • Add Outbound Webhooks entry to the settings sidebar (Organization group, Webhook icon, non-super-admin, demo-hidden).

Test plan

  • `pnpm exec vitest run src/server/middleware/tests/audit.test.ts` — 6/6 pass
  • Audit suite (router + service tests) — 80/80 pass
  • `pnpm lint` — 0 errors (warnings unrelated)
  • `pnpm exec tsc --noEmit` — clean
  • Manually verify Outbound Webhooks visible in settings sidebar under Organization

@github-actions github-actions Bot added the fix label Apr 28, 2026
The audit middleware sanitizer (src/server/middleware/audit.ts) only
redacted exact-key matches for password/token/secret/etc. Channel-config
secret fields slipped through unredacted, causing AuditLog.metadata to
store plaintext webhook signing secrets, SMTP passwords, PagerDuty
routing keys, and webhook URLs (which often embed auth tokens) on every
notificationChannel.created / .updated / .deleted action.

This undermined the encrypt-at-rest fix landed in PR #198, which closed
plaintext storage in the channel.config column itself but left the
audit-log side channel open.

Changes:
- Add hmacSecret, smtpPass, integrationKey, webhookUrl to SENSITIVE_KEYS.
- Extract SENSITIVE_KEYS / sanitizeInput / computeDiff into a separate
  audit-sanitize module so they can be unit-tested without pulling in
  the full Prisma + NextAuth runtime via the middleware barrel.
- Add unit tests covering top-level redaction, nested config redaction,
  arrays of channels, primitive passthrough, null/undefined, and
  presence of the new keys in the set.
@TerrifiedBug TerrifiedBug force-pushed the fix/audit-redact-channel-secrets branch from 53d5be0 to 4c5a770 Compare April 28, 2026 12:21
PR #199 wired the page route and the settings-overview card but left
settings-sidebar-nav.tsx untouched, so the page was unreachable from
the sidebar. Add it to the Organization group alongside Service
Accounts and AI (other team-level integrations) with the Webhook icon.
Non-super-admin so team editors can manage event subscriptions, demo-
hidden to match other integration entries.
@TerrifiedBug TerrifiedBug force-pushed the fix/audit-redact-channel-secrets branch from 4c5a770 to 71b025a Compare April 28, 2026 12:21
@github-actions github-actions Bot added fix and removed fix labels Apr 28, 2026
@TerrifiedBug TerrifiedBug merged commit 2b9533f into main Apr 28, 2026
7 checks passed
@TerrifiedBug TerrifiedBug deleted the fix/audit-redact-channel-secrets branch April 28, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant