Marius Fleischer, Alex Matrosov, Nicholas Carlini, Milad Nasr
Logic bugs occur when software behaves in conflict with the implicit rules that govern how it should work (i.e., its invariants). These bugs are harder than usual to discover because developers are limited in the tools they can use to find them. Most general-purpose detection tools rely on general-purpose “bug oracles”—automated checks that recognize incorrect program behavior, like a program crashing or accessing memory incorrectly. Logic bugs, however, do not usually cause these kinds of failures, which means they require different methods. In this post, we describe and evaluate several ways of using LLMs to identify logic bugs. We developed a benchmark of 21 historical (i.e., since-patched) logic bugs that we collected from the change history of open-source codebases, and then tested out several new methods. Across our testing, simpler techniques—such as using LLMs to perform agentic code reviews—achieved the best results. Our results suggest that recent LLMs are capable of identifying logic bugs without human guidance or specialized tooling.
Introduction
The discovery of memory safety bugs relies heavily on robust bug oracles (e.g., sanitizers), combined with automated tools such as fuzzers or static analysis. But a lack of such tooling makes automated discovery for other bug classes, especially logic bugs, much more difficult—or sometimes even impossible. Sanitizers can detect memory safety bugs without any understanding of program logic, since an invalid memory access is a bug in any program. Logic bugs, on the other hand, depend on program invariants and context. As these are program-specific and often implicit, predetermined heuristics, rules, or oracles rarely apply. As a result, the discovery of logic bugs typically relies on human code reviews, which do not scale to large codebases.
LLMs allow us to fill this tooling gap. LLMs are highly capable at reasoning about (and inferring the intent of) source code and its invariants. This means they’re able to produce and then test out hypotheses that might lead them to detect logic bugs.
In this post, we study multiple methods for discovering logic bugs that use LLMs in this way. To do so, we assess how well models can detect 21 historical logic bugs, and then we assess their ability to find previously unknown logic bugs on four target programs. We describe logic bugs in Caliptra, an open-source silicon root of trust IP; macOS; eBPF; and the Rust compiler that were found through this effort. Notably, we find that techniques focused on simplicity achieve better results. For example, running Claude within a standard agentic harness (Claude Code) outperforms techniques that rely on fuzzing or symbolic execution. The former rediscovered 11 out of 21 bugs without Claude being provided any hints or information; the more complex techniques rediscovered none in the same setting. We therefore recommend that defenders start by applying the simple techniques discussed below to their own codebases before investing in specialized tooling.
Detecting historical logic bugs
Methods
We designed a set of techniques that use LLMs for logic bug discovery, and then tested their effectiveness on, first, a set of historical logic bugs, and second, on 0-day discovery. We constructed a benchmark of 21 logic bugs across SQLite (9), zstd (3), brotli (1), and image-png (8) disclosed between 2016 and 2026. For each technique, we provided the model with only the unpatched source code, and asked it to prove that it had rediscovered each bug by submitting an input that would trigger it. To mirror a realistic 0-day discovery scenario, we did not make the patched commit available to the model during the rediscovery attempt.
We scored each submitted input by comparing the behavior of the code between the unpatched and patched commits. If the behavior differed in return value or output, the grader scored the input as a success. This is sufficient to identify the bug as having been triggered. The patches of these 21 logic bugs only change the code path of the specific bug, so a difference in behavior means that the input reached this code path with values that trigger the bug. This grading system assumes that a technique that is able to produce a valid input must have correctly reasoned about the violated invariant to arrive at it. The grader did not explicitly verify this assumption. However, the experiments below suggest that this assumption generally holds true.
We ran each technique three times per logic bug. We report the total number of rediscovered bugs across all three runs. During a single run for any given technique, the model could submit up to 1,000 inputs for scoring, but received no feedback as to whether the input triggered the intended bug: this assessment was performed only after the run was completed.
The benchmark ran in two settings: blind and informed. In the blind setting, the model behind each run received no information about the bug (similar to a fully autonomous vulnerability discovery setting). Instead, it had to reason about and extract intent from the source code alone to infer the invariant. In the informed setting, the invariant violated by each logic bug was provided, along with the source. This mimics a setup in which the approach is guided by a human researcher who provides invariants to test.
We perform two experiments based on this benchmark. First, we use it to evaluate four techniques for finding logic bugs. We run each of the techniques with Claude Mythos 5 in both the informed and the blind settings. Second, to study the progression of model capabilities, we evaluate agentic code review in the blind setting on models from Claude Sonnet 4.5 to Claude Mythos 5.2. In addition to inputs corresponding to the 21 historical logic bugs, we collect all other submissions, and verify true positives and deduplicate bugs through an LLM judge.
Because the benchmark consists of historical bugs, a model might remember a bug from its training data instead of rediscovering it. To measure this, we asked each model about each of the 21 bugs in a plain conversation, without the source code. The Claude 4.5 models remember none of the bugs, and Sonnet 5 remembers three (about as often as it claims to remember bugs we made up). Claude Opus 5 and later models remember between 8 and 10 of the 10 bugs that became public between 2016 and 2024, and at most one of the 11 later bugs. The first experiment is less exposed to memorization, since all four techniques use the same model. For the second experiment, we separately report the results on the nine bugs that no model remembers.
Techniques we tested
LLM oracles for fuzzing
Fuzzing is effective at exploring program behavior but lacks a reliable oracle for logic bugs. The typical way of finding bugs other than memory corruptions with fuzzers involves a human writing target-specific invariants in the form of assert statements directly in the code. This allows the fuzzer to identify logic bugs by finding concrete inputs through coverage-guided mutation that trigger an assert violation. The approach used here generates these assertions through an LLM agent instead of a human. Total fuzzing time is eight hours. Once per hour, any assert that was triggered at least once is removed to allow for more fuzzing progress.
LLM-driven symbolic execution
This approach combines an LLM agent with symbolic execution by allowing an agent with code access to generate the harness used by the symbolic execution engine. The harness includes assert statements that represent the invariants inferred by the LLM. The symbolic execution engine executes the code using symbolic inputs, collects path constraints during its traversal, and attempts to violate the asserts using an SMT solver under the collected path constraints. If successful, the SMT solver provides a concrete input that violates the assert statement, which is then submitted as a proof of concept (PoC). The symbolic execution engine receives the same execution time as the fuzzer.
Agentic code review
Previous experiments showed that simply pointing Claude Code at a codebase with the task of identifying memory safety issues is highly effective. Based on this experience, we test the same approach for logic bug discovery: an LLM agent is given source access and the ability to run test inputs against the compiled codebase. The agent submits interesting inputs discovered through this process as PoCs for judging.
Informal correctness proofs
This approach, inspired by formal verification, tasks an agent to produce a correctness proof document to prove invariants or properties of the target application. The proof is written in natural language with no formal correctness guarantees. Its structure resembles that of a mathematical proof, including theorems, definitions, assumptions, and lemmas. It is not important, however, that the proof is strictly correct or error-free. It is merely a tool for the agent to surface bugs. Each claim the proof depends on that cannot be discharged based on the code is turned into a concrete input by the agent and submitted as a PoC for scoring.
Results

Simplicity wins. On the set of historical logic bugs, the best-performing approaches are agentic code review and informal correctness proofs, which perform similarly in both settings, as shown in Figure 1. LLM oracles for fuzzing and LLM-driven symbolic execution score zero bugs unless they’re provided with information about the intended finding. When provided with information about the invariants, the symbolic-execution-based approach is able to discover 13 of the bugs. Notably, this discovery does not represent a higher-quality or more targeted symbolic execution setup. Instead, the LLM discovered the findings during its source review to write harnesses and submitted the relevant inputs directly. Symbolic execution was able to confirm two of the bugs but did not contribute anything beyond the findings of the LLM’s source review. A variant of the fuzzing technique showed the same behavior in the informed setting. If given control over seeds and harnesses, this approach rediscovered 15 out of the 21 bugs. All 15 rediscoveries, however, were a result of the LLM spotting the bug and forcing the fuzzer to discover it rather than the LLM meaningfully improving the fuzzing setup and the discovery being a result of that.
Even though the successful rediscoveries of the fuzzing and symbolic execution techniques came from the LLM’s source review, they stayed far behind the agentic code review approach. This is due to their unnecessary complexity—the LLM had to find a way to provide its findings through the predetermined pathway, rather than allowing the agent to choose appropriate tooling—as well as the inherent limitations of fuzzing and symbolic execution. In particular, both techniques rely on predefined rules and heuristics rather than reasoning about the concrete program and bug at hand. Fuzzers can only exercise program functionality that is reachable through the fuzzing harness, and can observe program behavior only at the granularity of the instrumentation they were built with. Symbolic execution is limited by its engine’s fixed strategies and by the predefined heuristics from the SMT solver it relies on. These strategies and heuristics limit which paths symbolic execution can explore and which bugs it can discover. Agentic code review, on the other hand, can reason about program behavior and form hypotheses without being restricted by a fixed oracle or exploration strategy. This allows agentic code review to customize the discovery process to the target, as a human researcher would.
In the appendix, we provide further evidence that the relative performance of the approaches is not the result of the selection of bugs in the benchmark.


Invariant generation improves. For agents to fully autonomously discover logic bugs, they need to be able to form hypotheses about the intent behind the code, in addition to being able to test the hypothesis. The informed setting suggests that testing the hypothesis is not challenging (20–21 of 21 bugs were found when the invariant was provided). The blind setting measures the harder part—forming the hypothesis given only the source code.
Older and smaller models such as Claude Sonnet 4.5 (which rediscovered one bug) or Opus 4.5 (five) perform substantially worse in the blind setting compared with newer Opus (9 to 13) and Claude Mythos (11 to 15) models (see Figure 2). Even when accounting for potentially memorized bugs, the trendline remains. Of the nine bugs that no model remembers, the Claude 4.5 models as well as Sonnet 5 rediscover zero to one of them, whereas Opus 5 and later models rediscover two to five. Remembering a bug is also neither necessary nor sufficient to rediscover it: Claude Opus 4.5 rediscovers 4 of the 10 older bugs without remembering any of them. Of the two SQLite bugs that most newer models remember, no model rediscovers one in the blind setting, and only Claude Mythos 5.2 rediscovers the other.
Outside of the benchmarked set of bugs, Claude Mythos models similarly outperform older models, with 54 to 241 total bugs relative to 17 to 18 bugs for models in the Claude 4.5 generation. All generations find a similar number of specification conformance bugs, but newer and more capable models increasingly also discover logic bugs. Claude Mythos Preview found 95 logic bugs out of a total of 118; Claude Mythos 5.2 found 216 logic bugs out of a total of 241 (Figure 3). The Claude Mythos models’ higher share of logic bugs suggests an improved ability to generate meaningful hypotheses. Although even recent Claude Mythos models are still limited by their ability to generate useful invariants and can benefit from human assistance, the trendline suggests that future models will be capable of fully autonomous and effective logic bug discovery.
Bugs discovered outside the intended set. During the experiments for rediscovering 21 historical logic bugs, all approaches found various other bugs in the target source code. Across all techniques and models, the experiments discovered a total of 316 unique bugs. Because of the setting of the experiment, all of these were discovered on outdated versions of the target programs. Replaying the triggering inputs on a current version of the target (along with code comments and forum discussions) shows that 189 bugs have been fixed in newer versions of the targets, or are already known to the maintainers. We are in the process of reporting the remaining 127 to the respective maintainers.
Discovering 0-days
To further demonstrate that agentic code review and informal correctness proofs are effective ways of finding logic bugs, we attempted to find 0-days using these approaches. We describe four of the resulting findings below. These bugs were not publicly known at the time we discovered them.
Logic bug in Caliptra
For agentic code review, we selected the open-source silicon root of trust Caliptra as the target. Caliptra is a highly secured codebase that has been audited by leading product security teams as well as external auditors. On top of that, it’s written entirely in Rust, so memory safety issues are largely out of scope. Claude was able to discover a time-of-check-to-time-of-use bug in the ROM’s firmware update flow that allows a compromised component on the same chip to make the root of trust execute firmware it never verified.
The above code snippet shows the relevant lines of code that install a new firmware image at runtime. In subsystem mode, Caliptra receives an address of a staging area with the new image through its mailbox. The ROM reads the manifest and image from that address over DMA and verifies the image via verify_image. Next, it extends the measurement registers PCR0 and PCR1 with the verified image, and then reads from the same address a second time to copy the image into its instruction memory by calling load_image. Between these two reads, the caller could overwrite the staging area with arbitrary data and instructions. As the image is not verified again, this modification would go undetected. This behavior violates the invariant that the installed firmware image is the same as the verified one.
We have reported the bug to the maintainers, who assigned it CVE-2026-11835 and have since addressed this issue with a patch.
Logic bug in macOS
Using our agentic code review approach, we independently discovered CVE-2026-43783 (now patched). macOS uses small privileged helper daemons to provide specific privileged operations to unprivileged apps. As these services run as root, each has to decide whether it trusts a caller and whether it should accept a request. Any mistake in this process can open significant privilege escalation routes. Apple’s mitigations, such as pointer authentication (PAC) and Memory Integrity Enforcement (MIE), stop memory corruption bugs, but offer no protection against such logic bugs.
DesktopServicesHelper is the root helper used by Finder for file operations not permitted to the logged-in user. Examples of such operations include changing protected files or fixing permissions on iCloud Drive items. Claude found this bug, CVE-2026-43783, in DesktopServicesHelper. It allows any local user, including the unprivileged nobody account, to take ownership of any file on the system that isn’t protected by System Integrity Protection (SIP). This capability can be used to spawn a root shell without a password.
The snippet above was reconstructed by Claude from the shipped binary. When a request arrives, the daemon checks whether the caller is sandboxed. Any process can sandbox itself with a single, unprivileged call. The daemon accepts RepairPermissionsForCloudItems from any sandboxed caller with no further check. The handler, running as root, then changes ownership of each path it receives to the caller without checking that the path is inside the caller’s iCloud folder. Therefore, an attacker can take ownership of system files such as /etc/pam.d/su, which can subsequently be used to allow the unprivileged user to spawn a shell as root.
Logic bugs in the Rust compiler
Rust is a type-safe programming language that guarantees code is memory safe. This means that if you write a valid Rust program (and don’t use the “unsafe” keyword), then any program that is expressible in the Rust type system should not be allowed to access invalid memory. Upholding this guarantee for any valid Rust program is an invariant of the Rust compiler. Although these are bugs—and not security vulnerabilities—here we hope to show that LLMs’ ability to find logic bugs is applicable to more than just security and 0-day finding.
We tasked Claude with proving that safe Rust is type-safe through the informal correctness proof technique. This resulted in the discovery of several dozen type safety issues. One of these is the counterexample shown below. This is a program that the Rust compiler accepts even though it accesses invalid memory. This bug could be used to introduce type-confusion bugs into seemingly type-safe Rust code. We have reported the bug to the maintainers, who are working on a patch. (Several others have already been fixed, but this one is the simplest to describe.)
The code snippet first defines a two-dimensional array arr whose single element is an owning pointer to an i32 on the heap (i.e., the integer has exactly one owner). In the next line, alias is intended to be an exclusive reference to the only element in arr, i.e., arr[0][0]. While calculating the second index value, the ownership of the inner array of arr is moved to row. This should result in the compiler treating arr as no longer holding a value. Next, drop frees the owning pointer and with it the i32 on the heap. As a consequence, at the time the reference to arr’s single element is assigned to alias, this memory has already been released. The compiler missed this bug because it fails to connect the ownership move of arr inside the index expression with the borrow of arr[0][...].
Logic bugs in eBPF
The extended Berkeley Packet Filter (eBPF) is a programming language that allows user applications to run code directly in the Linux kernel. At face value, this seems to violate one of the core design principles of an operating system: the entire purpose of the kernel is to isolate different user applications from each other. Allowing a user to write code that runs in the context of the kernel appears to be something that should be prohibited by design.
But eBPF takes a clever approach to safety: before running any user-supplied code in the kernel, it runs a verifier over the program. The verifier is supposed to prove that the code is well-behaved and only takes certain allowed actions (for instance, that it is verified to terminate, to only ever read from or write to a small bounded region of memory, and so on). A program, then, is said to be sound if it respects these security properties.
Using the same informal proof technique discussed above, we identified over a hundred soundness bugs in the eBPF verifier. We have reported all of these to the maintainers, who have, over the past few months, been working through and patching these. One of these, fixed in commit e51179a4e0 and filed as CVE-2026-98041, is described here. Consider the following eBPF program:
To avoid analyzing paths that can never execute, the verifier tries to predict the outcome of conditional branches like the one on line 3 (if w1 != 0 goto l1). If the verifier can prove that a branch always goes one way, it only checks that side. There are many rules of this form, and one of them concerns null checks. Because a pointer to a map value (a region of memory shared between an eBPF program and userspace) is known to be valid, it can never be equal to zero. The verifier therefore concludes that a comparison of the form ptr != 0 is always true (because it is!).
But this is only the case when all 64 bits of the pointer are compared. eBPF also has 32-bit comparisons, and when you compare w1 instead of r1 you compare the lower 32 bits of r1. The verifier erroneously applied the same rule to w1 without taking the width of the comparison into account. Therefore, an attacker who can arrange for the lower 32 bits of map_value to be zero can cause the verifier to believe the code can never run—and therefore the code does not get analyzed, even though it can run.
In the program above, the verifier decides that the jump to l1 is always taken, and that it is therefore not necessary to check if the read of (r1 + r6) is valid.
During the actual execution of the program, the processor reaches l0, because it doesn’t get confused in the same way by the size of the values. With r6 still holding a value chosen by the attacker, the processor then dereferences an address that the verifier never checked. Other parts of the verifier that reason about null pointers already excluded 32-bit comparisons, but out of several thousand lines of code, this one rule, which was added in 2020, was missing the check.
This vulnerability allows a userspace program to achieve local privilege escalation.
Conclusion
LLMs substantially extend the coverage of existing, effective approaches to vulnerability discovery, helping defenders scale the reach and speed of their work, whether they are finding new issues or triaging known ones. Finding bugs beyond memory safety is no longer constrained by tooling gaps such as missing sanitizers.
Defenders should broaden their efforts accordingly. To do so, security teams can increasingly rely on LLMs to close the tooling gap, since LLMs can form and test hypotheses grounded in code behavior, semantics, and developer intent. In our experiments, setups that favor simplicity and that give the LLM more agency (namely, agentic code review and informal correctness proofs) outperformed more complex approaches, such as using LLMs as fuzzing oracles. As models become better at inferring intent, we expect the share of logic bugs that are discovered without human assistance to continue growing. Before looking for specialized tooling, we therefore recommend that defenders first apply agentic code review and informal correctness proofs to their own codebases.
Appendix

To understand whether the choice of logic bugs in the evaluation set skews the results, we further analyzed all submissions that did not match the intended bugs. We use an LLM judge to identify true bugs and deduplicate findings. As with the results on the intended logic bugs, agentic code review and informal correctness proofs perform substantially better than the LLM oracles for fuzzing or LLM-driven symbolic execution.
