When must a digital twin intervene to keep a physical process safe under attack?
HyTwin connects formal verification with experimental CPS security. It brings together adversarial hybrid-system models, safety-preserving interventions, and trace-based evaluation on a PLC-driven water-treatment testbed. Its central idea is the mitigation horizon: the time available to act before a safety condition can no longer be preserved by the modeled mitigation.
Research artifact for HyTwin: Hybrid Program Semantics for Digital Twin-Based Security Interventions in Industrial Control Systems, Jainta Paul, Stefan Mitsch, and Luis Garcia, NASA Formal Methods (NFM 2025). Author PDF · Paper-to-artifact map · Formal models and proofs · Research showcase
Experimental trace collection and validation: the companion OpenPLC Mini Water Treatment Testbed was used to collect and validate the process traces for HyTwin's water-treatment evaluation. Together, the repositories connect mathematical attack models and intervention deadlines to instrumented PLC experiments. Explore the experimental infrastructure.
A compromised PLC command can become a physical safety hazard. This animation follows the same actuator attack under three response strategies: no intervention, timely shutdown, and delayed shutdown. Timely action keeps the receiving tank inside its safety limit; late action stops the flow after the limit has already been exceeded. This is the practical motivation for HyTwin's mitigation horizon: knowing how much time remains to protect the physical process.
Watch or download the 30-second MP4 · View the still image · Animation source and reproduction
The animation uses the repository's synthetic model traces and schematic tank geometry. It illustrates overflow risk, without modeling actual spill volume or presenting original testbed footage. The companion OpenPLC testbed provides the experimental trace collection and validation infrastructure.
- PLC-based experimental foundation: the companion miniwatertreatment repository provides OpenPLC controller projects, physical I/O integration, attack scripts, and multi-PLC trace collection tooling used in the trace collection and validation workflow.
- Nine newly reconstructed, machine-checked dL obligations, including unbounded nominal two-tank safety, attack/monitor properties, and fixed-flow horizon/shutdown properties. KeYmaera X 5.1.2 + Z3; source, logs, generated lemmas, and checksums.
- A dependency-free executable demonstration: six scenarios, exact constant-rate evolution within each scan, a response-delay sweep, and CSV/JSON/SVG outputs.
- 44 original historical files recovered from Git, preserved with commit IDs and SHA-256 hashes. These include attack models, Structured Text, process prototypes, and historical logs. Recovery record.
- Explicit provenance separating surviving originals, recovered drafts, new reconstructions, and missing experimental evidence.
Artifact status: the experimental collection and validation infrastructure is available in the companion testbed repository. The exact original Figure 2/3 recordings and original proof-session exports are not included in this HyTwin checkout. This repository combines historical material with new reconstructed proofs and a synthetic demonstration. The new proofs certify their written models under explicit assumptions; deployed hardware safety and the complete abstract shield theorem remain outside their scope.
The research connects three levels of evidence: attack and plant models, machine-checked safety reasoning, and experimental process traces. The companion testbed supplies the PLC and instrumentation context for collecting and validating those traces, while HyTwin formalizes the relationship between adversarial behavior, physical safety, and the deadline for intervention.
The experimental infrastructure includes PLC1, PLC2, and PLC3 controller projects, attack scenarios, and trace generators. Its multi-PLC collector records timestamped sensor measurements and actuator states through Modbus TCP. This makes the work relevant to both formal methods research and experimental industrial security engineering.
From the repository root, using Python 3.10+:
python3 -m hytwin demo --output results/demo
bash check_all.shNo pip packages, datasets, Docker, MATLAB, Wolfram account, or hardware are required for this path. bash setup.sh also generates the demo. Checked-in outputs are available for inspection without running anything.
| Scenario | Behavior | Outcome with chosen demo parameters |
|---|---|---|
nominal |
Paper Example 1 controller, no attack | Safe |
direct-unmitigated |
Force first inflow valve v1=1 |
Overflow after boundary at 14 s |
direct-mitigated |
Same attack; trusted shutdown after 2 s | Safe |
transfer-unmitigated |
Force transfer pump and valve p2=v2=1 |
Overflow after boundary at 17 s |
transfer-mitigated |
Same attack; trusted shutdown after 2 s | Safe |
transfer-late |
Same attack; shutdown after 16 s | Safety violation before shutdown |
Both attacks start at 2 s. Closed level bounds make boundary contact safe; continuing adverse flow beyond the boundary violates safety. Shutdown freezes the current levels, so acting late cannot undo an earlier violation.
Explore the response deadline yourself:
python3 -m hytwin run --attack transfer --delay 15 --output results/local/on-boundary
python3 -m hytwin run --attack transfer --delay 15.01 --output results/local/too-lateThe first stays safe in this ideal model. The second waits until the next 0.25 s scan and violates safety. Timing, assumptions, schema, and exact expected results.
With Java 17+ and Linux/Bash tools:
bash scripts/check_models.sh --download --proveThis downloads the official pinned KeYmaera X 5.1.2 JAR, validates its checksum, and replays all nine new proofs using bundled Z3. With an existing JAR, set KEYMAERAX_JAR=/absolute/path/keymaerax-5.1.2.jar and omit --download. Fresh results go to results/proofs/local/.
| Formal artifact | Checked scope |
|---|---|
| Nominal tank | Two-tank loop safety, nondeterministic bounded flows and scan durations |
| Attack and mitigation | Five actuator, monitor, and bounded sensor-spoof obligations |
| Mitigation horizon | Three constant-flow horizon, maximality, and on-time shutdown obligations |
The formal-model guide states assumptions and transcription corrections and distinguishes positive signature matches from complete attack coverage. A matching actuator command can also occur benignly. The executable demo schedules response from a known injected attack window and signature observation; it is not an intrusion-detection benchmark or an automatically synthesized ModelPlex monitor.
flowchart LR
A[Plant + PLC model] --> B[Safety and attack analysis in dL]
B --> C[Attack signature + mitigation + deadline]
C --> D[Observe runtime state]
D --> E[Evaluate signature and time budget]
E --> F[Trusted intervention]
F --> A
The paper's first-valve running example and its transfer-pump hardware experiment are distinct cases. This reconstruction keeps their models and demo names separate. For constant adverse level rate q>0 with no effective outflow, the simple horizon witness is tau=(HH-x0)/q. Variable flows, lower-bound hazards, actuation delays, and model mismatch require additional analysis.
| Path | Purpose |
|---|---|
hytwin/ |
New Python model, scenario runner, and report generation |
models/ |
New dL models and replayable tactics |
results/demo/ |
Synthetic traces, summary, 81-point delay sweep, overview, hash manifest |
assets/media/ |
Illustrative GIF, MP4, still image, and media provenance manifest |
scripts/render_animation.py |
Rebuild the animation directly from the checked-in synthetic traces |
results/proofs/ |
Checked proof evidence and verification metadata |
tests/ |
Physical invariants, timing boundaries, failure cases, and evidence integrity |
docs/paper-map.md |
Exact mapping to paper definitions, examples, and figures |
docs/experimental-testbed.md |
Companion PLC testbed used for experimental trace collection and validation |
docs/animation.md |
Animation narrative, numeric anchors, provenance, and optional rendering dependencies |
docs/showcase.md |
Portfolio framing, resume language, and interview walkthrough |
legacy/recovered/ |
Original deleted files restored byte-for-byte with provenance |
Archive/securityformalization.kyx |
Surviving original draft, unchanged |
scadman_monitor_swat.py |
Surviving exploratory monitor, unchanged; not part of validated demo |
The previous Docker/Wolfram setup is preserved in legacy/. The root Dockerfile runs only the new portable demo:
docker build -t hytwin-demo .
mkdir -p results/local/container
docker run --rm -v "$PWD/results/local/container:/results" hytwin-demoFor a research audience, frame this as formal verification and experimental validation of timed security interventions for industrial CPS. The differentiator is connecting an attack's physical consequences to a model-derived intervention deadline, backed by an instrumented water-treatment research platform. Use the showcase guide for a project description, resume bullets, and a three-minute technical walkthrough.
The most valuable extensions are to package experiment-specific traces and configurations alongside the available testbed infrastructure, prove monitor coverage for a richer attack class, and incorporate bounded sensing and actuation delay. Each would extend a concrete boundary of the present evidence.
Citation metadata is in CITATION.cff. Preserve original author credits and any file-level third-party notices. No new blanket license is assigned to the historical multi-author material in this reconstruction.
