Emergency procedures and tools for handling security incidents
This directory contains incident response procedures and emergency tools for DSS strategies. Essential for DSS-9.4 (Gold certification).
Incident response requires:
- ✅ Clear procedures - Step-by-step playbooks
- ✅ Emergency tools - Fast response capabilities
- ✅ Communication - Alert all stakeholders
- ✅ Documentation - Complete incident records
Comprehensive guide for handling security incidents.
Covers:
- Incident severity levels (CRITICAL, HIGH, MEDIUM, LOW)
- Step-by-step response procedures
- Emergency contacts
- Incident documentation templates
- Post-incident review process
Use Cases:
- Active exploit in progress
- Suspicious activity detected
- Failed operations
- Routine issues
Immediately pause strategy in emergency situations.
Features:
- Fast execution with high gas price
- Multi-channel alerts (Slack, Telegram, Discord)
- Incident logging
- Role verification
Usage:
# Execute emergency pause
ts-node emergency-pause.ts "Reason for pause"
# Example
ts-node emergency-pause.ts "Suspicious transactions detected"Active exploit or immediate threat:
# 1. PAUSE IMMEDIATELY
cd examples/operational/incident-response
ts-node emergency-pause.ts "Active exploit detected"
# 2. Alert team (automatic via script)
# 3. Assess situation
npm run monitor:health
npm run monitor:events
# 4. Follow playbook procedures
# See INCIDENT-RESPONSE-PLAYBOOK.mdSuspicious activity or high risk:
# 1. Verify the alert
npm run monitor:health
# 2. Assess risk
# Review recent transactions
# Check oracle prices
# Verify weights
# 3. Decide on action
# If confirmed: execute emergency pause
ts-node emergency-pause.ts "Suspicious activity confirmed"Follow procedures in playbook:
- Check logs
- Identify cause
- Fix issue
- Verify resolution
# Quick pause
ts-node emergency-pause.ts "Reason"
# With custom RPC
RPC_URL=https://mainnet.infura.io/v3/YOUR_KEY \
ts-node emergency-pause.ts "Reason"# Check strategy status
npm run monitor:health
# Check specific metrics
cast call $STRATEGY_ADDRESS "paused()"
cast call $STRATEGY_ADDRESS "calculateWeights()"# After incident is resolved
cast send $STRATEGY_ADDRESS "unpause()" \
--private-key $GUARDIAN_KEY \
--rpc-url $RPC_URL# Get recent transactions
cast logs --address $STRATEGY_ADDRESS \
--from-block -1000 \
--rpc-url $RPC_URL
# Decode transaction
cast tx $TX_HASH --rpc-url $RPC_URLCreate contacts.json:
{
"guardians": [
{
"name": "Alice",
"phone": "+1-555-0101",
"email": "alice@example.com",
"role": "Primary Guardian"
}
],
"multisig_signers": [
{
"name": "Bob",
"phone": "+1-555-0102",
"address": "0x..."
}
],
"external": {
"auditor": "security@auditor.com",
"insurance": "claims@insurance.com"
}
}Configure in .env:
# Slack
SLACK_WEBHOOK_URL=https://hooks.slack.com/...
# Telegram
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id
# Discord
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...
# Email (via SendGrid)
SENDGRID_API_KEY=your_api_key
ALERT_EMAIL=alerts@yourdomain.com# Use template from playbook
cp INCIDENT-RESPONSE-PLAYBOOK.md incident-report-$(date +%Y%m%d).md
# Fill in:
# - Summary
# - Timeline
# - Root cause
# - Impact
# - Response actions
# - Lessons learnedAll emergency pauses are automatically logged to:
logs/incident-{timestamp}.log
# Post-Mortem: [Incident Title]
## What Happened
[Brief description]
## Timeline
- HH:MM - Event 1
- HH:MM - Event 2
## Root Cause
[Technical explanation]
## Impact
- Funds at risk: $X
- Actual loss: $Y
- Downtime: Z hours
## What Went Well
- [Item]
## What Could Be Improved
- [Item]
## Action Items
- [ ] [Preventive measure]
- [ ] [Process improvement]# 1. Simulate incident
# 2. Execute emergency pause (on testnet)
# 3. Time the response
# 4. Review and improve
# Testnet drill
RPC_URL=https://goerli.infura.io/v3/YOUR_KEY \
STRATEGY_ADDRESS=0x... \
ts-node emergency-pause.ts "Monthly drill"Target response times:
- Detection to alert: < 1 minute
- Alert to pause: < 5 minutes
- Total response: < 15 minutes
After each incident or drill:
- Review what worked
- Identify improvements
- Update playbook
- Train team
Incident response helps achieve:
| Requirement | Tool/Procedure | Level |
|---|---|---|
| DSS-9.4.1: Incident Procedures | INCIDENT-RESPONSE-PLAYBOOK.md | Gold |
| DSS-9.4.2: Emergency Pause | emergency-pause.ts | Gold |
| DSS-9.4.3: Communication | Multi-channel alerts | Gold |
| DSS-9.4.4: Documentation | Incident logging | Gold |
Check:
- Guardian has GUARDIAN_ROLE
- Guardian wallet has ETH for gas
- RPC connection is working
- Strategy is not already paused
Debug:
# Check role
cast call $STRATEGY_ADDRESS \
"hasRole(bytes32,address)" \
$(cast keccak "GUARDIAN_ROLE") \
$GUARDIAN_ADDRESS
# Check balance
cast balance $GUARDIAN_ADDRESS
# Check pause status
cast call $STRATEGY_ADDRESS "paused()"Check:
- Webhook URLs are correct
- Network connectivity
- API tokens are valid
Test:
# Test Slack
curl -X POST $SLACK_WEBHOOK_URL \
-H 'Content-Type: application/json' \
-d '{"text":"Test alert"}'Possible reasons:
- Only guardian can unpause
- Timelock delay not passed
- Contract issue
Solution:
# Check who can unpause
cast call $STRATEGY_ADDRESS \
"hasRole(bytes32,address)" \
$(cast keccak "GUARDIAN_ROLE") \
$YOUR_ADDRESS- Review Incident Response Playbook
- Set up Monitoring
- Configure Alert Channels
- Test emergency procedures monthly