Appearance
Indicator of Compromise Detection and Behavioral Anomaly Analysis for AI Platforms
Document Information
| Field | Value |
|---|---|
| Version | 1.0 |
| Date | April 2026 |
| Classification | Public |
Executive Summary
Enterprise AI platforms process sensitive data at scale — regulated PII, trade secrets, financial records, and privileged communications flow through chat sessions, file uploads, tool invocations, and memory recall. Traditional perimeter security does not address the threat model unique to AI: a compromised account can exfiltrate vast amounts of data through seemingly normal conversation, a malicious insider can bulk-download sanitized reports at 2 AM, and an attacker pivoting through stolen credentials can query from unfamiliar geographies without triggering conventional IDS rules.
GhostAI addresses this gap with a dual-layer detection architecture:
IOC Rule Evaluation Engine — six purpose-built indicator types evaluate every audit event in real time, matching against organization-defined rules for volume spikes, off-hours access, geographic anomalies, data exfiltration, unusual access patterns, and custom regex signatures.
Behavioral Anomaly Detection — a statistical baseline system computes rolling 30-day per-user activity profiles across six metric dimensions, then applies z-score analysis to flag deviations that exceed configurable warning and critical thresholds.
Both layers persist match history, support acknowledgment workflows, emit structured events to enterprise SIEMs, and dispatch alerts through webhooks and email. This whitepaper describes the architecture, detection logic, data model, operational integration, and compliance alignment.
1. The Threat Landscape for Enterprise AI
1.1 AI-Specific Attack Vectors
AI platforms introduce unique indicators of compromise that traditional endpoint detection and network IDS were not designed to identify:
| Threat | Description | Traditional Detection Gap |
|---|---|---|
| Conversational exfiltration | An attacker uses AI chat to extract sensitive data through natural-language queries rather than database dumps | No file transfer or network anomaly to trigger |
| Bulk PII harvesting | A compromised service account makes thousands of PII-laden queries to build a dossier | Appears as normal API traffic |
| Off-hours data staging | An insider exports reports and audit logs during low-activity periods to avoid peer observation | VPN connection is legitimate; no lateral movement |
| Credential-stuffing via AI endpoints | Stolen API keys are used from multiple geographies simultaneously | Standard rate limiting catches volume, not origin diversity |
| Tool chain abuse | Malicious tool invocations exfiltrate data through MCP tool outputs | Tool calls look identical to legitimate usage |
| Memory system extraction | An attacker queries the memory system to retrieve historical context containing sensitive data | Memory recall is a core feature, not an anomaly by signature alone |
1.2 Why Both IOC Rules and Behavioral Baselines Are Required
IOC rules provide deterministic, low-latency detection — if a pre-defined pattern matches, an alert fires immediately. However, IOC rules require explicit definition and cannot adapt to emerging patterns.
Behavioral baselines provide adaptive, statistical detection — they learn what is normal for each user and flag deviations without requiring explicit rule authoring. However, they require a warm-up period and produce probabilistic rather than deterministic alerts.
Together, the two layers form a defense-in-depth model: IOC rules catch known-bad patterns in real time, while behavioral baselines catch unknown-bad patterns through statistical deviation.
2. Architecture Overview
┌─────────────────────────────────┐
│ Audit Event Pipeline │
│ (AuditLogger.log() on every │
│ state-changing action) │
└──────────┬──────────────────────┘
│
┌──────────▼──────────────────────┐
│ SIEM Event Emitter │
│ (structured event to SIEM queue) │
└──────────┬──────────────────────┘
│
┌────────────────▼────────────────────┐
│ Real-Time IOC Evaluation │
│ (IOCEvaluator.evaluate() inline) │
│ │
│ Skip prefixes: pii.*, memory.recall,│
│ system.rate_limit │
└────────┬───────────────┬────────────┘
│ │
IOC Match Found No Match
│ │
┌────────▼────────┐ │
│ Persist to │ │
│ ioc_matches │ │
│ table │ │
└────────┬────────┘ │
│ │
┌────────▼────────┐ │
│ Dispatch Alerts │ │
│ (webhook, email)│ │
└─────────────────┘ │
│
┌────────────────────────▼────────────┐
│ Scheduled Layers (APScheduler) │
│ │
│ Hourly (:45): IOC batch evaluation │
│ Re-scans last hour of audit logs │
│ for all active organizations │
│ │
│ Nightly (2:30 AM UTC): │
│ 1. Compute 30-day rolling baselines│
│ 2. Run z-score anomaly detection │
│ 3. Emit anomalies to SIEM │
└──────────────────────────────────────┘2.1 Real-Time Path
Every call to AuditLogger.log() — triggered on authentication events, data access, file downloads, tool executions, memory operations, settings changes, and more — automatically invokes the IOC evaluation engine inline. The evaluator loads the organization's enabled IOC definitions from a TTL-cached store (60-second cache, invalidated on CRUD operations), evaluates the event against each rule, and if matches are found, persists them and dispatches alerts. High-volume event types that are unlikely to be relevant to IOC rules (pii.*, memory.recall, system.rate_limit) are skipped to minimize overhead.
2.2 Scheduled Batch Path
Two scheduled jobs supplement the real-time path:
Hourly IOC batch evaluation (every hour at :45) re-evaluates the last hour of audit logs for all active organizations, catching events that may have been skipped or that require cross-event correlation (e.g., geographic anomaly detection that counts distinct IPs across the day).
Nightly baseline and anomaly scan (2:30 AM UTC) computes rolling 30-day behavioral baselines for every active user, then runs z-score anomaly detection and emits detected anomalies as SIEM events.
3. IOC Rule Evaluation Engine
3.1 IOC Type Taxonomy
The engine supports six IOC types, each with a JSON-based pattern schema that administrators configure through the API or UI:
| IOC Type | Purpose | Pattern Parameters |
|---|---|---|
volume_spike | Detect when a user's activity count exceeds their historical baseline by N standard deviations | metric (event_count, pii_volume), threshold_sigma (default 3.0), min_count (default 20) |
off_hours | Flag activity outside defined business hours | start_hour (default 22), end_hour (default 6), timezone, min_events |
geo_anomaly | Detect suspicious geographic diversity — too many distinct IP addresses in a single day | max_countries_per_day (default 2), blocked_countries (list) |
data_exfil | Identify bulk data download or export bursts that exceed baseline | metric (file_downloads), threshold_sigma (default 3.0), min_count (default 10) |
access_pattern | Flag unusual resource access frequency for specified resource types | resource_types (list), max_per_hour (default 5) |
custom | Arbitrary regex-based matching on event type and JSON detail fields | event_type_regex, detail_match (key-value dict) |
3.2 Detection Logic by Type
Volume Spike
The volume spike detector compares current activity against historical baselines stored in the user_activity_baseline table. When an event arrives:
- Load the user's most recent baseline for the configured metric type
- Count the user's events for the current day
- If the count exceeds the minimum threshold and the z-score
(current - baseline) / stddevmeets or exceedsthreshold_sigma, the rule fires
This prevents false positives on low-activity days (the min_count floor) and on users without sufficient historical data (no baseline row means no fire).
Off-Hours Access
The off-hours detector evaluates the event's timestamp against a configurable business-hours window. The default configuration flags activity between 10 PM and 6 AM. The hour comparison handles wrap-around correctly: when start_hour > end_hour, the detector matches events where hour >= start_hour OR hour < end_hour.
Geographic Anomaly
The geographic anomaly detector counts distinct IP addresses for a user within the current day. If the distinct count exceeds max_countries_per_day, the rule fires. The pattern also supports a blocked_countries list for geo-fencing, though the current implementation focuses on IP diversity as a proxy for geographic dispersion.
Data Exfiltration
The data exfiltration detector is specifically scoped to data export events: data.file_download, data.report_export, data.audit_export, and data.consensus_export. When one of these events occurs:
- Count all
data.*events for the user in the last hour - If below
min_count, do not fire (insufficient signal) - Load the user's
file_downloadsbaseline - If baseline exists with positive stddev, apply sigma threshold
- If no baseline exists, fall back to a 2x multiplier of
min_countas the absolute cap
This layered approach ensures the detector works both for users with established baselines and for new users or first-time exporters.
Access Pattern
The access pattern detector counts events matching a configured set of resource types within a one-hour sliding window. If the count exceeds max_per_hour, the rule fires. This catches scenarios like rapid-fire API key rotation, exhaustive memory recall queries, or repetitive file access that would not individually trigger other rules.
Custom
The custom IOC type provides maximum flexibility. Administrators define a regular expression for event_type matching and an optional detail_match dictionary of exact key-value matches against the event's details JSON. This enables rules like "flag any authz.role_change event where role equals admin" without requiring a code deployment.
3.3 Evaluation Pipeline
Event arrives in AuditLogger.log()
│
▼
Skip check: action starts with pii.*, memory.recall, system.rate_limit?
│ No
▼
Load enabled IOC definitions for org (cached, 60s TTL)
│
▼
For each IOC definition:
│
├─ Dispatch to type-specific check method
│ volume_spike → _check_volume_spike()
│ off_hours → _check_off_hours()
│ geo_anomaly → _check_geo_anomaly()
│ data_exfil → _check_data_exfil()
│ access_pattern → _check_access_pattern()
│ custom → _check_custom()
│
├─ Match? → Build match record (ioc_definition_id, org, user, session,
│ event_type, event_data JSON, timestamp)
│
└─ Error? → Log at debug level, continue to next IOC (fault isolation)
Persist all matches to ioc_matches table
Dispatch alerts for each match via configured channelsEach IOC definition can fail independently without affecting evaluation of other rules. This fault isolation ensures that a malformed pattern or transient database issue does not silence the entire detection layer.
3.4 Caching Strategy
IOC definitions are cached per-organization with a 60-second TTL to avoid querying the database on every audit event. The cache is explicitly invalidated whenever an IOC definition is created, updated, or deleted through the API. This balances performance (most orgs will have a stable set of IOC rules that change infrequently) with freshness (rule changes propagate within seconds, not minutes).
4. Behavioral Anomaly Detection
4.1 Baseline Computation
The insider risk service computes rolling 30-day behavioral baselines for every active user. The computation runs as a nightly scheduled job and can also be triggered on demand via the admin API.
For each user, six metric dimensions are computed:
| Metric | Source | Computation |
|---|---|---|
event_count (per category) | user_audit_logs grouped by action prefix | Daily mean and population stddev across 9 categories: authentication, authorization, data_access, chat, mcp, settings, memory, compliance, billing |
pii_volume | tool_execution_log.pii_count | Sum of PII entities detected per day |
session_count | user_audit_logs filtered on conversation creation events | Conversations initiated per day |
file_downloads | user_audit_logs filtered on data.file_download | File download count per day |
off_hours_activity | user_audit_logs timestamps evaluated against 8 PM - 6 AM window | Event count outside business hours per day |
geo_distinct_ips | user_audit_logs.ip_address | Count of distinct IP addresses per day |
The standard deviation for event_count is computed from actual daily counts over the lookback window, with zero-padding for days with no activity. This prevents the stddev from being artificially inflated by only counting active days.
Baselines are stored in the user_activity_baseline table with a composite unique constraint on (organization_id, user_id, metric_type, metric_name, period_start), enabling upsert semantics that prevent duplicate entries on re-computation.
4.2 Z-Score Anomaly Detection
The anomaly detection algorithm compares current-period metric values against stored baselines using z-score analysis:
z = (current_value - baseline_value) / stddevThree detection modes ensure coverage across different data conditions:
| Condition | Detection Method |
|---|---|
stddev > 0 and sample_count >= 3 | Standard z-score comparison against configurable thresholds |
stddev <= 0 or sample_count < 3 | Ratio check: fire if current > baseline * 5 |
| Absolute threshold exceeded | Hard caps independent of baseline: request_count > 1,000, data_download_mb > 500, export_count > 50, failed_auth > 100 |
Severity Classification
| Z-Score Range | Severity |
|---|---|
z >= critical_threshold (default 3.5) | Critical |
warning_threshold <= z < critical_threshold (default 2.5) | Warning |
z < warning_threshold | Not flagged |
Both thresholds are configurable per scan via the API, allowing administrators to tune sensitivity based on their organization's risk tolerance.
Deduplication
Each anomaly receives a deterministic ID computed as MD5(org_id:user_id:metric_type:metric_name:date)[:16]. This ensures that the same anomaly detected across multiple scan runs within a single day produces the same ID, preventing duplicate alerts.
4.3 Warm-Up and Cold-Start Handling
New users or organizations without 30 days of history still receive protection through several fallback mechanisms:
- The ratio check (5x baseline) catches extreme deviations even when stddev cannot be meaningfully computed
- Absolute thresholds fire regardless of baseline state, providing a floor of detection for all users
- IOC rules (particularly
off_hours,custom, andaccess_pattern) do not depend on baselines at all, providing immediate coverage from day one
5. Data Model
5.1 IOC Definitions
sql
CREATE TABLE ioc_definitions (
id TEXT PRIMARY KEY,
organization_id TEXT NOT NULL,
name TEXT NOT NULL,
description TEXT DEFAULT '',
ioc_type TEXT NOT NULL, -- volume_spike | off_hours | geo_anomaly |
-- data_exfil | access_pattern | custom
pattern TEXT NOT NULL, -- JSON pattern schema
severity TEXT DEFAULT 'medium', -- low | medium | high | critical
enabled INTEGER DEFAULT 1,
alert_channels TEXT DEFAULT '["webhook"]', -- JSON array
metadata TEXT DEFAULT '{}', -- JSON, extensible
created_by TEXT NOT NULL,
created_at TEXT DEFAULT CURRENT_TIMESTAMP,
updated_at TEXT DEFAULT CURRENT_TIMESTAMP
);5.2 IOC Match History
sql
CREATE TABLE ioc_matches (
id SERIAL PRIMARY KEY,
organization_id TEXT NOT NULL,
ioc_definition_id TEXT NOT NULL,
user_id TEXT,
session_id TEXT,
event_type TEXT NOT NULL,
event_data TEXT DEFAULT '{}', -- Full event JSON
matched_at TEXT DEFAULT CURRENT_TIMESTAMP,
acknowledged INTEGER DEFAULT 0,
acknowledged_by TEXT,
acknowledged_at TEXT,
FOREIGN KEY (ioc_definition_id) REFERENCES ioc_definitions(id) ON DELETE CASCADE
);The acknowledged flag and associated fields support SOC triage workflows: analysts can acknowledge matches to distinguish reviewed events from new alerts. The cascade delete ensures match history is cleaned up when IOC definitions are removed.
5.3 User Activity Baselines
sql
CREATE TABLE user_activity_baseline (
id SERIAL PRIMARY KEY,
organization_id TEXT NOT NULL,
user_id TEXT NOT NULL,
period_start TEXT NOT NULL,
period_end TEXT NOT NULL,
metric_type TEXT NOT NULL,
metric_name TEXT NOT NULL,
baseline_value REAL NOT NULL,
stddev REAL DEFAULT 0,
sample_count INTEGER DEFAULT 0,
created_at TEXT DEFAULT CURRENT_TIMESTAMP,
UNIQUE(organization_id, user_id, metric_type, metric_name, period_start)
);6. SIEM Integration
Both IOC matches and behavioral anomalies emit structured events to the enterprise SIEM pipeline through the unified audit event bus.
6.1 Event Types
| Event Type | Description | MITRE ATT&CK | Compliance |
|---|---|---|---|
insider_risk.ioc_matched | An event matched an IOC rule definition | T1078 (Valid Accounts) | SOC2-CC6.1, SOC2-AE2.2, HIPAA-164.312(b) |
insider_risk.anomaly_detected | Behavioral anomaly detected against user activity baseline | T1078 (Valid Accounts) | SOC2-CC6.1, SOC2-AE2.2, HIPAA-164.312(b) |
6.2 Event Payload
IOC match events include:
json
{
"ioc_name": "After-hours bulk download",
"ioc_type": "off_hours",
"event_type": "data.file_download",
"severity": "high"
}Anomaly detection events include:
json
{
"metric_type": "off_hours_activity",
"metric_name": "total",
"current_value": 45,
"baseline_value": 3.2,
"deviation": 4.1,
"severity": "critical"
}These payloads are formatted by the SIEM event emitter into the customer's chosen format (JSON, CEF, LEEF, Splunk HEC, Microsoft Sentinel, or OCSF) and delivered via webhook push or pull API.
6.3 Correlation with Existing SOC Workflows
The MITRE ATT&CK T1078 mapping enables SOC teams to correlate GhostAI IOC and anomaly events with existing detection rules for valid-account abuse. For example, a SIEM rule that combines insider_risk.ioc_matched (type: geo_anomaly) with VPN login events from the identity provider can produce a high-confidence alert for account takeover that neither system could generate alone.
7. API Reference
All endpoints are authenticated and scoped to the caller's organization.
7.1 IOC Management
| Method | Endpoint | Description |
|---|---|---|
POST | /api/insider-risk/iocs | Create an IOC definition |
GET | /api/insider-risk/iocs | List IOC definitions (filterable by type, enabled status) |
PUT | /api/insider-risk/iocs/{id} | Update an IOC definition |
DELETE | /api/insider-risk/iocs/{id} | Delete an IOC definition |
7.2 IOC Match History
| Method | Endpoint | Description |
|---|---|---|
GET | /api/insider-risk/ioc-matches | List matches (filterable by IOC ID, acknowledgment status; max 500) |
POST | /api/insider-risk/ioc-matches/{id}/acknowledge | Acknowledge a match |
7.3 Behavioral Baselines
| Method | Endpoint | Description |
|---|---|---|
GET | /api/insider-risk/baselines | List per-user baseline summaries |
GET | /api/insider-risk/baselines/{user_id} | Get detailed baseline metrics for a user |
POST | /api/insider-risk/baselines/compute | Trigger baseline recomputation (configurable period and lookback) |
7.4 Anomaly Detection
| Method | Endpoint | Description |
|---|---|---|
GET | /api/insider-risk/anomalies | List recent anomaly detections (max 200) |
POST | /api/insider-risk/anomalies/scan | Run anomaly scan on demand (configurable thresholds) |
POST | /api/insider-risk/ioc-evaluate | Run batch IOC evaluation over a time window (1-24 hours) |
8. Admin UI
The detection results surface in the GhostAI admin console through the Tool Security Center, accessible at Admin Dashboard > Security > Tool Security > Anomalies & Recommendations.
The panel provides:
- Anomaly list with severity color coding (critical = red, warning = yellow, info = blue), user attribution, metric details, z-score deviation values, and detection timestamps
- Recommendation list with priority classification (high, medium, low)
- Time-period selector (last hour, 24 hours, 7 days, 30 days)
- Anomaly-to-tool drill-down — clicking an anomaly navigates to the affected tool's security detail view
The same view is available in the Platform Admin Console under the Tool Risk tab for multi-tenant operators.
9. Compliance Alignment
| Framework | Requirement | How IOC/Anomaly Detection Addresses It |
|---|---|---|
| SOC 2 CC6.1 | Logical access security controls | IOC rules detect unauthorized access patterns; anomaly baselines identify deviation from authorized behavior |
| SOC 2 AE2.2 | Anomaly detection in the operating environment | Behavioral baselines with z-score analysis directly satisfy this criterion |
| HIPAA 164.312(b) | Audit controls — mechanisms to record and examine activity in systems containing ePHI | IOC match history and anomaly records provide immutable audit trail; SIEM emission enables centralized review |
| PCI-DSS 10.6 | Review logs and security events to identify anomalies or suspicious activity | Automated anomaly detection replaces manual log review; configurable thresholds adapt to each org's volume |
| GDPR Art. 32 | Appropriate technical measures to ensure security of processing | Real-time IOC evaluation and behavioral anomaly detection constitute continuous monitoring |
| FedRAMP SI-4 | Information system monitoring | Dual-layer detection with SIEM integration satisfies continuous monitoring requirements |
| NIST 800-53 SI-4 | System monitoring — detect attacks and unauthorized connections | Six IOC types cover the attack categories specified; geographic anomaly detection addresses unauthorized geographic access |
10. Operational Best Practices
10.1 Recommended Starter IOC Rules
| Rule Name | Type | Pattern | Severity |
|---|---|---|---|
| After-hours bulk download | off_hours | {"start_hour": 22, "end_hour": 6} | High |
| Query volume spike | volume_spike | {"metric": "event_count", "threshold_sigma": 3.0, "min_count": 20} | High |
| PII volume spike | volume_spike | {"metric": "pii_volume", "threshold_sigma": 3.0, "min_count": 20} | Critical |
| Geographic anomaly | geo_anomaly | {"max_countries_per_day": 3, "blocked_countries": []} | High |
| Bulk data export | data_exfil | {"metric": "file_downloads", "threshold_sigma": 3.0, "min_count": 10} | Critical |
| Rapid API key access | access_pattern | {"resource_types": ["settings.api_key_view"], "max_per_hour": 5} | High |
| Admin role escalation | custom | {"event_type_regex": "authz\\.role_change", "detail_match": {"role": "admin"}} | Critical |
10.2 Tuning Thresholds
- Start with defaults (warning: 2.5 sigma, critical: 3.5 sigma) and observe alert volume for two weeks
- Lower thresholds for high-security environments (healthcare, financial services): warning: 2.0, critical: 3.0
- Raise thresholds for high-activity environments (developer platforms, internal tools): warning: 3.0, critical: 4.0
- Use the
min_countfloor to suppress false positives from low-volume users — a user with 5 events per day cannot meaningfully spike
10.3 Baseline Warm-Up
- Baselines require a minimum of 3 sample days to produce meaningful stddev values
- The ratio fallback (5x baseline) provides interim protection during the warm-up period
- Absolute thresholds provide day-one protection regardless of baseline state
- Consider running
POST /api/insider-risk/baselines/computewith a 30-day lookback immediately after deployment to seed baselines from existing audit history
11. Test Coverage
The IOC evaluation engine and behavioral anomaly detection are covered by:
- Unit tests (
tests/unit/services/test_ioc_evaluator.py) — IOC cache lifecycle, all six IOC type check methods, full evaluate pipeline, batch evaluation, match persistence, and alert dispatch (webhook and email) - Unit tests (
tests/unit/services/test_insider_risk_service.py) — baseline computation, anomaly detection, SIEM emission - Integration tests (
tests/integration/test_insider_risk_pipeline.py) — end-to-end flow from audit event through IOC evaluation, baseline computation, anomaly detection, and SIEM emission
12. Conclusion
GhostAI's IOC and anomaly detection architecture provides continuous, multi-layered monitoring purpose-built for the AI platform threat model. The combination of deterministic IOC rules for known-bad patterns and adaptive behavioral baselines for unknown deviations ensures comprehensive coverage from day one, with increasing precision as baselines mature. Full SIEM integration, structured MITRE ATT&CK mapping, and compliance-aligned event cataloging enable security teams to incorporate AI platform monitoring into existing SOC workflows without building custom integrations.
The system is designed to reduce alert fatigue — configurable sigma thresholds, minimum count floors, absolute hard caps, and hourly deduplication ensure that alerts represent genuine deviations from established patterns rather than statistical noise. At the same time, the fault-isolated evaluation pipeline ensures that no single malformed rule or transient error can silence the detection layer.
For organizations deploying AI at scale, this architecture provides the continuous monitoring, audit trail, and anomaly detection required by SOC 2, HIPAA, PCI-DSS, GDPR, FedRAMP, and NIST 800-53 — while addressing the AI-specific threats that traditional security tooling was not designed to detect.