arXiv:2608.28400cs.CRAug 2026

Manuscript Offprint

arXiv:2608.28400

When Verified Source Becomes Attack Input: Defending Smart Contracts Against LLM-Based Vulnerability Scanning

Mingyuan Huang, Zimo Ji, Yifan Mo, Shuai Wang

Abstract

Smart contracts are financial programs deployed on blockchains to manage digital assets. To build trust with users and investors, smart contract projects typically publish their source code on blockchain explorers and verify it against the deployed bytecode, making the on-chain program accessible through a human-readable implementation. However, LLM agents are changing the threat model of this disclosure mechanism. By leveraging publicly disclosed source code, recent agent workflows make it increasingly practical to scan contract vulnerabilities for exploits at large scale.

In this paper, we propose DeLLMGuard, a smart contract deployment framework that defends against malicious LLM-based vulnerability scanning while preserving public source disclosure and authorized auditing. DeLLMGuard can separate disclosed source code from runtime execution through multiple contract addresses in a real-world blockchain environment. LLM agents must therefore recover additional proxy, delegate, and factory relations before vulnerability analysis. A built-in Verification Layer checks deployment relations, runtime bytecode, source code, and state changes to ensure that the transformation preserves the original business implementation. We evaluate DeLLMGuard on 387 real-world vulnerable contracts with three LLM agents in an environment derived from SCONE-bench. DeLLMGuard reduces overall root-cause correctness from 23.5% to 6.6% and outperforms the closed-source bytecode baseline on the primary non-proxy set. Trace and ablation analyses further show that agents often recover downstream contracts but still fail to identify the vulnerability, indicating that cross-contract recovery remains a major challenge for automated LLM scanning.

1 Introduction

Smart contracts are Turing-complete programs deployed and executed on blockchains. They are widely used to build decentralized finance (DeFi) applications that manage digital assets and user funds. Because vulnerabilities in these contracts can directly cause financial losses, security assurance and project reputation are critical in the DeFi ecosystem. To establish transparency and trust, DeFi projects commonly publish their source code on blockchain explorers such as Etherscan and verify it against the deployed bytecode [22]. Verified source disclosure has therefore become an established industry practice for making on-chain programs human-readable and supporting external security audits. Under the traditional threat model, both attackers and security auditors primarily rely on human experts to analyze disclosed smart contract source code [8, 34]. In practice, defenders often devote more systematic expert effort to auditing than attackers can justify for any individual contract, helping keep deployed contracts relatively secure [10, 40].

However, the emergence of LLM agents fundamentally changes this threat model. Anthropic SCONE-bench [38] and OpenAI EVM-bench [31] demonstrate that frontier LLM agents can autonomously discover and exploit vulnerabilities in real-world contracts, including contracts deployed after LLM knowledge cutoffs and previously unknown zero-day vulnerabilities. Such agents can automatically validate potential exploits via tool-mediated execution, thereby discarding failed attempts and continuously scanning contracts. More importantly, LLM-assisted attacks are beginning to emerge in the real world. Blockchain security companies have warned that AI has enabled large-scale vulnerability analysis and automated exploits [7, 9]. For example, Halborn reported indications that an LLM assistant was used in the 2025 Balancer exploit, which caused over $120 million in losses [4].

This also shows an emerging asymmetric advantage: attackers need only a single profitable vulnerability to execute, whereas defenders must manually verify all potential findings. Although LLM agents can assist security audits [33], their defensive benefits remain constrained because generated findings still require human verification. For example, Code4rena explicitly discourages LLM-generated submissions due to their high ratio of invalid findings and requires submitters to

∗^{*}These authors contributed equally to this work.

†^{\dagger}Corresponding author.

verify their validity and clarity [14]. These results show LLM agents can transform publicly disclosed source code from a foundation for transparency and auditing into scalable input for malicious vulnerability discovery and exploitation.

This risk is particularly acute for smart contracts compared with traditional software. In traditional software projects, vulnerabilities discovered with AI assistance can be reported to identifiable maintainers and handled through established patching and release processes, as illustrated by the Linux kernel security workflow [27]. In contrast, deployed smart contracts are immutable by design, while contract owners may be pseudonymous and lack dedicated reporting channels, making responsible reporting difficult [12, 21]. At the same time, a successful exploit can directly transfer on-chain assets to a pseudonymous attacker, making exploitation both practical and economically attractive [5].

Defending smart contracts against LLM-based abuse presents unique challenges: a practical defense must preserve public source access and established verification and auditing workflows while remaining effective when attackers control their own models and analysis tools. However, many existing LLM defenses rely on specially trained models or controlled execution environments [13, 37]. These assumptions do not hold on public blockchains, where attackers can freely interact with deployed contracts and control their own LLM agents. This leaves deployment-level protection of publicly disclosed contracts largely unexplored.

In this paper, we present DeLLMGuard, a deployment-level defense framework that leverages blockchain execution mechanisms to increase the context reconstruction effort of LLM agents. Rather than modifying business logic or restricting source access, DeLLMGuard uses multi-address deployment to separate the disclosed source address from contracts involved in runtime execution. DeLLMGuard thereby turns vulnerability analysis from local source code reasoning into reconstruction of execution contexts across multiple on-chain contracts. Before analyzing vulnerabilities, an LLM agent must retrieve the relevant contracts and correctly recover their transaction, bytecode, and storage relationships. This requires cross-component context retrieval and multi-step interaction with the execution environment, both of which remain challenging for current LLM-based systems [16, 26]. Errors in these intermediate steps can propagate to subsequent vulnerability analysis, increasing the effort of malicious scanning.

However, increasing analysis complexity alone is insufficient for a practical defense. DeLLMGuard must also preserve existing source code disclosure and authorized auditing workflows. To ensure that DeLLMGuard does not alter the original business logic, the Verification Layer verifies the consistency of business-source and business-runtime identities before and after transformation. It further checks the introduced deployment relations, execution routes, and state changes to ensure that the transformed system still reaches the intended business implementation without introducing new security risks. These checks ensure that the protected deployment remains verifiably linked to the disclosed business source and the original business implementation.

DeLLMGuard contains four guard components. ① The Factory Indirection Component (FIC) deploys the business runtime through a factory, separating the disclosed creation artifact from the deployed runtime address. ② The Delegate Layering Component (DLC) separates the user-facing entry address from the business-code location while preserving the execution context through delegatecall. ③ The Proxy Diversification Component (PDC) introduces competing proxy-resolution cues while preserving the effective implementation and forwarding relation. ④ The Comment Perturbation Component (CPC) modifies non-executable comments to provide a lightweight text-level intervention without changing compiled behavior. For comparison, we separately evaluate the Bytecode Inline Component (BIC), a source-verification preemption baseline that prevents disclosure of the original high-level business source. Moreover, these components are composable, allowing developers to use them independently or combine them based on the contract architecture.

We evaluate DeLLMGuard on 387 real-world vulnerable contracts with three frontier LLM agents in an environment derived from SCONE [38]. DeLLMGuard reduces root-cause detection by up to 87% while preserving source disclosure, matching or outperforming the closed-source Bytecode Inline baseline. Trace and ablation analyses show that its effectiveness mainly comes from forcing cross-address recovery of business logic and remains substantial even when agents are informed of the complete DeLLMGuard pipeline.

This paper makes the following contributions:

• We formulate the security problem of defending publicly disclosed smart contracts against malicious LLM-based vulnerability scanning while preserving source disclosure in real-world blockchain environments.

• We present DeLLMGuard, the first deployment-level defense framework that counters automated LLM-based vulnerability scanning while preserving public source disclosure and security auditing.

• We evaluate DeLLMGuard on 387 real-world vulnerable contracts with three LLM agents. DeLLMGuard reduces overall root-cause correctness from 23.5% to 6.6%, and outperforms the closed-source Bytecode Inline baseline on the primary non-proxy dataset.

References (19)