forked from rdi-berkeley/clue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
503 lines (493 loc) · 22.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Towards Automated Security Analysis of Smart Contracts based on Execution Property Graph | Berkeley RDI</title>
<meta name="description" content="blockchain large language models - txrank">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css" integrity="sha512-1sCRPdkRXhBV2PBLUdRb4tMg1w2YPf37qatUFeS7zlBy7jJI8Lf4VHwWfZZfpXtYSLy85pkm9GaYVYMfw5BC1A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link href="metaverse.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg bg-light">
<div class="container">
<a class="navbar-brand" href="#">Research @ <img src="img/rdi-sm.png" height="30"></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="https://rdi.berkeley.edu">RDI Home</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="https://rdi.berkeley.edu/research">Research Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="https://rdi.berkeley.edu/zkp">Zero Knowledge Proofs</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Metaverse Research
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="https://rdi.berkeley.edu/metadata">MetaData</a></li>
<li><a class="dropdown-item" href="https://rdi.berkeley.edu/metaguard">MetaGuard</a></li>
<li><a class="dropdown-item" href="https://rdi.berkeley.edu/metaverse-sok">Privacy SoK</a></li>
<li><a class="dropdown-item" href="https://rdi.berkeley.edu/vr-identification">Identification</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="https://rdi.berkeley.edu/metaverse">View All</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
aria-expanded="false">
DeFi Research
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="https://rdi.berkeley.edu/defi-attacks">DeFi Attacks</a></li>
<li><a class="dropdown-item" href="https://rdi.berkeley.edu/blockchain-llm">Blockchain LLM</a>
<li><a class="dropdown-item" href="https://rdi.berkeley.edu/clue">Clue</a>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="https://rdi.berkeley.edu/defi">View All</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="bg-light py-5">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-12">
<h1 class="mt-3">Towards Automated Security Analysis of Smart Contracts based on Execution Property Graph - <span class="clue">Clue</span> </h1>
<p class="text-secondary">2023 | Kaihua Qin* · Zhe Ye* · Zhun Wang · Weilin Li · Liyi Zhou · Chao Zhang · Dawn Song · Arthur Gervais | https://arxiv.org/pdf/2305.14046.pdf</p>
<p class="text-justify">Identifying and mitigating vulnerabilities in smart contracts is crucial, especially considering the rapid growth and increasing complexity of DeFi platforms. To address the challenges associated with securing these contracts, we introduce a versatile dynamic analysis framework specifically designed for the EVM. This comprehensive framework focuses on tracking contract executions, capturing valuable runtime information, while introducing and employing the EPG to propose a unique graph traversal technique that swiftly detects potential smart contract attacks. Our approach showcases its efficacy with rapid average graph traversal time per transaction and high true positive rates. The successful identification of a zero-day vulnerability affecting Uniswap highlights the framework's potential to effectively uncover smart contract vulnerabilities in complex DeFi systems.</p>
<p class="mb-0"><a class="btn btn-primary btn-lg" href="https://arxiv.org/pdf/2305.14046.pdf" target="_blank"><i class="fa fa-file-lines"></i> Read Paper</a></p>
</div>
</div>
</div>
</div>
<div class="container py-5 text-center">
<h1><i>Contract Execution Representation Graphs</i></h1>
<div class="row align-items-center mt-3">
<div class="col-lg-6">
<img src="img/epg-graph-code.png" style="width: 80%;">
</div>
<!-- <div class="col-lg-6">
<div>
<img src="img/epg-graph-code.png" style="width: 100%;">
</div>
</div> -->
<div class="col-lg-6">
<img src="img/epg-graph-ctg.png" id="displayed-image" style="width: 60%;">
</div>
</div>
<div class="row align-items-center mt-3">
<div class="col-lg-12">
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary">
<input type="radio" name="graph-options" onclick="displayImage('ctg')" autocomplete="off" checked> CTG
</label>
<label class="btn btn-secondary">
<input type="radio" name="graph-options" onclick="displayImage('dcfg')" autocomplete="off"> DCFG
</label>
<label class="btn btn-secondary">
<input type="radio" name="graph-options" onclick="displayImage('ddg')" autocomplete="off"> DDG
</label>
</div>
</div>
<script>
function preloadImage(imageName) {
var img = new Image();
img.src = 'img/epg-graph-' + imageName + '.png';
}
preloadImage("dcfg");
preloadImage("ddg");
function displayImage(imageName) {
// alert(imageName);
var displayedImage = document.getElementById("displayed-image");
if (imageName === "ctg") {
displayedImage.style.width = '60%';
} else if (imageName === "dcfg") {
displayedImage.style.width = '60%';
} else if (imageName === "ddg") {
displayedImage.style.width = '80%';
}
displayedImage.src = 'img/epg-graph-' + imageName + '.png';
}
</script>
</div>
<div class="row align-items-center mt-3">
<center class="col-lg-12">
<div style="width: 80%; text-align: left;">
These figures show the solidity source code and three corresponding basic execution representation graphs: <i>(i) Call Trace Graph (CTG), (ii) Dynamic Control Flow Graph (DCFG)</i>, and <i>(iii) Dynamic Dependence Graph (DDG)</i>. The <i>CTG</i> represents the calling relationships between mulitple smart contracts in a transaction. The <i>DCFG</i> represents the dynamically executed smart contract code as a graph, where each vertex denotes a basic block. The <i>DDG</i> represents data dependencies and control dependencies in a smart contract built from concrete executions.
</div>
</center>
</div>
</div>
<div class="container py-5 text-center">
<h1><i>Execution Property Graph (EPG)</i></h1>
<div class="row align-items-center mt-3">
<div class="col-lg-6">
<img src="img/epg-graph-example.png" id="displayed-image" style="width: 100%;">
</div>
<div class="col-lg-6" style="text-align: left;">
EPG is a comprehensive graph representation of smart contract executions, which is constructed by merging the three basic property graphs, CTG, DCFG, and DDG. It combines the dynamic execution information on EVM bytecode level, representing and formalizing contract executions as a graph. The left figure shows the partial EPG of a reentrancy attack transaction.
</div>
</div>
</div>
<div class="container py-5 text-center">
<div class="row align-items-center mt-3">
<h1><i>Architecture of <span class="clue">Clue</span></i></h1>
<div>
<img src="img/epg-overview.png" class="w-100 rounded">
</div>
<center class="mt-3">
<div style="width: 80%; text-align: left;">
This flow chart shows the high-level architecture of <span class="clue">Clue</span>. <span class="clue">Clue</span> offers support for both online and offline modes. The online mode enables real-time analysis of unconfirmed transactions, while the offline mode facilitates postmortem analysis. Central to <span class="clue">Clue</span> is an EVM emulator, which emulates and tracks the execution of the EVM. <span class="clue">Clue</span> allows extracting the data, control, asset flows from a transaction and further constructing EPG efficiently. Based on the EPG, we devise a graph traversal approach for identifying smart contract attacks automatically.
</div>
</center>
</div>
</div>
<div class="container py-5 text-center">
<h1><i>Traversal Based Security Analysis</i></h1>
<div class="row align-items-center mt-3">
<div class="col-lg-6" style="text-align: left;">
The EPG provides extensive information about the contract executions involved in a transaction. The <i>Graph Traversal</i> refers to the process of visiting vertices of a graph in a specific manner. This process can involve simply visiting every vertex in a predetermined order, or using more sophisticated rules to navigate through the graph. It is a prevalent method for mining information in property graphs, automates the identification of contract attacks. </div>
<div class="col-lg-6">
<img src="img/reentrancy_traversal_2-1.png" id="displayed-image" style="width: 80%;">
</div>
</div>
</div>
<div class="bg-dark text-white">
<div class="container">
<div class="row align-items-center py-5">
<div class="col-md-12">
<h1><span class="clue">Clue</span>'s Performance in Detecting Typical Attacks</h1>
To evaluate <span class="clue">Clue</span>'s performance in detecting <i>reentrancy, access control</i>, and <i>price manipulation</i> attacks, we construct three separate datasets: <i>(i) an Attack, (ii) a High-Gas</i>, and <i>(iii) a Regular dataset</i>. The <i>Attack</i> dataset comprises all attack transactions that were reported in <a href="https://arxiv.org/abs/2208.13035">SoK: Decentralized Finance (DeFi) Attacks</a> and correspond to the evaluated vulnerability type. Its main objective is to assess the true positive rate (FPR) and the false negative rate (FNR). Sampling from the non-attack transactions that have interacted with the related victim contracts in the <i>Attack</i> dataset, the <i>High-Gas</i> and <i>Regular</i> datasets comprise about 1k transactions with the highest gas, and about 20k randomly selected transactions, respectively. The primary objective is to assess the true negative rate (TNR) and false positive rate (FPR).
<h2 class="mt-3">Reentrancy Attack</h2>
The <i>Attack</i> dataset showcases a high true positive rate (91.95%) and a relatively low false negative rate (8.05%) with all false negatives resulting from "No Asset Flow" cases. In non-attack datasets, the true negative rates are remarkably high (99.81%) for <i>High-Gas</i> and (99.99%) for <i>Regular</i>. The few false positives are caused by Flash Loan and Rebase Token cases.
<table class="mt-3">
<thead>
<tr>
<th rowspan="2">Dataset</th>
<th rowspan="2">Attack</th>
<th colspan="2">Non-Attack</th>
</tr>
<tr>
<th>High-Gas</th>
<th>Regular</th>
</tr>
</thead>
<tbody>
<tr>
<td>Size</td>
<td>87</td>
<td>1,077</td>
<td>19,985</td>
</tr>
<tr>
<td>Gas Cost</td>
<td>3.33 ± 3.41M</td>
<td>2.13 ± 1.38M</td>
<td>0.24 ± 0.29M</td>
</tr>
</tbody>
<thead>
<tr>
<th colspan="4">Generic Rule</th>
</tr>
</thead>
<tbody>
<tr>
<td>Traversal Time</td>
<td>108 ± 136ms</td>
<td>20 ± 21ms</td>
<td>7 ± 3ms</td>
</tr>
<tr>
<td>TP (%)</td>
<td>80 (91.95%)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>FN (%)</td>
<td>7 (8.05%)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>TN (%)</td>
<td>-</td>
<td>1075 (99.81%)</td>
<td>19,984 (99.99%)</td>
</tr>
<tr>
<td>FP (%)</td>
<td>-</td>
<td>2 (0.19%)</td>
<td>1 (0.01%)</td>
</tr>
</tbody>
<thead>
<tr>
<th colspan="4">Refined Rule</th>
</tr>
</thead>
<tbody>
<tr>
<td>Traversal Time</td>
<td>0.32 ± 0.93s</td>
<td>52 ± 109ms</td>
<td>16 ± 347ms</td>
</tr>
<tr>
<td>TP (%)</td>
<td>87 (100%)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>FN (%)</td>
<td>0 (0%)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>TN (%)</td>
<td>-</td>
<td>1,069 (99.26%)</td>
<td>19,812 (99.08%)</td>
</tr>
<tr>
<td>FP (%)</td>
<td>-</td>
<td>8 (0.74%)</td>
<td>173 (0.87%)</td>
</tr>
</tbody>
</table>
<h2 class="mt-3">Access Control Attack</h2>
The <i>Attack</i> dataset demonstrates a high true positive rate (75.41%) and a relatively low false negative rate (24.59%) with all false negatives resulting from "Multi-tx" cases. In non-attack datasets, the true negative rates are remarkably high (98.44%) for <i>High-Gas</i> and (94.43%) for <i>Regular</i>. The few false positives stem from complex DeFi transactions and insufficient authorization checks.
<table class="mt-3">
<thead>
<tr>
<th rowspan="2">Dataset</th>
<th rowspan="2">Attack</th>
<th colspan="2">Non-Attack</th>
</tr>
<tr>
<th>High-Gas</th>
<th>Regular</th>
</tr>
</thead>
<tbody>
<tr>
<td>Size</td>
<td>61</td>
<td>1,091</td>
<td>19,992</td>
</tr>
<tr>
<td>Gas Cost</td>
<td>0.22 ± 0.65M</td>
<td>2.21 ± 1.53M</td>
<td>0.24 ± 0.28M</td>
</tr>
</tbody>
<thead>
<tr>
<th colspan="4">Generic Rule</th>
</tr>
</thead>
<tbody>
<tr>
<td>Traversal Time</td>
<td>9 ± 18ms</td>
<td>0.7 ± 8.6s</td>
<td>13 ± 244ms</td>
</tr>
<tr>
<td>TP (%)</td>
<td>38 (62.30%)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>FN (%)</td>
<td>23 (37.70%)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>TN (%)</td>
<td>-</td>
<td>942 (86.34%)</td>
<td>14,850 (74.28%)</td>
</tr>
<tr>
<td>FP (%)</td>
<td>-</td>
<td>149 (13.66%)</td>
<td>5,142 (25.72%)</td>
</tr>
</tbody>
<thead>
<tr>
<th colspan="4">Refined Rule</th>
</tr>
</thead>
<tbody>
<tr>
<td>Traversal Time</td>
<td>48 ± 121ms</td>
<td>8 ± 47s</td>
<td>0.08 ± 3.07s</td>
</tr>
<tr>
<td>TP (%)</td>
<td>46 (75.41%)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>FN (%)</td>
<td>15 (24.59%)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>TN (%)</td>
<td>-</td>
<td>1,074 (98.44%)</td>
<td>18,879 (94.43%)</td>
</tr>
<tr>
<td>FP (%)</td>
<td>-</td>
<td>17 (1.56%)</td>
<td>1,113 (5.57%)</td>
</tr>
</tbody>
</table>
<h2 class="mt-3">Price Manipulation Attack</h2>
The refined rule yields a high true positive rate (94.44%) and a relatively low false negative rate (5.56%) in the <i>Attack</i> dataset, with false negatives resulting from low profit margin and multi-transaction cases. In non-attack datasets, the true negative rates are significantly improved (98.51%) for <i>High-Gas</i> and (99.48%) for <i>Regular</i> after incorporating several refinements. The remaining false positives are primarily caused by arbitrage, complex transactions, and add/remove liquidity actions.
<table class="mt-3">
<thead>
<tr>
<th rowspan="2">Dataset</th>
<th rowspan="2">Attack</th>
<th colspan="2">Non-Attack</th>
</tr>
<tr>
<th>High-Gas</th>
<th>Regular</th>
</tr>
</thead>
<tbody>
<tr>
<td>Size</td>
<td>54</td>
<td>1,075</td>
<td>19,989</td>
</tr>
<tr>
<td>Gas Cost</td>
<td>6.89 ± 3.37M</td>
<td>2.14 ± 1.38M</td>
<td>0.24 ± 0.26M</td>
</tr>
</tbody>
<thead>
<tr>
<th colspan="4">Generic Rule</th>
</tr>
</thead>
<tbody>
<tr>
<td>Traversal Time</td>
<td>32 ± 17ms</td>
<td>7 ± 27ms</td>
<td>2.2 ± 1.1ms</td>
</tr>
<tr>
<td>TP (%)</td>
<td>53 (98.15%)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>FN (%)</td>
<td>1 (1.85%)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>TN (%)</td>
<td>-</td>
<td>322 (29.95%)</td>
<td>18,410 (92.10%)</td>
</tr>
<tr>
<td>FP (%)</td>
<td>-</td>
<td>753 (70.05%)</td>
<td>1,579 (7.90%)</td>
</tr>
</tbody>
<thead>
<tr>
<th colspan="4">Refined Rule</th>
</tr>
</thead>
<tbody>
<tr>
<td>Traversal Time</td>
<td>47 ± 23ms</td>
<td>10 ± 24ms</td>
<td>2.4 ± 1.5ms</td>
</tr>
<tr>
<td>TP (%)</td>
<td>51 (94.44%)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>FN (%)</td>
<td>3 (5.56%)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>TN (%)</td>
<td>-</td>
<td>1,059 (98.51%)</td>
<td>19,886 (99.48%)</td>
</tr>
<tr>
<td>FP (%)</td>
<td>-</td>
<td>16 (1.49%)</td>
<td>103 (0.52%)</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="bg-dark text-white text-center py-2">
<div class="container">
<p class="m-0">Copyright ©2022 UC Regents | Email us at <a href="mailto:rdi@berkeley.edu">rdi@berkeley.edu</a>.</p>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
</body>
</html>