cs.CRNov 24, 2026

Real Package, Wrong Controller: Static Auditing of Vendor--Protocol Mismatches in LLM-Generated PLC Code

Authors: S M Zia Ur Rashid, Sazidul Islam Hira, Suman Rath

Organizations: Department of Electrical and Computer Engineering, The University of Tulsa, Tulsa, OK, USA · Department of Computer Science and Engineering, International Islamic University Chittagong, Chittagong, Bangladesh

Abstract

Language models can generate Python that drives industrial protocols on programmable logic controllers, yet existing code-grounding checks ask whether an imported package or symbol exists rather than whether it suits the declared industrial target. We define metadata-conditioned, import-level vendor--protocol incompatibility and build Proteus-OT, a label-free static verifier over a version-pinned graph of documented bindings. Across 883 generated scripts, 180 carry an import-level mismatch against the declared target (20.4%); restricting to single-vendor targets gives 16.3%, and additionally requiring the offending library to reach a protocol communication call gives 14.2%, which we read as conditional on the corpus metadata rather than on verified intent. None of the 28 adjudicable human control files carries one, a sample too small to estimate a prevalence. Within the balanced subset, 96.6% of mismatching scripts import packages and call methods that exist, so an existence baseline does not represent them, and every positive ships with an inspectable witness. We also audit machine-versus-human classification on the same corpus, where character nn-grams reach macro-F1 1.000 under task, model and vendor-disjoint partitions and survive comment removal, an AST round trip and identifier anonymisation. The trailing newline present in 95.2% of human files and in none of the generated ones separates the classes on its own. Vendor--protocol consistency is a useful static audit target, whereas provenance classification on repository-labelled corpora is not authorship detection.

Figures & tables

Explore similar work

Nov 17, 2026

Trace2ST: Recovering PLC Structured Text from I/O Traces with LLM Generation and Verification

Programmable logic controllers (PLCs), the industrial computers that operate power and process plants, often run programs whose source code is no longer available; however, every input and output of the controller is logged continuously. This paper therefore asks whether a large language model (LLM) can recover an executable program in Structured Text (ST), the standard PLC language of IEC 61131-3, from such input/output records (traces) alone and, equally important, how the recovered program can be verified. To answer this question, we build a generate-replay-feedback pipeline. First, the LLM writes a candidate program from a compressed summary of the trace, without ever seeing the original program. The candidate is then executed one control cycle (scan) at a time and compared with the recording, and whenever a mismatch occurs the corresponding part of the trace is returned to the LLM, for at most three revisions. Because every result depends on the software that executes the candidates, we first validate it against two independent open-source PLC runtimes and find no unexplained difference. On this basis, we evaluate 47 third-party programs from two public benchmarks. The recovered programs reproduce the recorded trace exactly in 43 cases and agree with the original on 94% of scans for unseen inputs. The remaining errors, however, lie mostly in program branches that the trace never exercised; once a trace that targets these branches is added, agreement on unseen adversarial inputs rises from 0.80 to 0.98. By contrast, a classical automata-learning baseline without an LLM fits the recording but falls to 0.40 on unseen inputs, which indicates that recovering program structure is the hard part. Finally, on real data from a public water-treatment testbed, the recovered control laws match unseen measurements closely (R2>0.99R^2 > 0.99) and expose the only actuator attack in the dataset.
Oct 2, 2026

PLCWorld: Benchmarking LLM-Generated PLC Programs in Closed-Loop Plant Simulation

Programmable logic controllers (PLCs) coordinate industrial equipment through sensor inputs and control commands. Evaluating LLM-generated PLC programs requires observing device and workpiece states to assess task completion and safety. We introduce PLCWorld, a closed-loop execution environment and benchmark coupling Structured Text (ST) execution with simulated plant responses and sensor feedback. Grounded in control relations from industrial PLC programs and engineering documentation, PLCWorld contains 100 synthetic tasks and 473 registered task-condition pairs across Motion Control and Material Handling, with difficulty defined by control-dependency scope. It reports Task Success and Safety Violation separately. Execution Gap measures the fraction of cases with task failure or observed safety violation among those assigned to programs passing a common submission-profile and I/O check. Validation combines practitioner review, reference and alternative programs, 542 targeted counterexamples, alignment checks, and independent ST runtime comparisons. Across six LLMs and four adapted generation-and-verification workflows, direct GPT-5.5 achieves 83.96% Task Success on Easy cases but 24.51% on Hard cases. The workflows show no consistent plant-level gains, and failures persist after upstream acceptance. Our code is available at https://yunji0516.github.io/PLCWorld/.
Nov 3, 2026

Verified but Vacuous: Three Failure Surfaces of LLM-Driven Verified Code Generation

What should ``verified'' mean when evaluating LLM-generated code? Many existing pipelines report a single verification number. We argue this collapses three distinct properties measured in a conditional audit sequence: verifier acceptance (Surface A), \emph{syntactic specification binding (Surface B: does the proof obligation bind to the spec?), and semantic specification fidelity (Surface C: does the spec capture the informal requirement?). Two empirical demonstrations show the surfaces separate. \textbf{First (A≠BA \neq B), via Li@Opus (a same-model reproduction of \citet{li2025dafny}'s Dafny-as-intermediate-representation (IR) pipeline under Claude Opus 4.7) on three Python benchmarks}: it reaches 99.1% verifier acceptance on HumanEval while only 1.9% carry a certificate binding to a spec-defined predicate or function. \textbf{Second (B≠CB \neq C), via VCG on two Rust benchmarks}: we use VCG (which is our own in-house Dafny-as-intermediate pipeline) on Rust because the Rust target lets us enforce fully-verifiable output (every component ships as a Dafny certificate, ensures-binding gate passing by construction). Even inside that construction, 11.48% (MBPP-Rust) and 14.82% (VeriContest LC slice) of structurally-verified samples still fail hidden tests. On the LC slice of VeriContest, VCG's reported End2End rate is 7.79% (535/6870). The cited external rates are 5.51% (GPT-5.5) and 1.88% (single-shot Opus 4.7). These give descriptive differences of 2.3 percentage points and 4.14×\times, respectively; task-budget, repair and harness differences prevent a matched-performance claim.