SAQL: A Stream-based Query System for Real-Time Abnormal System Behavior Detection

Peng Gao, Xusheng Xiao, Ding Li, Zhichun Li, Kangkook Jee, Zhenyu Wu, Chung Hwan Kim, Sanjeev R. Kulkarni, Prateek Mittal

Advanced Persistent Threats (APTs) are the nightmares of the cybersecurity world. Unlike a simple virus, an APT is a slow-motion car crash—a sequence of subtle steps across multiple hosts that can take months to unfold. Detecting them requires monitoring every system call across an entire enterprise, creating a "big data" problem that traditional security tools struggle to handle in real-time.

In this paper, researchers from Princeton and NEC Labs present SAQL (Stream-based Anomaly Query Language), a system designed to give security analysts the power to define and detect complex abnormal behaviors as they happen, rather than weeks after a breach.

TL;DR

SAQL is a domain-specific language and execution engine that enables real-time detection of complex cyber-attacks by processing massive streams of system events. It allows analysts to combine rule-based, time-series, invariant, and outlier-based anomaly models into a single, highly efficient query system that scales to thousands of hosts.

What Problem Does This Paper Address?

Modern enterprises generate staggering amounts of monitoring data—roughly 50GB per day for every 100 hosts. To catch an APT, you need to look at this data as a continuous stream of "provenance" (who did what to what).

The authors identify three major gaps in current solutions:

  1. Time-Criticality: Attacks need to be stopped during the exploitation phase, not discovered during a post-mortem.
  2. Expert Knowledge Integration: There is no easy way for a security expert to translate their intuition (e.g., "it's weird if a web server suddenly starts spawning shell processes") into a formal, high-performance query.
  3. Model Diversity: Most existing systems are "one-trick ponies"—they might be good at finding statistical outliers but terrible at following a specific sequence of rules.

Methods

The core of the paper is the SAQL Language and its Execution Engine.

The Language

SAQL uses a {subject-operation-object} syntax (e.g., proc p1 write file f1). It stands out by supporting four distinct types of anomaly models:

  • Rule-based: Detecting known "bad" patterns (e.g., a specific sequence of file accesses).
  • Time-series: Using sliding windows to find spikes (e.g., a process suddenly sending 10x more data than its 3-period moving average).
  • Invariant-based: Learning "normal" behavior during a training phase and alerting on deviations (e.g., an Apache process spawning a java.exe child for the first time).
  • Outlier-based: Comparing "peers" to find the odd one out (e.g., one SQL server connecting to an unusual IP address compared to other SQL servers).

The Engine: Master-Dependent-Query Optimization

Standard stream processors (like Siddhi or Esper) often struggle with scalability because they treat every query as a separate task, often copying the entire data stream for each one.

SAQL introduces a Master-Dependent-Query scheme. It identifies queries that share the same "spatial" (which hosts) and "temporal" (which time windows) attributes. It then designates a "Master Query" to perform the heavy lifting of pattern matching and state maintenance, feeding the intermediate results to "Dependent Queries." This drastically reduces memory overhead and redundant computation.

Datasets

The authors evaluated SAQL in a real-world environment at NEC Labs America:

  • Scale: 150 hosts (servers and workstations).
  • Volume: 1.1 TB of real system monitoring data containing 3.3 billion events.
  • Platforms: Data was collected across Windows (ETW), Linux (Auditd), and macOS (DTrace).
  • Benchmarks: They tested the system against 17 complex attack scenarios (including APTs, SQL Injection, and Shellshock) and 64 micro-benchmarks.

Key Insights and Ideas

  • Unified Anomaly Modeling: The biggest "aha" moment is the realization that security isn't just about one type of math. By providing a DSL that handles both logic (rules) and statistics (outliers/time-series) in one place, SAQL bridges the gap between security analysts and data scientists.
  • Stateful Windows: SAQL allows queries to reference past states directly (e.g., ss[1] for the previous window). This makes calculating moving averages or detecting "first-time" events trivial for the user.
  • The Power of Sharing: In a security context, many queries look for the same "base" events (like all network connections). Exploiting this overlap via the Master-Dependent scheme is what allows the system to scale to enterprise levels on a single server.

Key Results

  • Performance: The system achieved a throughput of 110,000 events per second on a single 12-core server.
  • Latency: Alert detection latency was consistently under 2 seconds, and often less than 10ms for simpler queries.
  • Scalability: Based on their 150-host deployment, the authors estimate a single SAQL server can support approximately 4,000 hosts.
  • Efficiency: The Master-Dependent optimization resulted in a 30% memory saving compared to the state-of-the-art Siddhi engine.

Limitations and Future Work

  • Centralization: While efficient, the current engine runs on a single server. The authors suggest that for massive global enterprises, the system would need to be integrated with distributed frameworks like Apache Storm.
  • Data Granularity: The current model focuses on high-level system calls. It doesn't yet look at finer-grained details like "pipes" in Linux or specific in-memory manipulations, which could be used by even more sophisticated attackers.
  • Alert Fusion: SAQL detects individual anomalies. A logical next step is "Alert Fusion"—automatically chaining these individual alerts into a cohesive "attack story" to reduce alert fatigue for analysts.

Summary updated

BibTeX
@inproceedings{gao2018saql,
  author = {Peng Gao and Xusheng Xiao and Ding Li and Zhichun Li and Kangkook Jee and Zhenyu Wu and Chung Hwan Kim and Sanjeev R. Kulkarni and Prateek Mittal},
  title = {{SAQL: A Stream-based Query System for Real-Time Abnormal System Behavior Detection}},
  booktitle = {USENIX Security},
  year = {2018},
}
Figure