add why-this-works slide

This commit is contained in:
nitowa
2024-01-10 03:02:54 +01:00
parent c0b2c1a005
commit 8180295b9f
3 changed files with 20 additions and 9 deletions
Binary file not shown.
+20 -9
View File
@@ -117,15 +117,17 @@
pragma solidity 0.4.25; pragma solidity 0.4.25;
contract MyContract { contract MyContract {
uint[] private arr; address private owner;
uint[] private arr;
constructor() public {
arr = new uint[](0); constructor() public {
} arr = new uint[](0);
owner = msg.sender;
function write(unit index, uint value) { }
arr[index] = value;
} function write(unit index, uint value) {
arr[index] = value;
}
} }
\end{lstlisting} \end{lstlisting}
\end{frame} \end{frame}
@@ -192,6 +194,15 @@ contract MyContract {
\end{lstlisting} \end{lstlisting}
\end{frame} \end{frame}
\begin{frame}[fragile]
\frametitle{Why this works}
A dynamic array in storage slot $p$ stores its data at continuous addresses starting at $keccak(p)$.
For example, if the variable $x$ is a dynamic array occupying storage slot 3, $x[o]$ can be found at $keccak(0x3)+o$.
An attacker can use this information to overwrite any storage slot by finding an appropriate offset value.
\end{frame}
\section{Detecting and Exploiting} \section{Detecting and Exploiting}
\subsection[Detecting SWC-124]{Detecting SWC-124} \subsection[Detecting SWC-124]{Detecting SWC-124}
\begin{frame}[fragile] \begin{frame}[fragile]
Binary file not shown.