CoolFace
Apppublic

PudiHaripriya/soc-env-analyst

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

OpenEnv: Enterprise SOC Analyst (Procedural Threat Triage)

Python 3.10+ Environment Deployment


๐Ÿง  Overview

This project introduces a high-fidelity Security Operations Center (SOC) simulation environment designed for evaluating and training autonomous agents in realistic cybersecurity workflows.

Unlike toy environments, this system models:

  • โ€”Multi-step incident response pipelines
  • โ€”Procedural reasoning under constraints
  • โ€”Noisy, adversarial log analysis
  • โ€”Strict compliance-driven decision making

The agent operates as a Tier-1 SOC Analyst, tasked with:

  • โ€”Detecting threats from raw SIEM logs
  • โ€”Investigating using limited tools
  • โ€”Classifying attacks via MITRE ATT&CK
  • โ€”Executing mitigation under strict SOP constraints

๐ŸŽฏ Why This Environment Matters

Real-world SOC operations are:

  • โ€”High-risk (incorrect actions can break production systems)
  • โ€”Procedural (strict runbooks must be followed)
  • โ€”Noisy (signals buried in irrelevant logs)
  • โ€”Resource-constrained (limited investigation bandwidth)

This environment captures all of the above, making it a meaningful benchmark for agentic reasoning, not just pattern recognition.


๐Ÿ—๏ธ Repository Structure

.
โ”œโ”€โ”€ models.py                # Custom SOC Pydantic models (Actions/Observations)
โ”œโ”€โ”€ client.py                # SOC-specific persistent WebSocket client
โ”œโ”€โ”€ openenv.yaml             # Official environment specification
โ”œโ”€โ”€ pyproject.toml           # Project metadata & UV dependencies
โ”œโ”€โ”€ uv.lock                  # Deterministic dependency lock
โ”œโ”€โ”€ inference.py             # Baseline agent for local evaluation
โ”œโ”€โ”€ __init__.py              # Root exports
โ”œโ”€โ”€ README.md                # Documentation & HF Metadata
โ””โ”€โ”€ server/
    โ”œโ”€โ”€ __init__.py          # Exports MyEnvironment
    โ”œโ”€โ”€ app.py               # FastAPI server (Official OpenEnv entry)
    โ”œโ”€โ”€ Dockerfile           # UV-based container definition for HF Spaces
    โ”œโ”€โ”€ soc_graders.py          # Procedural reward & SOP validation logic
    โ””โ”€โ”€ my_env_environment.py   # Core SOC simulation engine logic

โš™๏ธ Core Environment Design

๐Ÿ” Observation Space (SOCObservation)

  • โ€”logs: Procedurally generated SIEM logs (multi-format, noisy)
  • โ€”tool_results: Threat intelligence responses
  • โ€”remaining_steps: Time constraint
  • โ€”api_budget_remaining: Limited investigation budget
  • โ€”system_message: Dynamic feedback + memory

๐ŸŽฎ Action Space (SOCAction)

  • โ€”QUERY_INTEL โ†’ Investigate IP reputation
  • โ€”CREATE_TICKET โ†’ Initiate mitigation workflow
  • โ€”BLOCK โ†’ Block external threat
  • โ€”ISOLATE_INTERNAL_HOST โ†’ Contain internal compromise
  • โ€”IGNORE โ†’ Dismiss benign activity

๐Ÿ”ฅ Key Features

1. Infinite Procedural Generation

  • โ€”Every episode generates:
  • โ€”new IPs
  • โ€”new attack patterns
  • โ€”new noise distribution ๐Ÿ‘‰ Prevents memorization, enforces reasoning

2. Strict SOP Enforcement

  • โ€”Mandatory workflow:
QUERY_INTEL โ†’ CREATE_TICKET โ†’ MITIGATE
  • โ€”Violations โ†’ penalties ๐Ÿ‘‰ Mirrors real SOC runbooks

3. MITRE ATT&CK Integration

Agents must classify attacks using:

  • โ€”Credential Access
  • โ€”Exfiltration
  • โ€”Impact
  • โ€”Initial Access
  • โ€”Discovery

4. Resource Constraints

  • โ€”Limited API calls (QUERY_INTEL)
  • โ€”Forces strategic decision-making

5. Zero-Day Mechanic

  • โ€”30% chance threat intel is WRONG ๐Ÿ‘‰ Agent must trust logs over tools

6. Chaos Mode (Multi-Threat)

  • โ€”Multiple simultaneous attacks
  • โ€”Requires prioritization and sequential mitigation

7. Anti-Reward Hacking

  • โ€”Duplicate actions penalized
  • โ€”Invalid sequences blocked

8. Dynamic Feedback System

System message tracks:

  • โ€”Active tickets
  • โ€”Investigated IPs
  • โ€”Mitigations
  • โ€”Remaining threats

๐Ÿ‘‰ Enables memory-based reasoning


๐Ÿงช Tasks & Difficulty Scaling

LevelDescription
EasyDetect brute-force attack
MediumDistinguish attack vs benign traffic
HardIdentify stealth SQL injection
ExpertHandle ransomware or DDoS
InsaneMulti-threat chaos scenario

๐Ÿ‘‰ Difficulty increases via noise, ambiguity, and multi-step reasoning


๐Ÿ“Š Reward Design

  • โ€”Positive rewards for:
  • โ€”correct investigation
  • โ€”correct classification
  • โ€”correct mitigation
  • โ€”Strict Zero-Reward Terminations (Game Over) for:
  • โ€”Fatal SOP violations (e.g., blocking internal IPs)
  • โ€”Redundant actions (duplicate tickets)
  • โ€”Ignoring active zero-day threats ๐Ÿ‘‰ Ensures agents cannot "reward hack" by spamming actions.

๐Ÿ‘‰ Enables dense + meaningful learning signals


๐Ÿค– Baseline Agent

The baseline agent:

  • โ€”Uses an LLM (Qwen / OpenAI-compatible)
  • โ€”Operates under:
  • โ€”strict JSON schema
  • โ€”deterministic inference (temperature=0, seed=42)

Output Format

[START]
[STEP]
[END]

โœ” Fully OpenEnv compliant โœ” Reproducible results


โ–ถ๏ธ Running the Environment

1. Install dependencies

bash
# Using UV (Recommended for OpenEnv)
uv sync
source .venv/bin/activate
# OR using pip
pip install -e .

2. Set API key

bash
export HF_TOKEN="your_token_here"

3. Run inference

bash
export SOC_TASK="hard"
python inference.py

๐Ÿš€ Deployment (Hugging Face Spaces)

  1. 1.Create a Docker Space
  2. 2.Upload all files
  3. 3.Wait until status = Running

Validate:

bash
curl -fsSL https://raw.githubusercontent.com/neo-derek/open-env/main/scripts/validate-submission.sh | bash -s -- <your-space-url> .

๐Ÿง  Design Philosophy: Prompt-Driven SOP vs. Autonomous Exploration

The Critique

The strict SOP workflow may appear partially enforced through the system prompt, raising concerns about reduced reliance on pure environment-driven learning.

Our Perspective

In real-world SOC environments:

  • โ€”Agents cannot freely explore actions
  • โ€”Mistakes can cause production failures
  • โ€”Analysts follow strict procedural runbooks

Thus, the prompt represents operational prior knowledge, not shortcuts.

Environment Guarantees

  • โ€”Grader enforces SOP rules
  • โ€”Invalid actions are penalized
  • โ€”Correct sequencing is validated programmatically

๐Ÿ‘‰ Environment correctness does not depend on prompt compliance

Future Direction

  • โ€”Introduce QUERY_SOP
  • โ€”Enable learning via interaction and feedback ๐Ÿ‘‰ Move toward fully autonomous agent learning

๐Ÿ† Summary

โœ” Realistic SOC simulation โœ” Strong OpenEnv compliance โœ” Multi-step reasoning challenges โœ” Deterministic evaluation โœ” Robust reward design


๐Ÿ’ก Final Thought

This is not just an environment โ€” it is a decision-making benchmark under real-world constraints.