Browse Source

Add initial presentation

master
Ivaylo Ivanov 4 months ago
parent
commit
c0b2c1a005

+ 5
- 0
.gitignore View File

@@ -2,3 +2,8 @@
2 2
 *.aux
3 3
 *.blg
4 4
 *.gz
5
+*.out
6
+*.snm
7
+*.toc
8
+*.vrb
9
+*.nav

BIN
SemSEpresentation/TU_Logo.pdf View File


BIN
SemSEpresentation/TU_Logo_white.pdf View File


BIN
SemSEpresentation/TU_Signet.pdf View File


+ 305
- 0
SemSEpresentation/beamerthemetuw.sty View File

@@ -0,0 +1,305 @@
1
+%%
2
+% @file beamerthemeTUW.sty
3
+% @date 2016-08-30
4
+% @author Wolfgang Puffitsch, Denise Ratasich
5
+%
6
+% @brief Beamer LaTeX template matching the corporate design of TU Wien.
7
+%%
8
+
9
+\NeedsTeXFormat{LaTeX2e}
10
+\ProvidesPackage{beamerthemeTUW}[2016/08/30 Beamer template that fits the TU Wien corporate design (adopted styles from powerpoint presentation template in CD manual)]
11
+
12
+\RequirePackage{graphicx}
13
+\RequirePackage{tikz}
14
+
15
+\def\beamer@tuwDefault{default}
16
+\def\beamer@tuwPlain{plain}
17
+\def\beamer@tuwSidebar{sidebar}
18
+\def\beamer@tuwHelvetica{helvetica}
19
+\def\beamer@tuwNoImage{none}
20
+\def\beamer@tuwLogo{TU_Logo}
21
+\def\beamer@tuwLogoWhite{TU_Logo_white}
22
+
23
+%%% options
24
+% The user may choose other fonts (TU Wien CD says to use helvetica).
25
+\DeclareOptionBeamer{font}{\def\beamer@tuwFont{#1}}
26
+% Another outer theme may be chosen, however it may not fit the TU Wien colors.
27
+\DeclareOptionBeamer{outer}{\def\beamer@tuwOuter{#1}}
28
+% Width of the sidebar.
29
+\DeclareOptionBeamer{width}{\def\beamer@tuwWidth{#1}}
30
+% Background image of TU Wien building on title page.
31
+\newif\ifbeamer@tuwBackground
32
+\DeclareOptionBeamer{tuw_background}{\beamer@tuwBackgroundtrue}
33
+% Individual background image on title page.
34
+\DeclareOptionBeamer{tuw_image}{\def\beamer@tuwImage{#1}}
35
+% White logo (if tuw_image is dark the logo should be set to be white).
36
+\newif\ifbeamer@tuwWhiteLogo
37
+\DeclareOptionBeamer{tuw_whitelogo}{\beamer@tuwWhiteLogotrue}
38
+% Print frame title beside the logo to save space.
39
+\newif\ifbeamer@tuwFrametitleToTop
40
+\DeclareOptionBeamer{tuw_frametitletotop}{\beamer@tuwFrametitleToToptrue}
41
+
42
+% defaults
43
+\ExecuteOptionsBeamer{outer=default}
44
+\ExecuteOptionsBeamer{width=1.6cm}
45
+\ExecuteOptionsBeamer{font=\familydefault}
46
+\beamer@tuwBackgroundfalse
47
+\ExecuteOptionsBeamer{tuw_image=none}
48
+\beamer@tuwWhiteLogofalse
49
+\beamer@tuwFrametitleToTopfalse
50
+
51
+\ProcessOptionsBeamer
52
+
53
+\ifx\beamer@tuwFont\beamer@tuwHelvetica
54
+\RequirePackage{helvet}
55
+\fi
56
+
57
+\mode<presentation>
58
+
59
+%%% colors
60
+% For some reason the logo is not in TU-blue (0,102,153). The powerpoint
61
+% presentation has TU-blue as background and the logo with a different color
62
+% (doesn't look nice). We align the TU-blue to the logo, like in the CD manual.
63
+\definecolor{tuwBlue}{RGB}{0,116,178}
64
+\definecolor{tuwGray}{RGB}{102,102,102}
65
+\definecolor{iceBlue}{RGB}{222,231,236}
66
+
67
+\def\tuwBlue{tuwBlue}
68
+\def\tuwGray{tuwGray}
69
+\def\iceBlue{iceBlue}
70
+\def\tuwLightBlue{tuwBlue!20!white}
71
+\def\tuwMediumBlue{tuwBlue!45!white}
72
+\def\tuwDarkBlue{tuwBlue!70!black}
73
+\def\alertred{red!50!black}
74
+
75
+% content page
76
+\setbeamercolor{normal text}{fg=black,bg=white}
77
+\setbeamercolor{alerted text}{fg=\alertred}
78
+\setbeamercolor{structure}{fg=\tuwBlue}
79
+\setbeamercolor{frametitle}{fg=black}
80
+
81
+\setbeamercolor{palette primary}{fg=\tuwDarkBlue,bg=\tuwLightBlue}
82
+\setbeamercolor{palette secondary}{fg=\tuwBlue!50!black,bg=\tuwMediumBlue}
83
+\setbeamercolor{palette tertiary}{fg=white,bg=\tuwBlue}
84
+
85
+\setbeamercolor{section in toc}{parent=normal text}
86
+\setbeamercolor{subsection in toc}{parent=section in toc}
87
+
88
+\setbeamercolor{block title}{fg=white, bg=\tuwBlue}
89
+\setbeamercolor{block title example}{fg=white, bg=\tuwBlue}
90
+\setbeamercolor{block title alerted}{fg=white, bg=\alertred}
91
+\setbeamercolor{block body}{bg=\iceBlue}
92
+\setbeamercolor{block body example}{parent=block body}
93
+\setbeamercolor{block body alerted}{parent=block body, fg=\alertred}
94
+
95
+\setbeamercolor{title in head/foot}{fg=\tuwBlue}
96
+\setbeamercolor{page number in head/foot}{fg=\tuwBlue}
97
+\setbeamercolor{footline}{fg=\tuwBlue}
98
+
99
+% color difference of default and other outer styles
100
+\ifx\beamer@tuwOuter\beamer@tuwDefault
101
+% default style - this is the CD of TU Wien
102
+% title page
103
+\setbeamercolor{title}{fg=white}
104
+\setbeamercolor{subtitle}{fg=white}
105
+\setbeamercolor{author}{fg=white}
106
+\setbeamercolor{institute}{fg=white}
107
+\setbeamercolor{date}{fg=white}
108
+% content page
109
+% keep defaults (black)
110
+\else
111
+% other outer styles (e.g., sidebar)
112
+% title page
113
+\setbeamercolor{title}{fg=\tuwGray}
114
+\setbeamercolor{subtitle}{fg=\tuwGray}
115
+\setbeamercolor{author}{fg=black}
116
+\setbeamercolor{institute}{fg=black}
117
+\setbeamercolor{date}{fg=black}
118
+% content page
119
+\setbeamercolor{frametitle}{fg=\tuwGray}
120
+\setbeamercolor{headline}{fg=\tuwGray}
121
+\setbeamercolor{footline}{fg=\tuwGray}
122
+\fi
123
+
124
+% sidebar
125
+\setbeamercolor{sidebar}{bg=\tuwBlue,fg=white}
126
+\setbeamercolor{palette sidebar primary}{fg=\tuwDarkBlue,bg=\tuwLightBlue}
127
+\setbeamercolor{palette sidebar secondary}{fg=\tuwDarkBlue,bg=\tuwLightBlue}
128
+\setbeamercolor{palette sidebar tertiary}{fg=white,bg=\tuwBlue}
129
+\setbeamercolor{title in sidebar}{fg=white,bg=\tuwBlue}
130
+\setbeamercolor{section in sidebar}{fg=\tuwDarkBlue}
131
+\setbeamercolor{section in sidebar shaded}{fg=white,bg=\tuwBlue}
132
+\setbeamercolor{subsection in sidebar}{fg=\tuwDarkBlue}
133
+\setbeamercolor{subsection in sidebar shaded}{fg=white,bg=\tuwBlue}
134
+
135
+%%% fonts
136
+
137
+% font weight
138
+\setbeamerfont{title}{series=\bfseries}
139
+\setbeamerfont{author}{series=\mdseries}
140
+\setbeamerfont{institute}{series=\mdseries}
141
+\setbeamerfont{date}{series=\mdseries}
142
+\setbeamerfont{frametitle}{series=\mdseries}
143
+\setbeamerfont{headline}{series=\mdseries}
144
+\setbeamerfont{footline}{series=\mdseries}
145
+
146
+% font size difference of default and other outer styles
147
+\ifx\beamer@tuwOuter\beamer@tuwDefault
148
+% default style - this is the CD of TU Wien
149
+\setbeamerfont{title}{size=\huge}
150
+\setbeamerfont{author}{size=\normalsize}
151
+\setbeamerfont{institute}{size=\normalsize}
152
+\setbeamerfont{date}{size=\normalsize}
153
+\setbeamerfont{frametitle}{size=\Large}
154
+\setbeamerfont{framesubtitle}{size=\large}
155
+\setbeamerfont{headline}{size=\scriptsize}
156
+\setbeamerfont{footline}{size=\scriptsize}
157
+\else
158
+% other outer styles (e.g., sidebar)
159
+% keep defaults
160
+\fi
161
+
162
+\setbeamerfont{section in toc}{parent=normal text}
163
+\setbeamerfont{subsection in toc}{parent=section in toc}
164
+
165
+% sidebar
166
+\setbeamerfont{title in sidebar}{series=\bfseries}
167
+\setbeamerfont{section in sidebar}{series=\bfseries,size=\tiny}
168
+\setbeamerfont{subsection in sidebar}{size=\tiny}
169
+
170
+%%% outer
171
+\setbeamersize{text margin left=1.2cm}
172
+\setbeamersize{text margin right=1.5cm}
173
+\beamertemplatenavigationsymbolsempty
174
+
175
+
176
+\ifx\beamer@tuwOuter\beamer@tuwDefault
177
+% default outher theme - this is the CD of TU Wien
178
+
179
+% background
180
+\setbeamertemplate{background}{
181
+  \begin{tikzpicture}
182
+    \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
183
+    % title page
184
+    \ifbeamer@tuwBackground % tu building background selected
185
+    \node[anchor=south west] (background) at (-0.15cm,-0.15cm) {\includegraphics[width=1.01\paperwidth]{TU_Background}};
186
+    \else\ifx\beamer@tuwImage\beamer@tuwNoImage % no background image specified
187
+    \fill[white] (0,0) rectangle (\the\paperwidth,\the\paperheight);
188
+    \else % individual background image
189
+    \node[anchor=north west] (background) at (-0.15cm,-0.15cm) {\includegraphics[width=1.01\paperwidth]{\beamer@tuwImage}};
190
+    \fi\fi
191
+    \fill[\tuwBlue, rounded corners=0.5cm] (-1cm,-1cm) rectangle (\paperwidth-0.5cm,\paperheight-3cm);
192
+    \ifbeamer@tuwWhiteLogo % white logo option specified
193
+    \node[anchor=north west] (logo) at (0.3cm,\paperheight-0.1cm) {\includegraphics[height=2cm]{\beamer@tuwLogoWhite}};
194
+    \else
195
+    \node[anchor=north west] (logo) at (0.2cm,\paperheight-0.2cm) {\includegraphics[height=2cm]{\beamer@tuwLogo}};
196
+    \fi
197
+    % content page
198
+    \ifnum\thepage>1\relax%
199
+    \fill[\iceBlue] (0,0) rectangle (\the\paperwidth,\the\paperheight);
200
+    \fill[white, rounded corners=0.5cm] (-1cm,-1cm) rectangle(\paperwidth-0.4cm,\paperheight-0.8cm);
201
+    \node[anchor=west] (logo) at (0.3cm,\paperheight-0.4cm) {\includegraphics[height=0.5cm]{TU_Signet}};
202
+    \fi
203
+  \end{tikzpicture}
204
+}
205
+
206
+% title page
207
+\def\beamer@titlepageLeft{1.6cm}
208
+\setbeamertemplate{title page}{
209
+  \vskip 4cm%
210
+  \begin{beamercolorbox}[leftskip=\beamer@titlepageLeft]{title}%
211
+    \usebeamerfont{title}\inserttitle%
212
+  \end{beamercolorbox}%
213
+  \vskip 0.5cm%
214
+  \begin{beamercolorbox}[leftskip=\beamer@titlepageLeft]{subtitle}
215
+    \usebeamerfont{subtitle}\insertsubtitle%
216
+  \end{beamercolorbox}
217
+  \vskip 0.25cm%
218
+  \vfill%
219
+  \begin{beamercolorbox}[leftskip=\beamer@titlepageLeft]{author}
220
+    \usebeamerfont{author}\insertauthor%
221
+  \end{beamercolorbox}
222
+  \begin{beamercolorbox}[leftskip=\beamer@titlepageLeft]{date}
223
+    \usebeamerfont{date}\insertdate%
224
+  \end{beamercolorbox}
225
+}
226
+
227
+% frametitle
228
+\setbeamertemplate{frametitle}
229
+{%
230
+  \ifbeamer@tuwFrametitleToTop % frametitle should be printed beside the logo
231
+  % vbox to keep the baseline
232
+  \vbox{}\vskip -0.43cm%
233
+  \else
234
+  \vbox{}\vskip 0.7cm%
235
+  \fi
236
+  \begin{beamercolorbox}[leftskip=0cm]{frametitle}
237
+    \usebeamerfont{frametitle}\insertframetitle%
238
+    \ifbeamer@tuwFrametitleToTop
239
+    \vbox{}\vskip 0.3cm%
240
+    \else
241
+    \vbox{}\vskip 0.2cm%
242
+    \fi
243
+    \usebeamerfont{framesubtitle}\insertframesubtitle%
244
+  \end{beamercolorbox}
245
+}
246
+
247
+% footline
248
+\setbeamertemplate{footline}{%
249
+  \vspace{0.1cm}
250
+  \ifnum\thepage>1
251
+    \begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex]{footline}
252
+      \hskip 1.2cm%
253
+      \usebeamerfont{footline}\insertshortdate%
254
+      \hfill%
255
+      \insertshorttitle, \insertshortauthor%
256
+      \hfill%
257
+      \insertframenumber\:/\:\inserttotalframenumber%
258
+      \hspace*{1.5cm}%
259
+    \end{beamercolorbox}
260
+  \else
261
+    \begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,center]{}%
262
+        % empty environment to raise height
263
+    \end{beamercolorbox}
264
+  \fi
265
+  \vspace{0.1cm}
266
+}
267
+
268
+\else\ifx\beamer@tuwOuter\beamer@tuwSidebar
269
+% sidebar outer theme
270
+\useoutertheme[width=\beamer@tuwWidth,height=0pt]{\beamer@tuwOuter}
271
+
272
+% footline
273
+\setbeamertemplate{footline}{
274
+  \ifnum\thepage>1
275
+  \vspace{-1cm}
276
+  \hfill{\scriptsize\insertframenumber\:/\:\inserttotalframenumber~~}
277
+  \vspace{0.1cm}
278
+  \fi
279
+}
280
+\else
281
+\useoutertheme{\beamer@tuwOuter}
282
+\fi\fi % if outer=default or outer=sidebar
283
+
284
+
285
+%%% inner
286
+\ifx\beamer@tuwOuter\beamer@tuwDefault
287
+\setbeamertemplate{itemize items}[circle]
288
+\else
289
+% defaults
290
+\fi % if outer=default
291
+
292
+\setlength{\parskip}{6pt}
293
+
294
+% blocks
295
+\setbeamertemplate{blocks}[rounded]
296
+\pgfdeclareverticalshading{bmb@transition}{\the\paperwidth}{color(0pt)=(\iceBlue); color(3.0pt)=(\iceBlue)}
297
+
298
+\setbeamercovered{invisible}
299
+
300
+% emphasize
301
+\renewcommand<>{\emph}[1]{{\only#2{\color{\tuwBlue}}#1}}
302
+
303
+\hypersetup{colorlinks=true,linkcolor=fg,citecolor=\tuwGray,urlcolor=\tuwGray}
304
+
305
+\mode<all>

BIN
SemSEpresentation/slides.pdf View File


+ 251
- 0
SemSEpresentation/slides.tex View File

@@ -0,0 +1,251 @@
1
+\documentclass{beamer}
2
+%\documentclass[aspectratio=169]{beamer}
3
+
4
+% You have to install the theme first!
5
+
6
+% corporate design of TU Wien
7
+\usetheme[font=helvetica]{tuw}
8
+% background "TU main building" on title page
9
+%\usetheme[tuw_background]{tuw}
10
+% individual background on title page
11
+%\usetheme[tuw_image=TU_Background]{tuw}
12
+% white logo if you have a dark background image
13
+%\usetheme[tuw_image=TU_Background,tuw_whitelogo]{tuw}
14
+% sidebar (not in TU Wien CD! but nice for long presentations)
15
+% width of the sidebar can be changed with option: "width=2cm"
16
+%\usetheme[outer=sidebar]{tuw}
17
+% move frametitle up (beside logo)
18
+%\usetheme[tuw_frametitletotop]{tuw}
19
+
20
+% if you use german umlaute use T1 encoding:
21
+%\usepackage[T1]{fontenc}
22
+% default Latex fonts are not T1 supported -> bitmaps used, this is not nice on
23
+% screen; you can use the lmodern package instead
24
+%\usepackage{lmodern}
25
+\usepackage[utf8]{inputenc}
26
+\usepackage{listings}
27
+\usepackage{booktabs}
28
+\usepackage{url}
29
+\usepackage{xcolor}
30
+
31
+\definecolor{codegreen}{rgb}{0,0.6,0}
32
+\definecolor{codegray}{rgb}{0.5,0.5,0.5}
33
+\definecolor{codepurple}{rgb}{0.58,0,0.82}
34
+\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
35
+\definecolor{verylightgray}{rgb}{.97,.97,.97}
36
+
37
+\lstdefinelanguage{Solidity}{
38
+	keywords=[1]{anonymous, assembly, assert, balance, break, call, callcode, case, catch, class, constant, continue, constructor, contract, debugger, default, delegatecall, delete, do, else, emit, event, experimental, export, external, false, finally, for, function, gas, if, implements, import, in, indexed, instanceof, interface, internal, is, length, library, log0, log1, log2, log3, log4, memory, modifier, new, payable, pragma, private, protected, public, pure, push, require, return, returns, revert, selfdestruct, send, solidity, storage, struct, suicide, super, switch, then, this, throw, transfer, true, try, typeof, using, value, view, while, with, addmod, ecrecover, keccak256, mulmod, ripemd160, sha256, sha3}, % generic keywords including crypto operations
39
+	keywordstyle=[1]\color{blue}\bfseries,
40
+	keywords=[2]{address, bool, byte, bytes, bytes1, bytes2, bytes3, bytes4, bytes5, bytes6, bytes7, bytes8, bytes9, bytes10, bytes11, bytes12, bytes13, bytes14, bytes15, bytes16, bytes17, bytes18, bytes19, bytes20, bytes21, bytes22, bytes23, bytes24, bytes25, bytes26, bytes27, bytes28, bytes29, bytes30, bytes31, bytes32, enum, int, int8, int16, int24, int32, int40, int48, int56, int64, int72, int80, int88, int96, int104, int112, int120, int128, int136, int144, int152, int160, int168, int176, int184, int192, int200, int208, int216, int224, int232, int240, int248, int256, mapping, string, uint, uint8, uint16, uint24, uint32, uint40, uint48, uint56, uint64, uint72, uint80, uint88, uint96, uint104, uint112, uint120, uint128, uint136, uint144, uint152, uint160, uint168, uint176, uint184, uint192, uint200, uint208, uint216, uint224, uint232, uint240, uint248, uint256, var, void, ether, finney, szabo, wei, days, hours, minutes, seconds, weeks, years},	% types; money and time units
41
+	keywordstyle=[2]\color{teal}\bfseries,
42
+	keywords=[3]{block, blockhash, coinbase, difficulty, gaslimit, number, timestamp, msg, data, gas, sender, sig, value, now, tx, gasprice, origin},	% environment variables
43
+	keywordstyle=[3]\color{violet}\bfseries,
44
+	identifierstyle=\color{black},
45
+	sensitive=true,
46
+	comment=[l]{//},
47
+	morecomment=[s]{/*}{*/},
48
+	commentstyle=\color{gray}\ttfamily,
49
+	stringstyle=\color{red}\ttfamily,
50
+	morestring=[b]',
51
+	morestring=[b]"
52
+}
53
+
54
+\lstset{
55
+	language=Solidity,
56
+	backgroundcolor=\color{verylightgray},
57
+	extendedchars=true,
58
+	basicstyle=\footnotesize\ttfamily,
59
+	showstringspaces=false,
60
+	showspaces=false,
61
+	numbers=left,
62
+	numberstyle=\footnotesize,
63
+	numbersep=9pt,
64
+	tabsize=2,
65
+	breaklines=true,
66
+	showtabs=false,
67
+	captionpos=b
68
+}
69
+
70
+%%% title page settings
71
+\title[SWC-124]{%
72
+  SWC-124: Write to Arbitrary Storage Location
73
+}
74
+\subtitle{192.127 Seminar in Software Engineering (Smart Contracts)}
75
+\author{Ivaylo Ivanov \& Peter Millauer}
76
+\date{\today}
77
+
78
+%%% slides start here
79
+\begin{document}
80
+
81
+% first frame must include the title page!
82
+\begin{frame}
83
+  \titlepage
84
+\end{frame}
85
+
86
+% table of contents if you have a long presentation (uses 'part' and 'section'
87
+% elements)
88
+\begin{frame}{Outline}
89
+  \tableofcontents
90
+\end{frame}
91
+
92
+\section{Introduction}
93
+
94
+\subsection[SWC-124: Weakness Outline]{SWC-124: Weakness Outline}
95
+\begin{frame}[fragile]
96
+  \frametitle{SWC-124: Weakness Outline}
97
+  SWC-124 is a weakness that allows attackers to write to places in the storage where they should not be able to.
98
+  It can be used to gain unauthorized access, overwrite data, steal funds etc.
99
+\end{frame}
100
+
101
+\begin{frame}[fragile]
102
+  \frametitle{SWC-124: Weakness Outline}
103
+  We generally differentiate three types of SWC-124:
104
+\begin{itemize}
105
+  \item unchecked array write
106
+  \item incorrect array length check
107
+  \item unchecked assembly code
108
+\end{itemize}
109
+
110
+  Examples follow, use in production at your own risk ;)
111
+\end{frame}
112
+
113
+\subsection[Examples]{Examples}
114
+\begin{frame}[fragile]
115
+  \frametitle{Unchecked Array Write}
116
+  \begin{lstlisting}[language=Solidity]
117
+pragma solidity 0.4.25;
118
+
119
+contract MyContract {
120
+  uint[] private arr;
121
+
122
+  constructor() public {
123
+    arr = new uint[](0);
124
+  }
125
+
126
+  function write(unit index, uint value) {
127
+    arr[index] = value;
128
+  }
129
+}
130
+  \end{lstlisting}
131
+\end{frame}
132
+\begin{frame}[fragile]
133
+  \frametitle{Incorrect Array Length Check}
134
+	\begin{lstlisting}[language=Solidity, basicstyle=\tiny\ttfamily, numberstyle=\tiny]
135
+pragma solidity 0.4.25;
136
+
137
+contract MyContract {
138
+  uint[] private arr;
139
+
140
+  constructor() public {
141
+    arr = new uint[](0);
142
+  }
143
+
144
+  function push(value) {
145
+    arr[arr.length] = value;
146
+    arr.length++;
147
+  }
148
+
149
+  function pop() {
150
+    require(arr.length >= 0);
151
+    arr.length--;
152
+  }
153
+
154
+  function update(unit index, uint value) {
155
+    require(index < arr.length);
156
+    arr[index] = value;
157
+  }
158
+}
159
+	\end{lstlisting}
160
+\end{frame}
161
+\begin{frame}[fragile]
162
+  \frametitle{Unchecked Assembly}
163
+	\begin{lstlisting}[language=Solidity, basicstyle=\tiny\ttfamily, numberstyle=\tiny, breaklines=true]
164
+pragma solidity 0.4.25;
165
+
166
+contract MyContract {
167
+  address private owner;
168
+  mapping(address => bool) public managers;
169
+
170
+  constructor() public {
171
+    owner = msg.sender;
172
+    setNextUserRole(msg.sender);
173
+  }
174
+
175
+  function setNextManager(address next) internal {
176
+    uint256 slot;
177
+    assembly {
178
+      slot := managers.slot
179
+      sstore(slot, next)
180
+    }
181
+    bytes32 location = keccak256(abi.encode(160, uint256(slot)));
182
+    assembly {
183
+      sstore(location, true)
184
+    }
185
+  }
186
+
187
+  function registerUser(address user) {
188
+    require(msg.sender == owner);
189
+    setNextManager(user);
190
+  }
191
+}
192
+	\end{lstlisting}
193
+\end{frame}
194
+
195
+\section{Detecting and Exploiting}
196
+\subsection[Detecting SWC-124]{Detecting SWC-124}
197
+\begin{frame}[fragile]
198
+  \frametitle{SWC-124: Detection Heuristics 1}
199
+  Any contract without dynamic arrays (or mappings with integer keys) or raw assembly including a SSTORE instruction can immediately be considered non-vulnerable.
200
+\end{frame}
201
+
202
+\begin{frame}[fragile]
203
+  \frametitle{SWC-124: Detection Heuristics 2}
204
+  If heuristic 1 does not hold, we can then apply a second heuristic: checking the solidity compiler version, specified at the top of the contract. Solidity version 0.8.0+ introduced integer under- and overflow protection, which are enabled per default and require extra work to be disabled.
205
+\end{frame}
206
+
207
+\begin{frame}[fragile]
208
+  \frametitle{SWC-124: Detection Heuristics 2.1}
209
+  If the version of the contract is higher than 0.8.0, we examine whether unchecked arithmetic has been used for modifying the arrays. If this is not the case, which it is not most of the time, we can then determine that the contract is non-vulnerable. Applying this heuristic, we found a contract that could have been vulnerable had it been compiled with a lower solidity version.
210
+
211
+  \begin{block}{Note on assembly}
212
+    Due to the nature of the examples given, we could not find reliable heuristics for unchecked assembly.
213
+  \end{block}
214
+\end{frame}
215
+
216
+
217
+\begin{frame}[fragile]
218
+  \frametitle{SWC-124: Detection Tools}
219
+  \begin{itemize}
220
+    \item existing static analysis tools were useless - most of them had no support for SWC-124
221
+    \item \texttt{solc-select} - for changing solidity compiler versions
222
+    \item \texttt{slither} - for printing contract variable layout
223
+  \end{itemize}
224
+\end{frame}
225
+
226
+\subsection[Exploiting SWC-124]{Exploiting SWC-124}
227
+
228
+% TODO: Exploitation is trivial, should we just go back and explain or should we go into memory layout? Can we handle it in time?
229
+
230
+\begin{frame}[fragile]
231
+  \frametitle{Vulnerable Examples}
232
+  Using the previously mentioned heuristics, we could not find a vulnerable contract from the dataset.
233
+\end{frame}
234
+
235
+\section{Future Work}
236
+\begin{frame}[fragile]
237
+  \frametitle{Future Work}
238
+\begin{itemize}
239
+  \item add heuristics to static analysis tool like \texttt{slither} or \texttt{mythril}
240
+  \item develop additional vulnerable and non-vulnerable contracts and test against heuristics
241
+  \item train a model against the resulting dataset
242
+  \item fine-tune heuristics
243
+\end{itemize}
244
+\end{frame}
245
+\section{Conclusion}
246
+\begin{frame}[fragile]
247
+  Questions?
248
+\end{frame}
249
+
250
+
251
+\end{document}

Loading…
Cancel
Save