Skip to content

Commit d5df52f

Browse files
Add ret2rsp
1 parent f8b990a commit d5df52f

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

chapters/04-attack-vectors.tex

+22
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,28 @@ \subsection{ret2rax}
528528
\label{fig:ret2rax}
529529
\end{figure}
530530

531+
\subsection{ret2rsp}
532+
\label{subsec:aici-ret2rsp}
533+
534+
Similar to the the ret2rax approach, the \emph{ret2rsp} approach is based on register contents at the end of a function.
535+
Also, like ret2rax, the suffix is derived from the register name.
536+
On \texttt{x86\_64}, the suffix is thus \texttt{rsp} where it was \texttt{esp} in the original proposal by \citeauthor{Kotler2005} \cite{Kotler2005}.
537+
538+
When a stack buffer overflow vulnerability can be found in a function, an attacker can overflow the buffer so that they overwrite the function's return address with the address of a \texttt{jmp rsp} instruction or an instruction with similar behavior.
539+
After this address, the attacker then puts the shellcode they want to execute.
540+
After running the function epilogue, the stack pointer points to the return address on the stack.
541+
The function's \texttt{ret} instruction then pops the return address from the stack and execution is continued at this address.
542+
The stack pointer thus points directly after the \gls{rip} on the stack when the \texttt{jmp rsp} instruction is executed.
543+
Because of this jump instruction, execution is continued at the address that is found in the \texttt{rsp} register which points to the shellcode on the stack.
544+
An example how stack layout could look like when conducting such an attack is shown in \cref{fig:ret2rsp}.
545+
546+
\begin{figure}[htb]
547+
\centering
548+
\includegraphics[width=0.7\textwidth]{figures/ret2rsp}
549+
\caption{Stack layout before and after a stack buffer overflow with ret2rsp approach (own graphical representation based on figure 22 in \cite[13]{Mueller2008})}
550+
\label{fig:ret2rsp}
551+
\end{figure}
552+
531553
\section*{ToDo}
532554

533555
\begin{itemize}

figures/ret2rsp.odg

18.5 KB
Binary file not shown.

figures/ret2rsp.pdf

17.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)