IMVEEDev Portal

Architecture & How It Works

Internal architecture of the Satellite Agent — enrollment flow, goroutine lifecycle, data collectors, queue mechanism and WebSocket connection. This page is aimed at developers who extend or debug the agent.

flowchart LR
  subgraph EP["Monitored Endpoint"]
    subgraph COL["Data Collectors"]
      C1["System Metrics\nCPU · RAM · Disk"]
      C2["Container Events"]
      C3["Kubernetes Events"]
    end
    subgraph CORE["Agent Core"]
      Q[["Local Queue\nBuffer during connection loss"]]
      BR["Transmission Control\nBatching & circuit breaker"]
    end
  end
  subgraph PLAT["SOCSuite Platform"]
    OS[("Event Database")]
    WS["Mission Receiver"]
    REG["Registration"]
  end
  C1 --> Q
  C2 --> Q
  C3 --> Q
  Q -->|"Validate & batch"| BR
  BR -->|"Send events"| OS
  BR -.->|"Receive missions"| WS
  BR -.->|"Heartbeat"| REG

Enrollment Flow

sequenceDiagram
    participant Agent as Satellite Agent
    participant API as SOCSuite API
    participant DB as PostgreSQL
    participant FS as Filesystem

    Agent->>Agent: Cache system info (hostname, OS, version)
    Agent->>FS: agent.id present?
    alt agent.id exists
        FS-->>Agent: Load agent_id + agent_key
        Agent->>Agent: Skip re-registration (idempotent)
    else agent.id missing
        Agent->>API: POST /api/v1/ingest/enroll
        Note right of Agent: { enrollment_token, hostname,<br/>os_name, os_version, agent_version }
        API->>DB: Create asset (type='agent')
        DB-->>API: asset_id
        API-->>Agent: { agent_id, api_key }
        Agent->>FS: Save agent.id (0644)
        Agent->>FS: Save agent.key (0600, AES-256-GCM)
    end

    loop Every 60s
        Agent->>API: POST /heartbeat (Bearer token)
        API-->>Agent: 200 OK + Missions
    end

Agent Lifecycle

After enrollment (see diagram above) the agent starts several parallel goroutines. The number is dynamically configurable via the mission config from the SOCSuite backend:

Fixed goroutines:
  ├── heartbeatLoop()    — every 60s (backoff on failure)
  ├── websocketLoop()    — persistent (WSS)
  ├── metricsLoop()      — every 10s (configurable: METRICS_INTERVAL)
  ├── inventoryLoop()    — every 15min (configurable: IMVEE_INVENTORY_INTERVAL)
  └── configSyncLoop()   — every 5min (configurable: IMVEE_CONFIG_SYNC_INTERVAL)

Dynamic goroutines (depending on mission config / always-on):
  ├── dockerCollectorLoop()    — real-time Docker events
  ├── shellCollectorLoop()     — ZSH/Bash hook (command + exit code)
  ├── eventlogCollectorLoop()  — Windows Event Log / journald
  ├── fileMonitorLoop()        — file monitoring (FIM)
  ├── auditCollectorLoop()     — audit log monitoring
  ├── journaldCollectorLoop()  — systemd journald events
  ├── vulnerabilityScanner()   — on mission request (incl. app-level inventory)
  ├── unifiedLogCollector      — macOS Unified Log (mission-gated, darwin)
  ├── complianceScanLoop()     — CIS-like compliance checks (mission-gated, Linux)
  ├── edrIndicatorLoop()       — EDR indicator scan (always-on, Linux/Windows)
  └── selfIntegrityLoop()      — self-integrity / anti-tamper (always-on)

Main loop (queue processing):
  queue.jsonl → (5s) → .work → validate → OpenSearch → delete
  docker.queue.jsonl → (5s) → .work → validate → OpenSearch → delete

:::info [Dynamic collectors] The agent regularly loads its configuration from the backend (configSyncLoop). On configuration changes, new collector goroutines are started or existing ones stopped — without restarting the agent. :::


Data Collectors

CollectorCollected DataInterval / Trigger
System MetricsCPU, RAM, Disk, Network, Loadevery 10 seconds (configurable)
Docker EventsContainer Start / Stop / Diereal-time (stream)
K8s CollectorPods, Nodes, Deployments, PVCsconfigurable
Vuln ScannerSoftware (OS packages + app-level: pip/npm/.NET/containers), open ports, system infoon mission request
System InventoryApps, users, processes, network connectionsevery 15 minutes
Shell CommandsZSH/Bash hook: command + exit codereal-time
File Monitor (FIM)file changes, baseline, watched pathsconfigurable
Audit Collectoraudit log entriesreal-time
Event Log (Windows)Windows Event Logreal-time (journald connector)
Journald Collectorsystemd journald eventsreal-time (Linux)
EDR Indicator Scanmalware/rootkit/injection indicators (deleted-exe, tmp-exec, rwx-mapping, SUID)every 5 min (always-on, Linux/Windows)
Self-Integritybinary hash + permissions of install/data dir (anti-tamper)every 5 min (always-on)
macOS Unified Loglog stream events → ECSreal-time (mission-gated, macOS)
Compliance Scan26 CIS-like hardening checks (profile imvee-linux-hardening-v1)every 1 h (mission-gated, Linux)

:::info [Shell Commands Collector] The Shell Commands Collector uses a ZSH hook and is platform-dependent. The macOS implementation is located under platforms/darwin/. :::


Enterprise Collectors (DEV-130–136)

Since 2026-10-14 the agent extends the base collection with enterprise features for hardening, threat detection and compliance. Activation is always-on (mission-independent, env var) or mission-gated (mission config from SOCSuite), depending on the feature:

FeatureActivationECS event.dataset
Always-on baseline sourcesIMVEE_ALWAYS_ON_SOURCES (default shell_commands)(affected source collectors)
Self-integrity / anti-tamperalways-onself_integrity
EDR indicator scanalways-on (Linux/Windows)edr_indicators
macOS Unified Logmission (unified_log), darwinmacos_unified_log
On-demand PCAPremote command via WebSocket— (file, chunked fetch)
Compliance scanmission (compliance), Linuxcompliance
App-level inventorypart of the vulnerability scan(InstalledSoftware payload)

Always-on baseline sources (DEV-130)

IMVEE_ALWAYS_ON_SOURCES keeps the named source keys active independent of the mission config. shouldCollectLogs() counts the baseline as active collection — the no-mission drop path (DEV-80) is unreachable with the default configuration. Details and the source-key list: Configuration — Enterprise Collectors.

Self-integrity / anti-tamper (DEV-131)

selfIntegrityLoop() creates a SHA-256 baseline of the agent's own binary plus permissions/owner of the install and data directories at startup. The periodic check reports self_binary_modified (high), self_binary_missing (critical) and permission changes (medium). The auto-update window is set by the agent itself (handleAutoUpdate): a legitimate binary swap appears as self_binary_replaced_by_update (info) instead of a tamper alarm.

EDR indicator scan (DEV-132)

edrIndicatorLoop() scans (Linux via /proc, Windows via WMI) for: processes from deleted binaries, execution from temp directories, rwx mappings of world-writable files, and SUID/SGID changes (baseline on the first scan, delta afterwards). Deduplication per (PID, action) or (path, mode).

macOS Unified Log (DEV-133)

Darwin-only collector, manages log stream --style json as a subprocess (backoff restart, 1 MB line buffer, like the journald collector). Field mapping: subsystem → log.logger, category → event.module, senderBinary → log.origin, activityID → event.hash, Level → log.level (FAULT→critical, ERROR→error, DEFAULT/INFO→info, DEBUG→debug).

On-demand PCAP (DEV-134)

New package internal/pcap (x/sys only, no new dependency): capture via AF_PACKET/SOCK_RAW on a validated interface, pcap writer (v2.4, EN10MB) with snaplen-65535 truncation. WebSocket commands start_capture / fetch_capture (chunked Base64, 256 KB/chunk, eof flag), both bound to isRemoteCommandsEnabled(). Hard limits via config sanitization: duration 1 s–5 min (default 60 s), max bytes 1–50 MB (default 10 MB). File name agent-generated, retention cleanup via IMVEE_PCAP_RETENTION.

Compliance scan (DEV-135)

complianceScanLoop() runs the profile imvee-linux-hardening-v1 (26 CIS-like checks: sshd, accounts, file_permissions, kernel, services). CheckContext encapsulates all system access (ReadFile/Stat/ReadSysctl/RunCmd/ ReadDir) — fully injectable-testable without a mock OS. Result: 1 event per check + compliance_scan_summary; missing input data = unknown.

App-level vulnerability inventory (DEV-136)

Extends PerformVulnerabilityScan with application-level software (Python pip list --format=json, Node.js npm list -g, .NET dotnet --list-sdks/--list-runtimes, containers = local Docker image metadata). All scanners run with timeouts (15–30 s) + presence checks — missing tools yield an empty result. Flows into the same InstalledSoftware payload; the backend matches via publisher-vendor hints against EUVD/NVD (no API change).


Queue Mechanism

All collector events are first written to a local queue before being sent to OpenSearch. This ensures data persistence during temporary connection interruptions.

flowchart LR
    C["Collectors"] -->|"Events (ECS)"| Q["queue.jsonl"]
    Q -->|"every 5s"| W[".work"]
    W --> V["Validation"]
    V -->|"Batch max 100"| OS["OpenSearch"]
    OS --> D["Delete .work"]

Format: Elastic Common Schema (ECS)

Queue path: Default /var/lib/imvee-satellite/queue.jsonl (configurable via IMVEE_QUEUE)

:::info [Data loss protection] The atomic rename (queue.jsonl → .work) and delayed deletion ensure that events are not lost if the agent crashes during a push — the .work file is reprocessed on the next start (on this path). :::

Queue Drop Behavior (DEV-80)

The queue is append-only and unbounded — it grows until drained. Monitoring hooks report state via the error channel: queue_overflow (> 10,000 lines), queue_stuck (no successful upload), queue_stale (oldest event > 1 h old).

Loss paths and their signals:

Loss pathBehaviorSignal
Upload failure (e.g. rate-limit 429)Affected lines are automatically re-queued — no lossuploadLogs error in the agent log
Malformed JSON lineGoes to the dead-letter file (queue.bad.jsonl) — not ingested into OpenSearchdead-letter warning in the agent log
No active mission / log sourceThe rotated .work file is discarded without upload — the events are lostWARNING: no active log collection … dropped N queued event(s) + heartbeat counters

The last path (e.g. an agent without configured missions) is the only real loss path of the file queue. Since DEV-80 it is no longer silent:

  • WARN log with the count and size of the dropped events (once per loop, not per line)
  • Heartbeat metrics QueueDroppedLines / QueueDroppedBytes (next to QueueSize in metrics — cumulative counters since agent start)

:::warning [Monitoring] If QueueDroppedLines increases, check the agent's mission configuration (are log sources active?) — queued events are being discarded. :::


WebSocket Connection

Agent ──WSS──► socsuite.dev.imvee.de/ws/agents/{id}?token={agentToken}
  • Persistent: The connection stays permanently open (websocketLoop())
  • Bidirectional:
    • Incoming: Missions (e.g. start vulnerability scan) and live commands from SOCSuite
    • Outgoing: Real-time status messages, mission results
  • Automatically reconnects on connection loss

Authentication

REST:       Authorization: Bearer <agentToken>
WebSocket:  wss://.../ws/agents/{id}?token={agentToken}

See Configuration — Token Priority for the origin of the agentToken.


Repository Structure

cmd/
  agent/
    main.go               Entry point — starts all goroutines

internal/
  collector/              Data collectors (metrics, docker, k8s, vuln, inventory)
  breaker/                Circuit breaker (sony/gobreaker)
  metrics/                Prometheus metrics for the agent itself
  queue/                  Queue management
  status/                 HTTP status server
  validation/             Input validation

platforms/
  darwin/                 macOS (sw_vers, airport, ZSH hook)
  linux/                  Linux (netlink proc connector, /proc)
  windows/                Windows (WMI, Windows Service, own go.mod)

scripts/
  remote-install.sh       Primary installer (curl | sudo bash)
  install.sh              Local installer
  update.sh               Update script
  uninstall.sh            Uninstall
  build-release.sh        Multi-arch build + checksums
  agent-doctor.sh         Health check / diagnostics

Dockerfile.k8s            Multi-stage build for Kubernetes DaemonSet
Makefile                  Build targets (build, build-all, test, release)
go.mod                    github.com/IMVEE-SOCsuite/imvee.satellite

Further Reading

On this page