Bladeren bron

Expand consequences, add examples

master
Ivaylo Ivanov 1 jaar geleden
bovenliggende
commit
97b52216cb
4 gewijzigde bestanden met toevoegingen van 120 en 56 verwijderingen
  1. 19
    8
      SemSEpaper/exercise.bib
  2. 52
    41
      SemSEpaper/exercises.bbl
  3. BIN
      SemSEpaper/exercises.pdf
  4. 49
    7
      SemSEpaper/exercises.tex

+ 19
- 8
SemSEpaper/exercise.bib Bestand weergeven

@@ -1,7 +1,7 @@
1 1
 @INPROCEEDINGS{smartian,
2 2
 	author={Choi, Jaeseung and Kim, Doyeon and Kim, Soomin and Grieco, Gustavo and Groce, Alex and Cha, Sang Kil},
3
-	booktitle={2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE)}, 
4
-	title={SMARTIAN: Enhancing Smart Contract Fuzzing with Static and Dynamic Data-Flow Analyses}, 
3
+	booktitle={2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE)},
4
+	title={SMARTIAN: Enhancing Smart Contract Fuzzing with Static and Dynamic Data-Flow Analyses},
5 5
 	year={2021},
6 6
 	volume={},
7 7
 	number={},
@@ -64,9 +64,20 @@
64 64
 	note = {\url{https://github.com/Arachnid/uscc/tree/master/submissions-2017/doughoyte} [Accessed: Oct. 27th 2023]}
65 65
 }
66 66
 
67
-@misc{CiteDrive2022,
68
-	title        = {CiteDrive brings reference management to Overleaf},
69
-	author       = {CiteDrive, Inc},
70
-	year         = 2022,
71
-	note         = {\url{https://www.citedrive.com/overleaf} [Accessed: (Use the date of access)]}
72
-}
67
+@article{multilayer,
68
+author = {Duan, Li and Sun, Yangyang and Zhang, Ke-Jia and Ding, Yong},
69
+year = {2022},
70
+month = {02},
71
+pages = {},
72
+title = {Multiple-Layer Security Threats on the Ethereum Blockchain and Their Countermeasures},
73
+volume = {2022},
74
+journal = {Security and Communication Networks},
75
+doi = {10.1155/2022/5307697}
76
+}
77
+
78
+@inproceedings{Kalra2018ZEUSAS,
79
+  title={ZEUS: Analyzing Safety of Smart Contracts},
80
+  author={Sukrit Kalra and Seep Goel and Mohan Dhawan and Subodh Sharma},
81
+  booktitle={Network and Distributed System Security Symposium},
82
+  year={2018},
83
+}

+ 52
- 41
SemSEpaper/exercises.bbl Bestand weergeven

@@ -1,41 +1,52 @@
1
-\begin{thebibliography}{1}
2
-
3
-\bibitem{smartian}
4
-Jaeseung Choi, Doyeon Kim, Soomin Kim, Gustavo Grieco, Alex Groce, and Sang~Kil
5
-  Cha.
6
-\newblock Smartian: Enhancing smart contract fuzzing with static and dynamic
7
-  data-flow analyses.
8
-\newblock In {\em 2021 36th IEEE/ACM International Conference on Automated
9
-  Software Engineering (ASE)}, pages 227--239, 2021.
10
-
11
-\bibitem{doughoyte}
12
-doughoyte.
13
-\newblock Merdetoken: It's some hot shit.
14
-\newblock
15
-  \url{https://github.com/Arachnid/uscc/tree/master/submissions-2017/doughoyte}
16
-  [Accessed: Oct. 27th 2023].
17
-
18
-\bibitem{teether}
19
-Johannes Krupp and Christian Rossow.
20
-\newblock {teEther}: Gnawing at ethereum to automatically exploit smart
21
-  contracts.
22
-\newblock In {\em 27th USENIX Security Symposium (USENIX Security 18)}, pages
23
-  1317--1333, Baltimore, MD, August 2018. USENIX Association.
24
-
25
-\bibitem{fuzzdrivegen}
26
-Siddhasagar Pani, Harshita~Vani Nallagonda, Vigneswaran, Raveendra~Kumar
27
-  Medicherla, and Rajan M.
28
-\newblock Smartfuzzdrivergen: Smart contract fuzzing automation for golang.
29
-\newblock In {\em Proceedings of the 16th Innovations in Software Engineering
30
-  Conference}, ISEC '23, New York, NY, USA, 2023. Association for Computing
31
-  Machinery.
32
-
33
-\bibitem{securify}
34
-Petar Tsankov, Andrei Dan, Dana Drachsler-Cohen, Arthur Gervais, Florian
35
-  B\"{u}nzli, and Martin Vechev.
36
-\newblock Securify: Practical security analysis of smart contracts.
37
-\newblock In {\em Proceedings of the 2018 ACM SIGSAC Conference on Computer and
38
-  Communications Security}, CCS '18, page 67–82, New York, NY, USA, 2018.
39
-  Association for Computing Machinery.
40
-
41
-\end{thebibliography}
1
+\begin{thebibliography}{1}
2
+
3
+\bibitem{smartian}
4
+Jaeseung Choi, Doyeon Kim, Soomin Kim, Gustavo Grieco, Alex Groce, and Sang~Kil
5
+  Cha.
6
+\newblock Smartian: Enhancing smart contract fuzzing with static and dynamic
7
+  data-flow analyses.
8
+\newblock In {\em 2021 36th IEEE/ACM International Conference on Automated
9
+  Software Engineering (ASE)}, pages 227--239, 2021.
10
+
11
+\bibitem{doughoyte}
12
+doughoyte.
13
+\newblock Merdetoken: It's some hot shit.
14
+\newblock
15
+  \url{https://github.com/Arachnid/uscc/tree/master/submissions-2017/doughoyte}
16
+  [Accessed: Oct. 27th 2023].
17
+
18
+\bibitem{multilayer}
19
+Li~Duan, Yangyang Sun, Ke-Jia Zhang, and Yong Ding.
20
+\newblock Multiple-layer security threats on the ethereum blockchain and their
21
+  countermeasures.
22
+\newblock {\em Security and Communication Networks}, 2022, 02 2022.
23
+
24
+\bibitem{Kalra2018ZEUSAS}
25
+Sukrit Kalra, Seep Goel, Mohan Dhawan, and Subodh Sharma.
26
+\newblock Zeus: Analyzing safety of smart contracts.
27
+\newblock In {\em Network and Distributed System Security Symposium}, 2018.
28
+
29
+\bibitem{teether}
30
+Johannes Krupp and Christian Rossow.
31
+\newblock {teEther}: Gnawing at ethereum to automatically exploit smart
32
+  contracts.
33
+\newblock In {\em 27th USENIX Security Symposium (USENIX Security 18)}, pages
34
+  1317--1333, Baltimore, MD, August 2018. USENIX Association.
35
+
36
+\bibitem{fuzzdrivegen}
37
+Siddhasagar Pani, Harshita~Vani Nallagonda, Vigneswaran, Raveendra~Kumar
38
+  Medicherla, and Rajan M.
39
+\newblock Smartfuzzdrivergen: Smart contract fuzzing automation for golang.
40
+\newblock In {\em Proceedings of the 16th Innovations in Software Engineering
41
+  Conference}, ISEC '23, New York, NY, USA, 2023. Association for Computing
42
+  Machinery.
43
+
44
+\bibitem{securify}
45
+Petar Tsankov, Andrei Dan, Dana Drachsler-Cohen, Arthur Gervais, Florian
46
+  B\"{u}nzli, and Martin Vechev.
47
+\newblock Securify: Practical security analysis of smart contracts.
48
+\newblock In {\em Proceedings of the 2018 ACM SIGSAC Conference on Computer and
49
+  Communications Security}, CCS '18, page 67–82, New York, NY, USA, 2018.
50
+  Association for Computing Machinery.
51
+
52
+\end{thebibliography}

BIN
SemSEpaper/exercises.pdf Bestand weergeven


+ 49
- 7
SemSEpaper/exercises.tex Bestand weergeven

@@ -222,15 +222,57 @@ owner to set them as a manager, which would result in the weakness being exploit
222 222
 The consequences of exploiting an arbitrary storage access weakness can be of different types and severity.
223 223
 An attacker may gain read-write access to private contract data, which should only be accessible to owners, maintainers etc.
224 224
 They may also exploit the contract to circumvent authorization checks and drain the contract funds.
225
-%TODO: can we expand this?
225
+According to Li Duan et al.~\cite{multilayer}, an attacker may also be able to destroy the contract storage structure and thus cause
226
+unexpected program flow, abnormal function execution or contract freeze.
226 227
 
227 228
 \section{Vulnerable contracts in literature}
228 229
 
229
-collect vulnerable contracts used by different papers to motivate/illustrate the weakness
230
+One example for vulnerable contracts, which is similar to Algorithm~\ref{alg:pop-incorrect}, is mentioned in the paper by Li Duan et al.~\cite{multilayer}:
231
+
232
+\medspace
233
+
234
+\lstset{style=mystyle}
235
+\begin{algorithm}[H]
236
+	\begin{lstlisting}[language=Octave]
237
+    function PopBonusCode() public {
238
+      require(0 <= bonusCodes.length);
239
+      bonusCodes.length--;
240
+    }
241
+
242
+    function UpdateBonusCodeAt(uint idx, uint c) public {
243
+      require(idx < bonusCodes.length);
244
+      bonusCodes[idx] = c;
245
+    }
246
+  \end{lstlisting}
247
+	\caption{Arbitrary write as per Li Duan et al.}
248
+  \label{alg:multilayer-example}
249
+\end{algorithm}
250
+
251
+We will not go into a detailed explanation, as we already did this in the previous section.
252
+
253
+
254
+A more sophisticated example is presented in the paper by Sukrit Kalra et al.~\cite{Kalra2018ZEUSAS}:
255
+
256
+\medspace
257
+
258
+\lstset{style=mystyle}
259
+\begin{algorithm}[H]
260
+	\begin{lstlisting}[language=Octave]
261
+    uint payout = balance/participants.length;
262
+    for (var i = 0; i < participants.length; i++)
263
+      participants[i].send(payout);
264
+  \end{lstlisting}
265
+	\caption{Arbitrary read as per Sukrit Kalra et al.}
266
+  \label{alg:zeus-example}
267
+\end{algorithm}
268
+
269
+The vulnerability here is an integer overflow - as the variable \texttt{i} is dinamically typed, it will get the smallest possible type that will be able to hold the value 0 - that being \texttt{uint8}, which is able to hold positive integers up to 255.
270
+
271
+Because of this, if the length of the \texttt{participants} arrays is greater than 255, the integer overflows on the 256th iteration and instead of moving on to \texttt{participants[255]}, it reverts back to the first element in the array. As a result, the first 255 paricipants will split all the balance of the contract, whereas the rest will get nothing.
230 272
 
231 273
 \section{Code properties and automatic detection}
232 274
 
233
-Automatic detection tools can be broadly categorized into ones employing static analysis and those who use fuzzing, i.e. application of semi-random inputs. Notable static analysis tools include Securify \cite{securify} and teEther \cite{teether} which both function in a similar manner:
275
+Automatic detection tools can be broadly categorized into ones employing static analysis and those who use fuzzing, i.e. application of semi-random inputs. Notable static analysis tools include Securify~\cite{securify} and teEther~\cite{teether} which both function in a similar manner:
234 276
 
235 277
 \medspace
236 278
 
@@ -238,15 +280,15 @@ Initially, the given EVM byte-code is disassembled into a control-flow-graph (CF
238 280
 
239 281
 \medspace
240 282
 
241
-In the case of Securify \cite{securify}, the CFG is translated into what the authors call "semantic facts" to which an elaborate set of so-called security patterns is applied. These patterns consist of building blocks in the form of predicates, which allows the tool to simply generate output based on the (transitively) matched patterns.
283
+In the case of Securify~\cite{securify}, the CFG is translated into what the authors call "semantic facts" to which an elaborate set of so-called security patterns is applied. These patterns consist of building blocks in the form of predicates, which allows the tool to simply generate output based on the (transitively) matched patterns.
242 284
 
243 285
 \medspace
244 286
 
245
-teEther \cite{teether} employs a similar approach, but instead the authors opt to build a graph of dependent variables. If the graph arrives at a $sstore(k,v)$ instruction and a path can be found leading to user-controlled inputs, the tool infers a set of constraints which are then used to automatically generate an exploit.
287
+teEther~\cite{teether} employs a similar approach, but instead the authors opt to build a graph of dependent variables. If the graph arrives at a $sstore(k,v)$ instruction and a path can be found leading to user-controlled inputs, the tool infers a set of constraints which are then used to automatically generate an exploit.
246 288
 
247 289
 \medspace
248 290
 
249
-The fuzz-driven approach to vulnerability detection is more abstract, as general-purpose fuzzing tools generally don't have knowledge of the analysed program. For the tool SmartFuzzDriverGenerator \cite{fuzzdrivegen}, a multitude of these fuzzing libraries can be used. The problem at hand is, however, that the technique cannot interface with a smart contract out of the box. The "glue" between fuzzer and program is called a driver, hence the name of "driver-generator".
291
+The fuzz-driven approach to vulnerability detection is more abstract, as general-purpose fuzzing tools generally don't have knowledge of the analysed program. For the tool SmartFuzzDriverGenerator~\cite{fuzzdrivegen}, a multitude of these fuzzing libraries can be used. The problem at hand is, however, that the technique cannot interface with a smart contract out of the box. The "glue" between fuzzer and program is called a driver, hence the name of "driver-generator".
250 292
 
251 293
 \medspace
252 294
 
@@ -254,7 +296,7 @@ SmartFuzzDriverGenerator aims to automatically generate such a driver by %TODO:
254 296
 
255 297
 \medspace
256 298
 
257
-The Smartian tool \cite{smartian} attempts to find a middle-ground between static and dynamic analysis by first transforming the EVM bytecode into control-flow facts. Based on this information, a set of seed-inputs is generated that are expected to have a high probability of yielding useable results. Should no exploit be found, the seed-inputs are then mutated in order to yield a higher code coverage. %TODO: This is probably extemely inprecise and should be re-written%
299
+The Smartian tool~\cite{smartian} attempts to find a middle-ground between static and dynamic analysis by first transforming the EVM bytecode into control-flow facts. Based on this information, a set of seed-inputs is generated that are expected to have a high probability of yielding useable results. Should no exploit be found, the seed-inputs are then mutated in order to yield a higher code coverage. %TODO: This is probably extemely inprecise and should be re-written%
258 300
 
259 301
 \section{Exploit sketch}
260 302
 

Laden…
Annuleren
Opslaan