Manuscript Offprint

arXiv:2609.10537

Towards Tackling Application Logic Flaws through Autonomous Formal-Logic Modeling and Automated Reasoning

Yiwei Fang, Yichen Liu, Ze Jin, Haoqiang Wang, Qixu Liu, Luyi Xing

Yiwei Fang*, Yichen Liu†, Ze Jin*, Haoqiang Wang*, Qixu Liu*, Luyi Xing†,

*Institute of Information Engineering, Chinese Academy of Sciences

ph4ng0t@rustysnow.org, jinze@iie.ac.cn, wanghaoqiang@iie.ac.cn, liuqixu@iie.ac.cn

†University of Illinois Urbana-Champaign

yichen59@illinois.edu, lxing2@illinois.edu

Abstract—Logic flaws pose significant challenges in the design and implementation of modern, semantically rich systems and applications, impacting security, privacy, and trust. These flaws are inherently tied to business-specific semantics and threat models, making their discovery and reasoning difficult and hard to scale. Real-world systems often exhibit diverse application features, complex protocol logic, and domain-specific threat models, necessitating substantial human effort and domain expertise for effective security analysis. In this paper, we introduce LL-Verifier, a novel, automated framework for identifying logic vulnerabilities built on (1) large language models for autonomous modeling, and (2) logic model checkers for rigorous reasoning. LL-Verifier processes natural language inputs, in particular protocol descriptions and security goals, to automatically generate formal logic models and properties expressed in a new logic language built on a generic logic language Maude, optimized for modeling arbitrary application-level semantics. These formal models are then converted into logical state machines, enabling exhaustive, rigorous verification through logic level model checking. This approach streamlines the analysis of diverse, application-level protocols deployed in real-world scenarios, offering automated, exhaustive, and precise reasoning within their logical constraints. We evaluated the high effectiveness, efficiency, and practicality of LL-Verifier by applying it to 27 access control protocols of widely used IoT devices, which come with vendor-specific logic flows and semantics. While LL-verifier tackles a hard problem in application security, i.e., automatic logic flaws discovery, our analysis uncovers a range of sophisticated logic vulnerabilities in IoT protocols and devices with serious security and privacy implications.

1. Introduction

Logic vulnerabilities, known as logic flaws or business logic errors [1], [2], represent a critical challenge in designing and implementing modern semantic-rich systems, affecting security, privacy, and safety. Unlike programming bugs, these vulnerabilities arise from design-level weaknesses, such as flawed reasoning or incorrect assumptions in specific semantic contexts, targeting contextual logic rather than code-level errors [3]. Consequently, they often evade

traditional detection techniques like static analysis, dynamic analysis, and fuzzing [3]–[9]. These flaws have severe implications in domains like communication protocols, military systems, and financial infrastructure, leading to unauthorized access, data corruption, and operational disruptions. For example, a 2023 logic vulnerability in Newag trains in Poland caused disruptions when third-party service providers unintentionally triggered manufacturer-enforced logic controls [10], [11]. This case, uncovered by the ethical hacking group Dragon Sector, underscores the operational and financial risks posed by logic vulnerabilities in critical systems.

Challenges for detecting flaws in application-level logic. Given an application or application-level protocol which usually comes with context-specific, domain-specific semantics, prior formal methods based techniques including model checking [12]–[17] and logic reasoning [18]–[25] struggle to scale and adapt to this diversity, leaving many logic vulnerabilities undetected in complex, real-world applications, software, and cyber-physical systems. These limitations emphasize the need for novel approaches that can systematically reason about logic vulnerabilities across varied semantic contexts.

Our research focuses on flaws at the “application level” (application logic, application-level protocols), in contrast to the “cryptography level.” In those prior works, modeling a specific system, application or underlying protocols involves identifying domain-specific, context-specific semantic elements that should be modeled, and deciding how to model these semantic elements (e.g., defining data structures and operations using the syntax supported by a modeling language) [26]–[30]. Existing formal modeling approaches struggle with automation, generality, and scalability. The prior modeling process has generally (1) relied heavily on manual effort or domain experts for individual systems and protocols, and (2) been highly tailored to specific systems or domains to identify the necessary semantics for modeling. As a result, the resulting model is essentially a domain-specific model (DSM) and prior approaches have been largely unscalable across different applications and semantic domains.

Research goals. To address both this fundamental gap in formal methods and critical security risks in system and pro-tocol designs, this paper introduces a formal logic analysis framework, namely LL-Verifier, a novel LLM-assisted approach for autonomous formal logic modeling and logic flaw reasoning. Given an application-layer protocol design and a customized security goal, LL-Verifier aims to autonomously generate domain-specific models in formal logic, and use logic model checkers to automatically verify the specified goals against the target. Notably, it is not uncommon for protocol implementations to deviate from protocol design due to intentional customization or specification ambiguity [31]–[33]. However, it is critically important to directly analyze protocol designs to identify logic flaws in the system and protocol design itself to elevate design-level security (this research does not focus on flaws in protocol implementations).

Research questions. For the above goals, we summarize specific research questions and their challenges as follows.

RQ1: What formal modeling approach can generally enable autonomous modeling of diverse application-level protocols with diverse and potentially arbitrary semantics? There are two categories of formal logic-based languages: generic logic languages (such as Maude [34], Tamarin [35], Twelf [24], and Prolog [36]) and domain-specific logic language (DSL) [37]. DSL cannot easily adapt to diverse application-layer protocols, thus being highly limited in scope of usage. Generic, foundational logic languages like Maude are highly flexible in syntax and provide capabilities to flexibly define data structures and types used in modeling. However, it is difficult for LLM to accurately generate semantic domain-specific models using highly generic logic languages featuring highly customizable data structures and types, while ensuring that the generated models are ready to or can be verified, in particular, based on state-of-the-art formal model checkers.

This is because it is up to LLM to (1) define data structures and types for complex semantic elements (e.g., non-monotonic mutable states) and (2) implement mutual operations and relations between semantic elements, and consequently the generated models come with low accuracy and effectiveness to feed to state-of-the-art model checkers. Specifically, modeling a protocol is essentially to implement the protocol's core semantics (semantics of interest) using the chosen modeling language. While pure semantic or functionality-level automatic implementation may become practical based on trending code LLM techniques [38], [39], downstream tasks specifically model checking, however, require the modeling in specific paradigms, for instance, as a logically, formally defined state machine with conceptually defined states and transitions. Without such definitions and regulations, model checking with respect to customized or semantic properties (e.g., linear temporal logic or LTL properties) cannot be rigorously defined and verified. To address the problems, this paper designs and implements a novel approach to enable LLM and its agentic systems to autonomously generate DSMs for applications and application-level protocols of various semantics, while ensuring that the models are directly ready to verify for context-specific security goals.

RQ2: How to design a formal logic language and modeling mechanism that can effectively find logic flaws by capturing customized application-level threat models? Security flaws are dependent on assumptions made for the protocol actors, including both benign and threat actors. We dub such assumptions as "threat models," which define the possible behaviors of benign actors and attackers. Model checking is known to exhaustively traverse the entire state space, in which process a transitioning to the next state is triggered by a possible event (e.g., a user action) — this process is known to be non-efficient (sometimes cannot stop) and not truly scalable (e.g., state explosion [40]). When the enumerated user action is unrealistic or outside the scope of a threat model of interest, the model checking process is non-efficient mixed with unuseful results (e.g., out of scope of the given assumption of interest).

Based on the reality of diverse, often domain-specific, semantic-dependent threat models that fundamentally deviate from traditional Dolev-Yao assumptions [3], [27], [29], [41]–[61], the novel challenge and our goal are: (1) designing a generalized logic modeling framework that natively supports domain-specific, custom threat models by easily, explicitly distinguishing deterministic protocol executions from non-deterministic attacker events, and (2) ensuring this threat mechanism is structurally coherent with the core protocol modeling (e.g., events, rules, etc). Thus, the generated threat model in the appropriate modeling language is directly pluggable to the protocol DSM, making the entire model ready for verification. Consequently, the reported violations in DSM model checking strictly adhere to the defined application-level threats, ensuring analysis soundness.

Our approach. To address these challenges, we designed and implemented LL-Verifier, an automatic logical flaw identification framework (§ 3). LL-Verifier introduces an LLM-compatible modeling framework, Les, which features a novel “modeling guardrails” design tailored for LLMs and includes a Les model compiler (§ 2.5). The “modeling guardrails” (FMG) ensure accurate and reliable LLM generation of formal models for application-level protocols. Les is designed with FMG principles, including foundational symbols and types (§ 2.1), State-Transitional Logic Rules for protocol rule modeling (§ 2.2), and Event Generation Rules for event modeling (§ 2.4). The Les compiler translates Les formal models of protocols or applications into a rewrite theory [62], enabling the creation of logical state machines M\mathcal{M} (§ 2.5), and supporting non-monotonic mutable states. This facilitates exhaustive and automatic model checking using off-the-shelf model checkers [63].

Given the textual representation of a protocol and a customized security goal, LL-Verifier reorganizes the information into multiple components and formalizes each of them respectively to Les through the collaborative efforts of Les formalization agents (§ 3.1). By employing LLM in-context learning (i.e., few-shots prompting) [64] and an embedded program analyzer, we ensure the reliability and accuracy of LLM responses (§ 3.2). Based on customized threat models and security goals, LL-Verifier adjusts the determinism/non-determinism of Les rules (§ 3.3.2) and sup-port non Dolev-Yao application-layer threat model. Using LL-Verifier, we specify trace properties in Linear Temporal Logic (LTL). These properties are defined over propositions derived from the same Σ\Sigma and are evaluated against system states (§ 3.3.3). By verifying whether M\mathcal{M} satisfies the negation of a trace property, LL-Verifier produces the corresponding attack traces.

Evaluation and findings. We have used LL-Verifier to model and reason about IoT devices and applications of 28 IoT vendors (such as iRobot, Google Home, Aqara, see Table 2), show that our techniques are effective and practical (§ 4). Specifically, across 27 unique devices, LL-Verifier found 35 logic flaws; this includes 30 previously unknown logic flaws among 23 vendors. We implemented proof-of-concept attacks on real devices of ours for all the new flaws (§ 5). We responsibly reported all zero-day flaws to affected vendors. The Connectivity Standards Alliance (CSA, the organization that manages the emerging IoT standard Matter [65]) and 14 vendors such as August, Philips, and Tuya have acknowledged the flaws and are releasing patches.

To further evaluate coverage and accuracy of LL-Verifier in modeling application-level protocols, we developed Logic-Modeling Bench, a novel benchmark including the textual specifications and formal models of 29 application level protocols, including those of 24 IoT and mobile vendors (such as iRobot, Philips, Tuya) and 5 protocols from prior papers (§ 4). Given those protocols, we evaluate the coverage and accuracy in modeling the protocols' semantics elements, including subjects (i.e., principals, e.g., users, clients, devices, servers), events (e.g., actions and API requests supported in the protocol), attributes of the subjects and events, and protocol rules. Our evaluation shows that LL-Verifier achieved high coverage in modeling semantic elements and high accuracy.

Contributions. We summarize the contributions as follows:

  • New techniques. We present LL-Verifier, a novel approach and tool for autonomous formal modeling of system and application designs of various semantic contexts into domain-specific models (DMSes), and automatically detecting application-level logical flaws based on formal model checking.

  • New benchmark. We introduce Logic-Modeling Bench, the first benchmark to evaluate autonomous formal modeling of application-level protocols with varied semantics across vendors and application domains.

  • New findings. We applied LL-Verifier to model and analyze logic flaws in 27 real devices, uncovering the sophistication and pervasiveness of these flaws in IoT protocols and diverse application scenarios, highlighting the fundamental threats posed by logic flaws, which are difficult to avoid in the design space of IoT systems and potentially other systems.

References (100)

Couldn't load all references. Reload the page to try again.