Security Playbooks
Overview
Security playbooks are step-by-step operational procedures for handling security incidents, planned maintenance, and emergency scenarios. These playbooks ensure consistent, repeatable responses to common security situations in StockEase Frontend.
Playbooks Index
1. Token Revocation & Forced Logout
π revoke-tokens.md
Purpose: Handle forced user logout scenarios, revoke compromised tokens, and manage session termination.
Key Topics:
- When to revoke tokens (security incidents, account changes, policy updates)
- Token revocation methods (server-side blacklist, distributed cache, client-only)
- Current logout implementation vs. recommended improvements
- Batch token revocation for incidents
- Monitoring and verification
- Emergency response procedures
Use Cases:
Scenario: User reports account compromise
ββ Follow: Token Revocation & Forced Logout
ββ Action: Revoke all tokens for user
ββ Result: User forced to re-authenticate
ββ Follow-up: Password reset + security audit
Current Implementation:
- β Client-side logout (remove token from localStorage)
- β Server-side blacklist (not implemented - recommended)
- β Batch revocation (not implemented - needed for incidents)
Recommended Actions:
- Implement server-side token blacklist (Redis)
- Create revocation endpoint for manual/programmatic revocation
- Setup batch revocation for security incidents
- Add audit logging for all revocations
2. Key Rotation & Rollout
π key-rotation.md
Purpose: Plan and execute JWT signing key rotations, maintain availability, and recover from incidents.
Key Topics:
- Why rotate keys (security, compliance, maintenance)
- Current key architecture (HS256, environment variables)
- Three rotation strategies:
- Immediate (emergency - key compromise)
- Graceful (planned - 3-4 week rollout)
- Rolling (continuous - 4 week rotation by cohort)
- Step-by-step rollout procedures
- Emergency rollback process
- Monitoring and metrics
- Key rotation schedule
Use Cases:
Scenario: Quarterly scheduled key rotation
ββ Follow: Key Rotation & Rollout
ββ Strategy: Graceful rotation (3-4 weeks)
ββ Timeline: Generate β Deploy dual-key β Monitor β Deprecate
ββ Result: All users migrated to new key
Scenario: Key compromise detected
ββ Follow: Key Rotation & Rollout (Immediate strategy)
ββ Timeline: Generate new key β Deploy β Force re-login
ββ Duration: < 1 hour
ββ Result: System secure, old tokens invalid
Current Implementation:
- β Automated rotation (not implemented)
- β Dual-key support (not implemented)
- β Rotation monitoring (not implemented)
Recommended Actions:
- Implement dual-key support in backend
- Create key rotation monitoring dashboard
- Schedule quarterly rotation (every 90 days)
- Setup automated alerts for key rotation events
Quick Reference: When to Use Which Playbook
| Situation | Playbook | Timeline | Impact |
|---|---|---|---|
| User forgot password | None (use login) | N/A | None |
| User requests logout | Token Revocation | Immediate | Minimal |
| Account compromise suspected | Token Revocation | < 5 min | User session ends |
| Admin revokes user access | Token Revocation | < 1 min | User forced to login |
| Security breach detected | Token Revocation (batch) | < 30 min | Multiple users affected |
| Quarterly maintenance | Key Rotation (graceful) | 3-4 weeks | Minimal (transparent) |
| Key leaked/compromised | Key Rotation (immediate) | < 1 hour | All users re-login |
| Post-incident analysis | Both | 24 hours | Documentation |
Security Incident Response Flow
Token Compromise Detected
Step 1: Detection & Assessment
ββ Token found in logs/breach
ββ Attacker using token observed
ββ Multiple accounts affected
ββ Severity: CRITICAL
Step 2: Immediate Actions (< 5 min)
ββ See: Token Revocation & Forced Logout
ββ Action: Batch revoke all affected tokens
ββ Result: Tokens immediately invalid
ββ Next: Force affected users to re-login
Step 3: Containment (< 30 min)
ββ Determine scope: How many users?
ββ Determine cause: How was token leaked?
ββ Isolate: Stop further leaks
ββ Notify: Alert security team
Step 4: Recovery (< 1 hour)
ββ See: Key Rotation & Rollout (Immediate strategy)
ββ Action: Rotate signing key if compromised
ββ Result: New tokens cannot be forged
ββ Verify: All old tokens invalid
Step 5: Follow-up (24 hours)
ββ Audit: How did it happen?
ββ Fix: Prevent future leaks
ββ Notify: Communicate with users
ββ Document: Post-incident review
Security Checklist for Operations Team
Daily
Weekly
Monthly
Quarterly
Playbook Activation Decision Tree
Security Event Detected
β
ββ Is it a token/session issue?
β β
β ββ YES: User logout, permission change, account suspension?
β β ββ USE: Token Revocation & Forced Logout
β β ββ Revoke user's tokens
β β ββ Force re-authentication
β β ββ Document in audit log
β β
β ββ NO: Signing key issue?
β β
β ββ YES: Key compromise suspected or scheduled rotation?
β β ββ USE: Key Rotation & Rollout
β β ββ Generate new key
β β ββ Deploy dual-key or immediate rollout
β β ββ Monitor migration
β β
β ββ NO: Unknown issue
β ββ ESCALATE: Call incident commander
β
ββ Execute selected playbook
ββ Document all actions
ββ Post-incident review
Communication Templates
User Notification: Forced Re-login
Subject: Security Update - Please Log In Again
Hi [User],
For your account security, we're requiring all users to log in again.
This is part of our ongoing security maintenance.
Actions needed:
1. Click "Logout" or close your browser
2. Visit https://stockease.com
3. Log in with your credentials
The re-login process takes < 1 minute.
If you have any issues, contact support@stockease.com
Thank you,
Security Team
Security Alert: Incident Response
Subject: URGENT - Security Incident Response
Hi Team,
A potential security incident has been detected and identified as [INCIDENT TYPE].
Status: [CONTAINED / IN PROGRESS / RESOLVED]
Timeline:
ββ [TIME] Detected
ββ [TIME] Containment actions started
ββ [TIME] Expected resolution
Impact:
ββ Affected users: [NUMBER]
ββ Service impact: [BRIEF DESCRIPTION]
ββ Data at risk: [YES/NO]
Actions taken:
- [ACTION 1]
- [ACTION 2]
- [ACTION 3]
Next steps:
- [NEXT STEP 1]
- [NEXT STEP 2]
Questions? Contact: security@stockease.com
Incident Commander: [NAME]
Tools & Resources
Monitoring Tools
// Key Rotation Monitoring
https://monitoring.stockease.com/dashboards/key-rotation
// Token Revocation Audit
https://logging.stockease.com/queries/token-revocation
// Authentication Metrics
https://metrics.stockease.com/auth/dashboardCommands Reference
# Check Redis for revoked tokens
redis-cli keys "revoked_*" | wc -l
# Decode JWT token
jwt decode --secret=$JWT_SECRET <token>
# Generate new signing key
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
# Monitor token verification errors
tail -f /var/log/stockease/auth.log | grep "VERIFICATION_ERROR"
# Check dual-key usage
curl https://api.stockease.com/metrics/auth/keysEscalation Contacts
Authentication Issue:
ββ Level 1: DevOps Team (ops@stockease.com)
ββ Level 2: Security Team (security@stockease.com)
ββ Level 3: CTO (cto@stockease.com)
Security Incident:
ββ Level 1: Security Team (security@stockease.com)
ββ Level 2: Incident Commander (on-call)
ββ Level 3: Executive Team (escalation list)
Key Compromise:
ββ Immediate: Page on-call security engineer
ββ Notify: Incident commander
ββ Execute: Key Rotation (Immediate strategy)
Playbook Exercises
Exercise 1: Quarterly Key Rotation
Objective: Test key rotation procedures
Duration: 4 weeks Environment: Production (with monitoring) Success Criteria:
Runbook: See Key Rotation & Rollout
Exercise 2: Emergency Token Revocation
Objective: Test emergency revocation procedures
Duration: 1 hour Environment: Staging (simulate production) Scenario: "Admin account compromised, revoke all admin tokens"
Success Criteria:
Runbook: See Token Revocation & Forced Logout
Exercise 3: Incident Simulation
Objective: Test full incident response
Duration: 2 hours Environment: Staging (full simulation) Scenario: "Signing key found in GitHub repo history"
Steps:
- Detect the compromise
- Execute Emergency Key Rotation
- Execute Batch Token Revocation
- Notify users
- Post-incident review
- Document lessons learned
Success Criteria:
Related Documentation
Authentication & Authorization
API Security
Frontend Security
Platform Security
Playbook Maintenance
Version Control
Last Updated: November 13, 2025
Version: 1.0
Maintained By: Security Team
Review Schedule: Quarterly
Change Log
2025-11-13 | v1.0 | Initial creation
| | - Token Revocation playbook
| | - Key Rotation playbook
| | - Incident response procedures
Update Procedure
- Draft proposed changes
- Security team review
- Test changes in staging
- Update documentation
- Announce to operations team
- Archive old version
Last Updated: November 13, 2025
Status: Operational (Ready for Use)
Priority: High (Incident Response)
Maintainer: Security Operations Team