Select Git revision
dbs-20231214.tex
Forked from
Peter Gerwinski / Datenbanken und Datensicherheit
80 commits behind the upstream repository.
Peter Gerwinski authored
dbs-20231214.tex 6.15 KiB
% dbs-20221214.pdf - Lecture Slides on Databases and Information Security
% Copyright (C) 2023 Peter Gerwinski
%
% This document is free software: you can redistribute it and/or
% modify it either under the terms of the Creative Commons
% Attribution-ShareAlike 3.0 License, or under the terms of the
% GNU General Public License as published by the Free Software
% Foundation, either version 3 of the License, or (at your option)
% any later version.
%
% This document is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this document. If not, see <http://www.gnu.org/licenses/>.
%
% You should have received a copy of the Creative Commons
% Attribution-ShareAlike 3.0 Unported License along with this
% document. If not, see <http://creativecommons.org/licenses/>.
% README: @@@
\documentclass[10pt,t]{beamer}
\usepackage{pgslides}
\newcommand{\vfilll}{\vspace{0pt plus 1filll}}
\newcommand{\underconstruction}{%
\begin{picture}(0,0)
\put(11,1.2){\makebox(0,0)[b]{\includegraphics[width=1.5cm]{Zeichen_123.pdf}}}
\put(11,0.9){\makebox(0,0)[t]{\shortstack{Änderungen\\vorbehalten}}}
\end{picture}}
\title{Datenbanken und Datensicherheit}
\author{Prof.\ Dr.\ rer.\ nat.\ Peter Gerwinski}
\date{14.\ Dezember 2023}
\begin{document}
\maketitleframe
\nosectionnonumber{\inserttitle}
\begin{frame}
\shownosectionnonumber
\begin{itemize}
\item[\textbf{1}] \textbf{Einführung}
\hfill\makebox(0,0)[br]{\raisebox{2.25ex}{\url{https://gitlab.cvh-server.de/pgerwinski/dbs}}}%
\item[\textbf{2}] \textbf{Kurzeinführung Unix}
\item[\textbf{3}] \textbf{Kurzeinführung TCP/IP}
\item[\textbf{4}] \textbf{Relationale Datenbanken}
\begin{itemize}
\vspace*{-\smallskipamount}
\item[\textbf{\dots}]
\item[4.9] Indizierung
\color{medgreen}
\item[4.10] Funktionen und Trigger
\item[4.11] GUI-Zugriff
\item[4.12] SQL Injection
\color{red}
\item[4.13] Datensicherheit bei Datenbanken
\item[4.14] Sonstige Datenbanken
\end{itemize}
\item[\textbf{5}] \textbf{Kryptographie}
\begin{itemize}
\color{red}
\item[5.1] Einführung
\vspace*{-\smallskipamount}
\item[\textbf{\dots}]
\end{itemize}
\vspace*{-\smallskipamount}
\item[\textbf{\dots}]
\end{itemize}
\vfilll
\underconstruction
\end{frame}
\setcounter{section}{3}
\section{Relationale Datenbanken}
\setcounter{subsection}{9}
\subsection{Funktionen und Trigger}
\begin{frame}
\showsection
\showsubsection
Funktionen:
\begin{itemize}
\item
\lstinline[style=cmd]{PROCEDURE} entspricht einer \lstinline{void}-Funktion in C.
\item
\url{https://www.postgresql.org/docs/15/sql-createprocedure.html}
\end{itemize}
\bigskip
Trigger:
\begin{itemize}
\item
\url{https://www.sqltutorial.org/sql-triggers/}
\item
\url{https://www.postgresqltutorial.com/postgresql-triggers/creating-first-trigger-postgresql/}
\end{itemize}
\end{frame}
\subsection{GUI-Zugriff}
\begin{frame}
\showsection
\showsubsection
\begin{itemize}
\item
Anwendung nutzt DBMS-Client-Bibliothek\\
GUI-Programmierung: wie gewohnt
\item
Spezialfall: Web-Anwendung
\end{itemize}
\bigskip
Beispiel: Programmiersprache PHP
\begin{itemize}
\item
Integration in HTML-Quelltext: \lstinline{<?php ... ?>}
\item
Objekt zur Kommunikation mit Datenbanken: \lstinline{PDO}
\end{itemize}
\bigskip
Literatur:
\begin{itemize}
\item
\url{https://www.postgresqltutorial.com/postgresql-php/connect/}
\item
\url{https://www.phptutorial.net/php-pdo/pdo-connecting-to-postgresql/}
\end{itemize}
\end{frame}
\subsection{SQL Injection}
\begin{frame}[fragile]
\showsection
\showsubsection
Problem:
\begin{itemize}
\item
Ein böswilliger Benutzer gibt über eine Benutzerschnittstelle
(z.\,B.\ ein Web-Interface) Daten ein (z.\,B.\ einen "`Namen"'),
die Sonderzeichen enthalten, damit sie als SQL-Befehle ausgeführt werden.
\item
Literatur: \url{https://xkcd.com/327/}
\end{itemize}
\medskip
Lösung: Die Benutzerschnittstelle prüft die Daten auf Sonderzeichen\\
und ersetzt diese durch geeignete Escape-Sequenzen
\begin{itemize}
\item
\lstinline[style=cmd]{'} durch \lstinline[style=cmd]{''} ersetzen
\item
Funktion \lstinline[style=cmd]{CHR()}
\item
Viele DBMS verstehen ein vorangestelltes \lstinline[style=cmd]{\}.
\end{itemize}
\medskip
Bessere Lösung: \newterm{Prepared Statements}
\begin{itemize}
\item
\url{https://www.postgresql.org/docs/current/sql-prepare.html}
\item
\url{https://www.w3schools.com/php/php_mysql_prepared_statements.asp}
\end{itemize}
\end{frame}
\subsection{Datensicherheit bei Datenbanken}
\begin{frame}
\showsection
\showsubsection
\begin{itemize}
\item
kein direkter Zugriff von außen auf die Datenbank
\item
feingranulare Benutzerrechte
\item
Software aktuell halten
\item
Prepared Statements
\item
Transportverschlüsselung
\end{itemize}
\end{frame}
\subsection{Sonstige Datenbanken}
\begin{frame}
\showsection
\showsubsection
\begin{itemize}
\item
Eingebettete Datenbanken:\\
Berkeley DB, SQLite\\
Software-Bibliothek, keine Client-Server-Struktur
\item
Nicht-relationale Datenbanken:\\
dokumentenorientierte Datenbanken, noSQL\\
Performanz wichtiger als Konsistenz\\
\textarrow\ Applikationen stärker in Konsistenzprüfung eingebunden
\end{itemize}
\end{frame}
\section{Kryptographie}
\subsection{Einführung}
\begin{frame}
\showsection
\showsubsection
\begin{itemize}
\item
Verschlüsselung: symmetrisch, asymmetrisch, hybrid
\item
Hashes: Einwegfunktionen, Salt
\item
Signaturen, Zertifikate
\item
Schlüsselaustausch
\end{itemize}
\end{frame}
\end{document}