# Beveiliging ## XSS preventie ```php // Altijd escapen echo htmlspecialchars($userInput, ENT_QUOTES, 'UTF-8'); // In Twig (automatisch) {{ userVariable }} ``` ## CSRF tokens ```php // Genereren $csrf = $auth->getCsrfToken(); // Verifiëren if (!$auth->verifyCsrf($_POST['csrf_token'])) { die('Ongeldige CSRF token'); } ``` ## Path traversal preventie ```php // Gebruik realpath() en check prefix $realPath = realpath($filePath); $realContentDir = realpath($contentDir); if (strpos($realPath, $realContentDir) !== 0) { die('Ongeldig pad'); } ```