Beyond Copying: Lifelong Smart Contract Security Task Construction via Protocol Mutation
Organizations: Shanghai Artificial Intelligence Laboratory · The Hong Kong University of Science and Technology (Guangzhou) · University of Science and Technology of China · Wuhan University
Abstract
AI agents can inspect code and run tests to support smart contract security. SlowMist reports about $38.6 billion in losses across the broader blockchain ecosystem. Existing evaluations can reward memorized or copied answers, including attack code recovered from public blockchain transactions. Reconstructing contracts and validating tasks also require costly manual effort. To address these issues, we propose CONSTRAINTDIAL, a framework for lifelong construction of smart contract security tasks via protocol mutation. It automates local contract reconstruction and uses attack execution to select changes to the required calls or inputs. Execution checks guide revisions that make the original attack fail while preserving exploitability, the security objective, and normal functionality. New incidents and audit findings enter the same procedure. With CONSTRAINTDIAL, we construct 3,045 task inputs from 203 public cases, covering detect, exploit, and patch. Compared with reconstruction alone, protocol mutation reduces success with supplied public answers by 10.9 percentage points on average across detect, exploit, and patch. The fraction of tasks solved by copying online answers falls by 9.3 points.
Figures & tables
| Work | D | E | P | Tasks k | Protocol mutation | Lifelong | Full automation |
|---|---|---|---|---|---|---|---|
| SCONE-bench | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ |
| EVMbench | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ |
| CyberChainBench | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ |
| Ours | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Task | Model | Base | Equivalent control | Change 1 | Change 2 | Combined changes | Overall |
|---|---|---|---|---|---|---|---|
| Detect | GLM-5.2 | 37.7 | 31.1 | 31.1 | 34.4 | 37.7 | 34.4 |
| Qwen3.8-Max | 39.3 | 39.3 | 36.1 | 19.7 | 42.6 | 35.4 | |
| DeepSeek-V4.1-Flash | 49.2 | 49.2 | 41.0 | 44.3 | 49.2 | 46.6 | |
| GLM-5.3-Flash | 31.1 | 32.8 | 32.8 | 31.1 | 29.5 | 31.5 | |
| Qwen3.8-27B | 29.5 | 29.5 | 29.5 | 27.9 | 26.2 | 28.5 | |
| Gemma-4-31B-IT | 26.2 | 29.5 | 26.2 | 24.6 | 26.2 | 26.6 |
| Method | Accepted | Rate (%) |
|---|---|---|
| Simple preparation | 105 | 86.1 |
| Direct rewriting | 65 | 53.3 |
| Full method | 100 | 82.0 |
| Without execution traces | 73 | 59.8 |
| Without paired checks | 75 | 61.5 |
| Without test feedback | 61 | 50.0 |
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
| Version type | Changed condition | Original attack |
|---|---|---|
| Base | Original local calling conditions | Succeeds |
| Equivalent control | Pause on a transfer path outside the reference attack | Succeeds |
| Change 1 | Registration before the vulnerable deposit | Fails |
| Change 2 | Open the schedule before advancing it | Fails |
| Combined changes | Both registration and schedule opening | Fails |
| Model | Location | Report | Trigger | Submission coverage | False positives | |
|---|---|---|---|---|---|---|
| GLM-5.2 | 40.3 | 34.4 | 28.9 | 95.4 | 9.6 | 28/291 |
| Qwen3.8-Max | 41.0 | 35.4 | 30.5 | 95.7 | 8.2 | 24/292 |
| DeepSeek-V4.1-Flash | 51.5 | 46.6 | 41.3 | 99.3 | 6.3 | 19/303 |
| GLM-5.3-Flash | 38.0 | 31.5 | 25.6 | 94.8 | 9.0 | 26/289 |
| Qwen3.8-27B | 36.4 | 28.5 | 22.0 | 92.8 | 11.3 | 32/283 |
| Gemma-4-31B-IT | 34.1 | 26.6 | 20.3 | 91.1 | 10.8 | 30/278 |
| Model | Build | Attack blocking | Normal operations | Joint |
|---|---|---|---|---|
| GLM-5.2 | 93.8 | 60.0 | 60.0 | 47.9 |
| Qwen3.8-Max | 95.4 | 68.2 | 65.9 | 55.1 |
| DeepSeek-V4.1-Flash | 97.7 | 72.5 | 73.8 | 62.3 |
| GLM-5.3-Flash | 91.5 | 55.7 | 53.8 | 42.3 |
| Qwen3.8-27B | 87.9 | 44.9 | 43.3 | 32.5 |
| Gemma-4-31B-IT | 91.1 | 47.5 | 47.2 | 36.1 |
| Detect | Exploit | Patch | ||||
|---|---|---|---|---|---|---|
| Model | Time | Cost | Time | Cost | Time | Cost |
| GLM-5.2 | 25.5 | 0.29 | 41.1 | 1.05 | 32.6 | 0.99 |
| Qwen3.8-Max | 21.8 | 0.20 | 36.5 | 0.84 | 33.0 | 0.91 |
| DeepSeek-V4.1-Flash | 10.3 | 0.03 | 12.1 | 0.21 | 14.3 | 0.22 |
| GLM-5.3-Flash | 26.7 | 0.03 | 43.6 | 0.08 | 35.4 | 0.09 |
| Qwen3.8-27B | 29.6 | 0.19 | 42.1 | 0.68 | 40.6 | 0.72 |
| Model | Single | 95% interval | Combined | 95% interval | Improved | Worse |
| Detect | ||||||
| GLM-5.2 | 0.0 | 0.0 | 2 | 2 | ||
| Qwen3.8-Max | -3.3 | 3.3 | 7 | 5 | ||
| DeepSeek-V4.1-Flash | -8.2 | 0.0 | 2 | 2 | ||
| GLM-5.3-Flash | 0.0 | -1.6 | 4 | 5 | ||
| Qwen3.8-27B | 0.0 | -3.3 | 4 | 6 | ||
| Model | Condition | Successes | Identifiers only | Extra calls only | Other calls or inputs |
|---|---|---|---|---|---|
| Qwen3.8-Max | Simple preparation | 47 | 0 | 42 | 5 |
| Qwen3.8-Max | Protocol mutation | 40 | 0 | 11 | 29 |
| DeepSeek-V4.1-Flash | Simple preparation | 53 | 0 | 49 | 4 |
| DeepSeek-V4.1-Flash | Protocol mutation | 48 | 0 | 17 | 31 |
| Model / task | Historical | Base | Simple preparation | Protocol mutation |
|---|---|---|---|---|
| Qwen3.8-Max / Detect | 53/57 | 37/45 | 32/44 | 27/40 |
| DeepSeek-V4.1-Flash / Detect | 57/60 | 47/56 | 44/54 | 36/49 |
| Qwen3.8-Max / Exploit | 50/55 | 17/49 | 0/47 | 0/40 |
| DeepSeek-V4.1-Flash / Exploit | 55/59 | 23/55 | 0/53 | 0/48 |
| Qwen3.8-Max / Patch | 49/54 | 34/50 | 31/49 | 25/44 |
| DeepSeek-V4.1-Flash / Patch | 54/58 | 41/55 | 38/54 | 32/49 |
| Task | Environment | Answer found | Answer copied | Successful copies | Final successes after copying |
|---|---|---|---|---|---|
| Detect | Historical | 111 | 88 | 70 (57.4) | 80 |
| Detect | Base | 89 | 66 | 28 (23.0) | 34 |
| Detect | Protocol mutation | 80 | 54 | 23 (18.9) | 28 |
| Exploit | Historical | 112 | 94 | 68 (55.7) | 77 |
| Exploit | Base | 91 | 69 | 21 (17.2) | 42 |
| Exploit | Protocol mutation | 81 | 55 | 6 (4.9) | 31 |
| Task and transfer | Historical | Base | Combined |
|---|---|---|---|
| Detect: Unchanged | 10 | 5 | 4 |
| Detect: Mechanical transfer | 10 | 8 | 7 |
| Exploit: Unchanged | 10 | 1 | 0 |
| Exploit: Mechanical transfer | 10 | 5 | 1 |
| Patch: Unchanged | 10 | 3 | 2 |
| Patch: Mechanical transfer | 10 | 7 | 6 |
| Batch | Inspected | Constructed | Versions | Detect | Exploit | Patch | Total | Rate (%) |
|---|---|---|---|---|---|---|---|---|
| 1 | 24 | 20 | 100 | 98 | 100 | 96 | 294 | 83.3 |
| 2 | 21 | 20 | 100 | 99 | 100 | 97 | 296 | 95.2 |
| Total | 45 | 40 | 200 | 197 | 200 | 193 | 590 | 88.9 |
| Method | Protocol | Detect | Exploit | Patch | Common | Mean revisions | Total cost (USD) | Cost per accepted version (USD) |
|---|---|---|---|---|---|---|---|---|
| Simple preparation | 117 | 114 | 116 | 109 | 105 | 0.7 | 47.58 | 0.45 |
| Direct rewriting | 83 | 76 | 81 | 70 | 65 | 1.5 | 112.24 | 1.73 |
| Full method | 110 | 106 | 109 | 103 | 100 | 1.4 | 150.06 | 1.50 |
| Without execution traces | 89 | 84 | 86 | 76 | 73 | 1.9 | 142.74 | 1.96 |
| Without paired checks | 94 | 87 | 91 | 80 | 75 | 1.1 | 122.00 | 1.63 |
| Without test feedback | 81 | 72 | 78 | 65 | 61 | 0.0 | 95.16 | 1.56 |
Software Security
Software security studies how to find, prevent, validate, and repair vulnerabilities in code, systems, dependencies, and software supply chains.
See all 95 papers