Skip to content

[Feature] Automated incident response & circuit-breaker for critical pool security alerts #254

Description

@Sendi0011

Summary

The security monitoring system (/api/admin/security/scan and the security-scan cron) already detects and persists critical alerts, but nothing acts on them automatically. Build an automated incident-response / circuit-breaker layer that escalates critical alerts into safe, reversible recovery actions.

Today the scan returns alerts (severity: "critical", etc.) and writes them to the alert table, but no code path ever invokes the contracts' existing pause/emergency_withdraw primitives or flips a pool to the paused status.

Requirements

  1. Critical-alert → auto-pause — when a scan flags a configured threshold of critical alerts for a pool, automatically invoke the contract's pause function (rotational contract: fn pause) and persist the paused status + reason to Supabase.
  2. Incident record — create an incidents table (pool, trigger, severity, created_by_scan, timestamps, resolution) so every automatic action is auditable via the existing admin audit log (/api/admin/audit-log).
  3. Escalation & cooldown — add a cooldown to prevent pause-flap (e.g., no auto-pause more than N times per pool per window), and notify admins via the existing notification/push system.
  4. Admin review & recovery — an admin endpoint to review a paused pool, mark the incident resolved, and (optionally) resume it; keep emergency_withdraw admin-only and manual, never automatic.
  5. Dry-run mode — a config flag to run in dry-run (log-only) before enabling auto-action, with the scan result reporting whether action would have fired.

Notes / context

  • Contract primitives already exist: rotational/src/lib.rs has pause, emergency_withdraw, migrate. Reuse them — do not change contract logic unless required.
  • Follow /api/cron/security-scan/route.ts and /api/admin/security/scan/route.ts conventions for auth (server-side checks + CRON_SECRET) and rate limiting.
  • Add unit tests for the cooldown/pause-flap logic and the dry-run path, mirroring existing route.test.ts patterns.

Acceptance criteria

  • Critical alerts can automatically pause the affected pool (with dry-run toggle)
  • Every auto-action produces an auditable incident record
  • Cooldown prevents pause-flap; admins can review, resolve, and resume
  • Unit tests cover cooldown, dry-run, and escalation logic
  • Linting, format, and all CI checks pass

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignfeatureNew functionality to addfrontendhigh-complexityLarge scope, multiple systems/files. Needs planningpriority: highMajor impact, breaks key feature. fix next after P0smart-contract

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions