CoolFace
Apppublic

PradeepFr/soc-analyst-rl-env

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

๐Ÿ›ก๏ธ SOC Analyst Environment

A realistic Security Operations Center (SOC) analyst environment for training and evaluating AI agents on security event triage โ€” deciding whether to PERMIT, VERIFY, SUSPEND, or BAN based on MITRE ATT&CK-aligned threat signatures.

Why This Environment?

SOC analysts process thousands of security alerts per shift. Alert fatigue causes real analysts to miss critical threats โ€” an estimated 30% of alerts go uninvestigated (Ponemon Institute). This environment models that exact challenge:

  • โ€”Real-world task: Security event triage is performed by >400,000 SOC analysts worldwide
  • โ€”Business-aware decisions: The agent must balance security (catching threats) with business impact (not banning innocent users)
  • โ€”MITRE ATT&CK alignment: All threat signatures map to real-world attack techniques

Environment Description

The agent plays the role of a SOC analyst processing a stream of security events during a shift. Each event contains:

  • โ€”User metadata: job role, department, typical login hours, registered devices
  • โ€”Event data: timestamp, source IP, geolocation, action string (command/activity), payload size, device ID, login history

The agent must classify each event into one of four response levels.

Action Space

ActionDescriptionUse Case
PERMITAllow activityNormal behavior, routine operations
VERIFYSoft lock โ€” trigger MFA, remove write accessUnusual but not dangerous (after-hours login, new device)
SUSPENDDisable account, require human reviewSerious threat indicators (impossible travel, brute force)
BANKill all sessions, blacklist IPCritical threats (ransomware, credential theft)

Observation Space

json
{
    "event_id": 1,
    "total_events": 10,
    "user_id": "USR-1042",
    "job_role": "Contractor",
    "department": "External",
    "typical_login_hours": "09:00-17:00",
    "registered_devices": ["DEV-WIN-8821"],
    "timestamp": "2025-03-15T14:22:31Z",
    "source_ip": "198.51.100.45",
    "geo_location": "Unknown VPN Exit Node",
    "action_string": "vssadmin delete shadows /all /quiet",
    "payload_size_mb": 0.01,
    "device_id": "DEV-WIN-8821",
    "failed_login_count": 0,
    "previous_login_location": "New York, US",
    "previous_login_timestamp": "2025-03-15T09:01:00Z",
    "task_name": "soc_easy",
    "events_remaining": 9,
    "cumulative_reward": 0.0,
    "message": "SOC Analyst shift started...",
    "done": false,
    "reward": 0.0
}

Tasks

soc_easy โ€” 10 events (Easy)

Obvious threats with clear signatures. No ambiguity or traps. Tests basic pattern recognition.

  • โ€”Ransomware commands (vssadmin delete shadows, LSASS dumps)
  • โ€”Clear impossible travel (London โ†’ Tokyo in 25 min)
  • โ€”Standard brute force (127 failed logins)
  • โ€”Normal work activities (git push, opening spreadsheets)

soc_medium โ€” 15 events (Medium)

Context-dependent decisions with benign traps mixed in:

  • โ€”IT Admin running vssadmin list shadows (legitimate โ€” NOT ransomware)
  • โ€”Employee who forgot password with 5 failed logins (NOT brute force)
  • โ€”Remote worker on vacation logging in from Berlin (NOT impossible travel)
  • โ€”New employee downloading 1.5GB onboarding materials (NOT insider threat)

soc_hard โ€” 25 events (Hard)

Alert fatigue + adaptive attacker:

  • โ€”First 14 events are mostly benign (lulls the agent into always saying PERMIT)
  • โ€”Threats use adapted signatures:
  • โ€”wmic shadowcopy delete instead of vssadmin delete shadows
  • โ€”ntdsutil IFM dump instead of mimikatz
  • โ€”Base64-encoded PowerShell shadow copy deletion
  • โ€”reg save HKLM\SAM for offline credential cracking
  • โ€”Heavy false positive traps (Data Engineer doing 15GB backup, IT Admin viewing LSASS process info)

Reward Design

ScenarioReward
โœ… Correct decision+1.0
โš ๏ธ Close but wrong (e.g., VERIFY instead of SUSPEND)-0.3
โŒ Missed real threat (PERMIT on ransomware)-1.0
๐Ÿšซ Banned innocent user-1.0
โฌ†๏ธ Over-escalated minor issue-0.5 to -0.7

Key design principle: False positives (banning innocent users) are penalized equally to false negatives (missing threats). This forces the agent to be Business-aware, not just a "ban everything" filter.

Final score per task = max(0, cumulative_reward) / total_events, clamped to [0.0, 1.0].

Setup & Usage

Docker (Recommended)

bash
# Build
cd soc_analyst_env
docker build -t soc-analyst-env:latest .

# Run
docker run -p 8000:8000 soc-analyst-env:latest

Local Development

bash
cd soc_analyst_env
pip install -r server/requirements.txt
uvicorn server.app:app --reload --host 0.0.0.0 --port 8000

Running the Baseline

bash
# Set your API credentials
export HF_TOKEN="your-token-here"
export API_BASE_URL="https://router.huggingface.co/v1"
export MODEL_NAME="Qwen/Qwen2.5-72B-Instruct"

# Start the environment server
uvicorn server.app:app --host 0.0.0.0 --port 8000 &

# Run inference
python inference.py

API Endpoints

EndpointMethodDescription
/resetPOSTReset environment (accepts task_name in body)
/stepPOSTSubmit action ({"action": {"action": "BAN"}})
/stateGETGet current state
/schemaGETGet action/observation JSON schemas
/healthGETHealth check
/wsWSWebSocket for persistent sessions

Project Structure

soc_analyst_env/
โ”œโ”€โ”€ Dockerfile              # Container for HF Spaces
โ”œโ”€โ”€ README.md               # This file
โ”œโ”€โ”€ openenv.yaml            # OpenEnv manifest
โ”œโ”€โ”€ pyproject.toml          # Project metadata
โ”œโ”€โ”€ inference.py            # Baseline inference script
โ”œโ”€โ”€ __init__.py             # Package exports
โ”œโ”€โ”€ models.py               # Pydantic Action/Observation models
โ”œโ”€โ”€ scenarios.py            # Security event data (50 events)
โ”œโ”€โ”€ client.py               # EnvClient for programmatic access
โ””โ”€โ”€ server/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ app.py              # FastAPI application
    โ”œโ”€โ”€ requirements.txt    # Docker dependencies
    โ””โ”€โ”€ soc_analyst_env_environment.py  # Core environment logic

Baseline Scores

TaskScoreNotes
soc_easy~0.90Most models handle obvious signatures well
soc_medium~0.65Benign traps catch over-aggressive models
soc_hard~0.45Alert fatigue and adapted signatures challenge even strong models

Creativity & Novelty

  • โ€”Alert fatigue simulation: Tests if agents stay vigilant after long benign sequences
  • โ€”Adaptive attacker: Hard task uses variant signatures (wmic, ntdsutil, encoded PowerShell) that test generalization beyond exact pattern matching
  • โ€”Business friction penalty: Over-banning is equally bad as under-responding โ€” forces nuanced decision-making
  • โ€”MITRE ATT&CK alignment: Real-world relevance backed by industry-standard threat taxonomy