Learning from Mutants: Using Code Mutation to Learn and Monitor Invariants of a Cyber-Physical System

Yuqi Chen, Christopher M. Poskitt, Jun Sun

TL;DR

This paper introduces a novel method for automatically learning "invariants" – essential physical properties – of cyber-physical systems (CPS) by using machine learning on data from mutated software components. This approach successfully detects a high percentage of simulated network and code-modification attacks on a water purification system, offering a practical way to monitor CPS integrity.

What Problem Does This Paper Address?

Cyber-physical systems (CPS) are complex integrations of software and physical processes, found everywhere from industrial control to autonomous vehicles. Their interconnected nature makes them vulnerable to attacks that can compromise software, networks, or sensors, potentially leading to significant damage. Detecting these attacks in real-time is challenging because building accurate models of CPS behavior, especially the intricate physical dynamics, is extremely difficult, even for domain experts. This paper tackles this challenge by proposing an automated way to learn these crucial system invariants, which can then be used for monitoring and detecting malicious activities.

Methods

The core of the paper's approach lies in a three-step process:

  1. Generating Mutants and Traces: Instead of manually creating attack scenarios, the authors systematically introduce small, subtle code changes ("mutations") into the CPS's control software (PLCs). These mutated programs, along with the original, are then run to generate both "normal" and "abnormal" data traces (sequences of sensor readings). This mutation-testing-inspired technique aims to mimic how an attacker might subtly alter the system.
  2. Feature Vector Extraction and Learning: From these traces, feature vectors are extracted. These vectors capture snapshots of system states at fixed time intervals, allowing the model to learn temporal patterns. A supervised machine learning algorithm, specifically Support Vector Machines (SVM) with an RBF kernel, is then trained on these feature vectors. The SVM learns to distinguish between normal and abnormal behavior based on the data generated from the mutated code.
  3. Classifier Validation: The learned classifier is validated to ensure it represents a true physical invariant of the system. This involves standard k-fold cross-validation for generalization assessment and, crucially, Statistical Model Checking (SMC). SMC uses hypothesis testing on observed system executions to provide statistical evidence that the classifier correctly identifies normal behavior with high probability.

Datasets

The primary dataset used in this research is derived from the Secure Water Treatment (SWaT) simulator. SWaT is a scaled-down, operational water purification plant testbed. The authors generated their own datasets by:

  • Running the SWaT simulator with its original PLC code to collect "normal" traces.
  • Running the SWaT simulator with systematically mutated PLC programs to collect "abnormal" traces.
  • Simulating 55 specific network and code-modification attacks on the SWaT simulator.

No new benchmark datasets were introduced; instead, the authors leveraged the SWaT simulator and a benchmark of attacks previously performed on the SWaT testbed.

Key Insights and Ideas

  • Mutation Testing for Anomaly Detection: The paper ingeniously repurposes mutation testing, typically used for software testing, to generate realistic "abnormal" data for training anomaly detection models in CPS. The idea is that subtle code changes can lead to subtle but detectable physical deviations.
  • Supervised Learning for Invariant Discovery: Unlike many unsupervised anomaly detection methods, this approach uses labeled data (normal vs. abnormal, generated via mutations) to train a classifier. This allows the model to learn a more precise boundary between normal and abnormal behavior.
  • RBF Kernel's Superiority: The experiments revealed that a Radial Basis Function (RBF) kernel for SVM significantly outperformed linear and polynomial kernels, highlighting the complex, non-linear relationships between sensor readings in CPS that simpler models struggle to capture.
  • Physical Attestation Potential: The learned invariants can serve as a form of "physical attestation," verifying the integrity of the CPS by checking if its physical behavior aligns with expected norms, even without direct access to firmware or hardware.

Key Results

  • Attack Detection Rate: The learned invariant successfully detected 85% of the 55 simulated network and code-modification attacks.
  • Classification Accuracy: The SVM-RBF classifier achieved a high accuracy of 91.05% and cross-validation accuracy of 90.99% when trained on data from 600 mutants and a 250ms time interval for feature vectors.
  • Network Attack Detection: All 15 implemented network attacks were successfully detected, with most achieving accuracies around 90% or higher. Attacks involving slow manipulation (1mm/sec) were detected "eventually" with high accuracy.
  • Code Modification Attack Detection: The system detected 32 out of 40 randomly generated code modification attacks. The missed attacks were those with limited physical effects.

Limitations and Future Work

The authors acknowledge several limitations:

  • Dataset Specificity: The evaluation was limited to the SWaT simulator, raising questions about the generalizability of the approach to other CPS.
  • Initial Configurations: The use of a fixed set of initial configurations for data generation might have missed rare but potentially important behaviors.
  • Realistic Attackers: The code modification attacks were randomly generated. Real attackers might employ more sophisticated strategies.

Future work suggested includes:

  • Addressing Invariant Complexity: Developing methods to simplify learned invariants for stronger validation techniques like symbolic execution.
  • Real-World CPS Application: Adapting the approach for actual CPS testbeds (like the SWaT testbed) and reducing data collection overhead.
  • More Effective Mutations: Using domain knowledge to focus mutation operators on parts of the PLC code more likely to yield useful abnormal traces.
  • Generalizability: Implementing and evaluating the approach on diverse CPS applications beyond water treatment.
  • Comparison with Unsupervised Methods: Further clarifying the trade-offs between the overhead of supervised learning (mutant generation) and the potential benefits in accuracy and detection capabilities compared to unsupervised methods.

Summary updated

Abstract

Cyber-physical systems (CPS) consist of sensors, actuators, and controllers all communicating over a network; if any subset becomes compromised, an attacker could cause significant damage. With access to data logs and a model of the CPS, the physical effects of an attack could potentially be detected before any damage is done. Manually building a model that is accurate enough in practice, however, is extremely difficult. In this paper, we propose a novel approach for constructing models of CPS automatically, by applying supervised machine learning to data traces obtained after systematically seeding their software components with faults ("mutants"). We demonstrate the efficacy of this approach on the simulator of a real-world water purification plant, presenting a framework that automatically generates mutants, collects data traces, and learns an SVM-based model. Using cross-validation and statistical model checking, we show that the learnt model characterises an invariant physical property of the system. Furthermore, we demonstrate the usefulness of the invariant by subjecting the system to 55 network and code-modification attacks, and showing that it can detect 85% of them from the data logs generated at runtime.
BibTeX
@inproceedings{chen2018learning,
  author = {Yuqi Chen and Christopher M. Poskitt and Jun Sun},
  title = {{Learning from Mutants: Using Code Mutation to Learn and Monitor Invariants of a Cyber-Physical System}},
  booktitle = {IEEE Symposium on Security and Privacy},
  year = {2018},
  url = {https://openreview.net/forum?id=vnxxY3bsjv},
}
Figure