← Latest papers
💻 computer science

State-inferer: LLM-Driven State Machine Extraction and Formal Verification for Secure Protocol Implementations

This paper introduces State-inferer, a white-box framework that integrates program slicing, large language models, and formal model checking to accurately extract and verify protocol state machines from source code, achieving superior transition-level accuracy and uncovering four previously unknown security vulnerabilities in TLS, IKEv2, and SSH implementations.

Original authors: MengCheng Ju, Xi Chen, XieLi Zhang, Mingliang Zhu, Guanping Zhang, Dongliang Zhao, ChunXiang Gu

Published 2026-11-09
📖 6 min read🧠 Deep dive

Original authors: MengCheng Ju, Xi Chen, XieLi Zhang, Mingliang Zhu, Guanping Zhang, Dongliang Zhao, ChunXiang Gu

Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). ✨ This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The security of the digital world relies heavily on the invisible rules that govern how computers talk to one another. These rules, known as network protocols, are designed to ensure that data travels safely from a sender to a receiver, verifying identities and keeping secrets. At their heart, these protocols function like a strict script: a computer must be in a specific condition, receive a specific message, and then move to a new condition before it can proceed. If a computer skips a step or accepts a message while in the wrong condition, the entire system can be compromised, allowing attackers to bypass security checks or steal sensitive information. For decades, security experts have tried to verify that the actual code running on servers follows this script perfectly. However, the code is often messy, filled with hidden variables and complex logic that standard testing tools struggle to map. When the real behavior of a program diverges from its written design, dangerous flaws can hide in plain sight, waiting to be exploited.

A team of researchers at the PLA Information Engineering University has developed a new method to solve this problem, creating a tool called State-inferer that acts as a translator between complex computer code and the logical rules it is supposed to follow. Instead of trying to read the entire codebase at once or guessing how a program behaves by sending it random messages, this tool breaks the code down into tiny, manageable pieces. It uses a technique called program slicing to trace exactly how a specific piece of data changes as it moves through the software, isolating the precise logic that causes a computer to switch from one state to another. This process is like tracing a single thread through a tangled ball of yarn to see exactly where it leads, ignoring the rest of the mess. By focusing on these specific threads, the system can reconstruct the exact sequence of events a program follows, including the hidden internal conditions that standard tools often miss.

The researchers then fed these reconstructed sequences into a large language model, a type of artificial intelligence trained to understand and reason about code. Unlike previous attempts that simply asked the AI to read large chunks of text, this system provided the AI with one small, focused fragment of code for every single transition in the protocol. This allowed the AI to see the full context of a state change without getting overwhelmed by irrelevant information. The AI then built a complete map of the program's behavior, noting not just what messages triggered a change, but also the internal variables that had to be true for that change to happen. Finally, the researchers used a formal verification engine to check this map against the official security rules. This engine acts like a rigorous auditor, systematically testing every possible path the program could take to see if it ever violates the rules, such as sending data before a secure connection is fully established.

When tested on seven different open-source implementations of major security protocols, including TLS, IKEv2, and SSH, the new method proved to be remarkably accurate. It correctly identified the behavior of the code with a precision of 95.2 percent, significantly outperforming the best existing tools, which managed only about 78.9 percent. The difference was not just a matter of minor errors; the new tool successfully captured complex internal logic that other methods completely missed, such as transitions driven by internal timers or resource checks rather than external messages. In fact, the researchers found that older methods often failed to see nearly half of the critical transitions because they relied on a simplified view of the program that ignored these internal details. By capturing the full picture, the new tool was able to uncover four previously unknown vulnerabilities in the software. These flaws, which had never been discovered before, were serious enough to be assigned official security identifiers and reported to the software maintainers for fixing.

One of the most significant findings was that the flaws were not just theoretical possibilities but real, exploitable weaknesses. In one instance, the tool discovered that a server could be tricked into accepting a critical security message before it had finished the necessary key exchange, effectively bypassing authentication. In another case, a missing check allowed a server to process an endless stream of messages, potentially exhausting its resources. These discoveries highlight a critical gap in how software is currently analyzed: looking only at the input and output is not enough to understand how a program truly works. The researchers demonstrated that by combining precise code analysis with the reasoning power of artificial intelligence, it is possible to build a complete and accurate model of a program's internal logic. This approach does not require the software to be modified or the researchers to manually trace every line of code, making it a scalable way to audit the complex systems that protect our digital infrastructure.

The study also addressed the limitations of previous approaches that relied on retrieving code based on text similarity. Those methods often failed because they could not connect the dots between different functions that worked together to change a program's state. The new system, by contrast, follows the actual flow of data and control, ensuring that the context provided to the artificial intelligence is complete and connected. This allowed the system to generate security checks that were tailored specifically to the variables and logic of each unique implementation, rather than applying a generic template that might miss the mark. The result is a framework that can adapt to the quirks of different coding styles and still produce a reliable model of the system's behavior.

Ultimately, this work represents a shift in how we approach software security. It moves away from the idea that we must either manually inspect every line of code or rely on black-box testing that can only see the surface. Instead, it offers a way to see inside the machine, understanding exactly how it thinks and reacts. The researchers found that by treating the code as a set of logical steps that can be sliced, analyzed, and verified, they could find errors that had been hiding for years. While the tool was tested on open-source projects, the method suggests a path forward for securing the vast array of proprietary systems that run the internet. The ability to automatically extract and verify the state machines of complex protocols means that security can be checked more thoroughly and more quickly than ever before, potentially preventing the kinds of breaches that have plagued the digital world for decades. The findings confirm that the gap between what a protocol is supposed to do and what it actually does is where the danger lies, and that closing this gap requires a deeper, more precise look at the code itself.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →