Implement CSRF protection for user invitation and management actions; add QR code generation script; secure internal includes directory with .htaccess

This commit is contained in:
2026-09-11 14:46:08 +02:00
parent 55618ffaed
commit cf0ceeca82
18 changed files with 413 additions and 163 deletions
+29 -2
View File
@@ -9,14 +9,41 @@ require_once __DIR__ . '/../../config/database.php';
require_once __DIR__ . '/../cache.php';
/**
* Normaliseert het Jira domein naar een schone URL zonder slash aan het einde
* Normaliseert het Jira domein naar een schone URL zonder slash aan het einde.
* Bevat SSRF-bescherming: weigert loopbacks, localhost en private netwerkadressen.
*/
function jira_normalize_domain(string $domain): string {
$domain = trim($domain);
if (empty($domain)) {
return '';
}
if (!preg_match('#^https?://#i', $domain)) {
$domain = 'https://' . $domain;
}
return rtrim($domain, '/');
$domain = rtrim($domain, '/');
// Parseer en valideer de host ter voorkoming van SSRF (Server-Side Request Forgery)
$parsed = parse_url($domain);
$host = $parsed['host'] ?? '';
if (empty($host)) {
return '';
}
$lowerHost = strtolower($host);
// Weiger localhost en local domains
if ($lowerHost === 'localhost' || str_ends_with($lowerHost, '.localhost') || str_ends_with($lowerHost, '.local') || str_ends_with($lowerHost, '.internal')) {
return '';
}
// Weiger private IP-ranges en loopback adressen (bijv. 127.0.0.1, 192.168.x, 10.x, 172.16.x, 169.254.x)
if (filter_var($host, FILTER_VALIDATE_IP)) {
if (!filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
return '';
}
}
return $domain;
}
/**