Anomaly Detection
Define behavioral baselines and anomaly detection rules for "$ARGUMENTS". Establish normal patterns, create detection rules for deviations, and configure automated responses for high-confidence anomalies.
Prerequisites
Read .metapowers/security/$ARGUMENTS/00-govern.md. If this file does not exist, tell the user:
Phase 0 (Govern) has not been completed for "$ARGUMENTS". Run a Govern skill first (e.g., /security:security-policy $ARGUMENTS), or use --skip-checks to bypass.
If --skip-checks is present in $ARGUMENTS, skip this check and log to .metapowers/security/$ARGUMENTS/skip-log.md.
Process
Establish behavioral baselines:
- Login patterns — normal login times, locations, devices, and frequency per user population
- API usage patterns — typical request rates, endpoint access distribution, payload sizes
- Data access patterns — normal query volumes, data export sizes, access to sensitive resources
- Network patterns — expected traffic volumes, destination IPs/domains, protocol distribution
- System patterns — normal CPU/memory usage, process lists, file system activity
- Define baseline measurement period (minimum 30 days of data, accounting for business cycles)
Define anomaly detection rules:
- Impossible travel — login from geographically distant locations within an impossible timeframe
- Unusual hours — access outside established working hours for the user's role and timezone
- Failed login spike — sudden increase in failed authentication attempts (brute force indicator)
- Bulk data export — data retrieval significantly exceeding baseline (exfiltration indicator)
- Privilege escalation attempts — repeated access denied events followed by elevated access
- New admin accounts — creation of privileged accounts outside change management process
- Lateral movement — sequential access across multiple systems from a single compromised account
- DNS anomalies — queries to newly registered domains, high-entropy domain names (DGA detection)
Set detection thresholds:
- Define statistical thresholds (standard deviations from baseline, percentile-based)
- Tune thresholds to minimize false positives while maintaining detection sensitivity
- Implement different thresholds by user population (admins vs. standard users, humans vs. service accounts)
- Define learning period for new users and systems before enforcing anomaly rules
- Plan for seasonal adjustments (end-of-quarter, product launches, maintenance windows)
Create alert correlation rules:
- Combine multiple low-confidence signals into high-confidence detections
- Define attack chain correlations (reconnaissance -> initial access -> lateral movement -> exfiltration)
- Implement time-windowed correlation (related events within a defined time period)
- Create entity-based correlation (aggregate anomalies per user, per IP, per service)
- Assign composite risk scores based on correlated signals
Define automated response actions:
- High confidence — automatic containment (account lockout, session termination, network isolation)
- Medium confidence — step-up authentication (require MFA re-verification), increase logging verbosity
- Low confidence — flag for analyst review, add to watchlist for enhanced monitoring
- Define rollback procedures if automated response was a false positive
- Ensure all automated actions generate audit trail entries
Write the artifact to .metapowers/security/$ARGUMENTS/03-detect.md with heading:
Anomaly Detection
Include sections:
- Behavioral Baselines — patterns measured, data sources, and measurement methodology
- Detection Rules — each anomaly rule with logic, data source, and threshold
- Threshold Configuration — statistical methods, tuning approach, and false positive targets
- Correlation Rules — multi-signal correlations and composite risk scoring
- Automated Responses — actions by confidence level with rollback procedures
- Tuning Plan — ongoing threshold adjustment and false positive reduction process
Output
The anomaly detection plan written to .metapowers/security/$ARGUMENTS/03-detect.md. Present a summary to the user highlighting:
- Behavioral baselines to be established and data sources
- Key anomaly detection rules and their threat coverage
- Automated response actions by confidence level
- Correlation rules for attack chain detection
1---2name: anomaly-detection3description: Define behavioral baselines and anomaly detection rules4---56# Anomaly Detection78Define behavioral baselines and anomaly detection rules for "$ARGUMENTS". Establish normal patterns, create detection rules for deviations, and configure automated responses for high-confidence anomalies.910## Prerequisites1112Read `.metapowers/security/$ARGUMENTS/00-govern.md`. If this file does not exist, tell the user:1314> Phase 0 (Govern) has not been completed for "$ARGUMENTS". Run a Govern skill first (e.g., `/security:security-policy $ARGUMENTS`), or use `--skip-checks` to bypass.1516If `--skip-checks` is present in $ARGUMENTS, skip this check and log to `.metapowers/security/$ARGUMENTS/skip-log.md`.1718## Process19201. **Establish behavioral baselines:**21 - **Login patterns** — normal login times, locations, devices, and frequency per user population22 - **API usage patterns** — typical request rates, endpoint access distribution, payload sizes23 - **Data access patterns** — normal query volumes, data export sizes, access to sensitive resources24 - **Network patterns** — expected traffic volumes, destination IPs/domains, protocol distribution25 - **System patterns** — normal CPU/memory usage, process lists, file system activity26 - Define baseline measurement period (minimum 30 days of data, accounting for business cycles)27282. **Define anomaly detection rules:**29 - **Impossible travel** — login from geographically distant locations within an impossible timeframe30 - **Unusual hours** — access outside established working hours for the user's role and timezone31 - **Failed login spike** — sudden increase in failed authentication attempts (brute force indicator)32 - **Bulk data export** — data retrieval significantly exceeding baseline (exfiltration indicator)33 - **Privilege escalation attempts** — repeated access denied events followed by elevated access34 - **New admin accounts** — creation of privileged accounts outside change management process35 - **Lateral movement** — sequential access across multiple systems from a single compromised account36 - **DNS anomalies** — queries to newly registered domains, high-entropy domain names (DGA detection)37383. **Set detection thresholds:**39 - Define statistical thresholds (standard deviations from baseline, percentile-based)40 - Tune thresholds to minimize false positives while maintaining detection sensitivity41 - Implement different thresholds by user population (admins vs. standard users, humans vs. service accounts)42 - Define learning period for new users and systems before enforcing anomaly rules43 - Plan for seasonal adjustments (end-of-quarter, product launches, maintenance windows)44454. **Create alert correlation rules:**46 - Combine multiple low-confidence signals into high-confidence detections47 - Define attack chain correlations (reconnaissance -> initial access -> lateral movement -> exfiltration)48 - Implement time-windowed correlation (related events within a defined time period)49 - Create entity-based correlation (aggregate anomalies per user, per IP, per service)50 - Assign composite risk scores based on correlated signals51525. **Define automated response actions:**53 - **High confidence** — automatic containment (account lockout, session termination, network isolation)54 - **Medium confidence** — step-up authentication (require MFA re-verification), increase logging verbosity55 - **Low confidence** — flag for analyst review, add to watchlist for enhanced monitoring56 - Define rollback procedures if automated response was a false positive57 - Ensure all automated actions generate audit trail entries58596. **Write the artifact** to `.metapowers/security/$ARGUMENTS/03-detect.md` with heading:6061 ## Anomaly Detection6263 Include sections:64 - **Behavioral Baselines** — patterns measured, data sources, and measurement methodology65 - **Detection Rules** — each anomaly rule with logic, data source, and threshold66 - **Threshold Configuration** — statistical methods, tuning approach, and false positive targets67 - **Correlation Rules** — multi-signal correlations and composite risk scoring68 - **Automated Responses** — actions by confidence level with rollback procedures69 - **Tuning Plan** — ongoing threshold adjustment and false positive reduction process7071## Output7273The anomaly detection plan written to `.metapowers/security/$ARGUMENTS/03-detect.md`. Present a summary to the user highlighting:74- Behavioral baselines to be established and data sources75- Key anomaly detection rules and their threat coverage76- Automated response actions by confidence level77- Correlation rules for attack chain detection