Skip to content

Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.

fix: ssrf vulnerability on all test notifications endpoint

Miguel Ribeiroe8a513591dbb
diff --git a/admin.php b/admin.php
index 863e622..6cea995 100644
--- a/admin.php
+++ b/admin.php
@@ -338,6 +338,33 @@ $loginDisabledAllowed = $userCount == 1 && $settings['registrations_open'] == 0;
</div>
</section>
+ <section class="account-section">
+ <header>
+ <h2><?= translate('security_settings', $i18n) ?></h2> </header>
+ <div class="admin-form">
+ <div class="form-group-inline">
+ <input type="text" name="local_webhook_notifications_allowlist" id="local_webhook_notifications_allowlist" autocomplete="off"
+ placeholder="e.g., 192.168.1.5:8123, homeassistant.local" value="<?= htmlspecialchars($settings['local_webhook_notifications_allowlist'] ?? '', ENT_QUOTES, 'UTF-8') ?>" />
+ </div>
+
+ <div class="buttons">
+ <input type="submit" class="thin mobile-grow" value="<?= translate('save', $i18n) ?>"
+ id="saveSecuritySettingsButton" onClick="saveSecuritySettingsButton()" />
+ </div>
+
+ <div class="settings-notes">
+ <p>
+ <i class="fa-solid fa-circle-info"></i>
+ <?= translate('ssrf_protection_info', $i18n) ?>
+ </p>
+ <p>
+ <i class="fa-solid fa-circle-info"></i>
+ <?= translate('local_webhook_info', $i18n) ?>
+ </p>
+ </div>
+ </div>
+</section>
+
<?php
// Get latest version from admin table
if (!is_null($settings['latest_version'])) {
diff --git a/endpoints/admin/savesecuritysettings.php b/endpoints/admin/savesecuritysettings.php
new file mode 100644
index 0000000..f3635b4
--- /dev/null
+++ b/endpoints/admin/savesecuritysettings.php
@@ -0,0 +1,36 @@
+<?php
+
+require_once '../../includes/connect_endpoint.php';
+require_once '../../includes/validate_endpoint_admin.php';
+
+$postData = file_get_contents("php://input");
+$data = json_decode($postData, true);
+
+if (!isset($data['local_webhook_notifications_allowlist'])) {
+ echo json_encode([
+ "success" => false,
+ "message" => translate('error', $i18n)
+ ]);
+ die();
+}
+
+// Basic cleanup: trim whitespace and strip any accidental HTML tags
+$allowlist = trim(strip_tags($data['local_webhook_notifications_allowlist']));
+
+// Update the admin table (assuming id 1 is the primary settings row, as in your reference)
+$sql = "UPDATE admin SET local_webhook_notifications_allowlist = :allowlist WHERE id = 1";
+$stmt = $db->prepare($sql);
+$stmt->bindParam(':allowlist', $allowlist, SQLITE3_TEXT);
+$result = $stmt->execute();
+
+if ($result) {
+ echo json_encode([
+ "success" => true,
+ "message" => translate('success', $i18n)
+ ]);
+} else {
+ echo json_encode([
+ "success" => false,
+ "message" => translate('error', $i18n)
+ ]);
+}
\ No newline at end of file
diff --git a/endpoints/notifications/testdiscordnotifications.php b/endpoints/notifications/testdiscordnotifications.php
index ef0e42b..f4ac12b 100644
--- a/endpoints/notifications/testdiscordnotifications.php
+++ b/endpoints/notifications/testdiscordnotifications.php
@@ -2,6 +2,7 @@
require_once '../../includes/connect_endpoint.php';
require_once '../../includes/validate_endpoint.php';
+require_once '../../includes/ssrf_helper.php';
$postData = file_get_contents("php://input");
$data = json_decode($postData, true);
@@ -36,6 +37,8 @@ if (
]));
}
+ $ssrf = validate_webhook_url_for_ssrf($webhook_url, $db, $i18n);
+
$postfields = [
'content' => $message,
'embeds' => [
@@ -59,6 +62,9 @@ if (
// Set the URL and other options
curl_setopt($ch, CURLOPT_URL, $webhook_url);
+
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
+ curl_setopt($ch, CURLOPT_RESOLVE, ["{$ssrf['host']}:{$ssrf['port']}:{$ssrf['ip']}"]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postfields));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
diff --git a/endpoints/notifications/testgotifynotifications.php b/endpoints/notifications/testgotifynotifications.php
index 69d0687..e3d05a8 100644
--- a/endpoints/notifications/testgotifynotifications.php
+++ b/endpoints/notifications/testgotifynotifications.php
@@ -1,7 +1,7 @@
<?php
require_once '../../includes/connect_endpoint.php';
require_once '../../includes/validate_endpoint.php';
-
+require_once '../../includes/ssrf_helper.php';
$postData = file_get_contents("php://input");
$data = json_decode($postData, true);
@@ -38,10 +38,15 @@ if (
]));
}
+ $ssrf = validate_webhook_url_for_ssrf($url, $db, $i18n);
+
$ch = curl_init();
// Set the URL and other options
curl_setopt($ch, CURLOPT_URL, $url . "/message?token=" . $token);
+
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
+ curl_setopt($ch, CURLOPT_RESOLVE, ["{$ssrf['host']}:{$ssrf['port']}:{$ssrf['ip']}"]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
'title' => $title,
diff --git a/endpoints/notifications/testmattermostnotifications.php b/endpoints/notifications/testmattermostnotifications.php
index 663f243..63a99cb 100755
--- a/endpoints/notifications/testmattermostnotifications.php
+++ b/endpoints/notifications/testmattermostnotifications.php
@@ -2,6 +2,7 @@
require_once '../../includes/connect_endpoint.php';
require_once '../../includes/validate_endpoint.php';
+require_once '../../includes/ssrf_helper.php';
$postData = file_get_contents("php://input");
$data = json_decode($postData, true);
@@ -38,6 +39,8 @@ if (
]));
}
+ $ssrf = validate_webhook_url_for_ssrf($webhook_url, $db, $i18n);
+
$postfields = [
'text' => $message,
];
@@ -54,6 +57,8 @@ if (
// Set the URL and other options
curl_setopt($ch, CURLOPT_URL, $webhook_url);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
+ curl_setopt($ch, CURLOPT_RESOLVE, ["{$ssrf['host']}:{$ssrf['port']}:{$ssrf['ip']}"]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postfields));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
diff --git a/endpoints/notifications/testntfynotifications.php b/endpoints/notifications/testntfynotifications.php
index 61d6b3c..97b1bfd 100644
--- a/endpoints/notifications/testntfynotifications.php
+++ b/endpoints/notifications/testntfynotifications.php
@@ -2,6 +2,7 @@
require_once '../../includes/connect_endpoint.php';
require_once '../../includes/validate_endpoint.php';
+require_once '../../includes/ssrf_helper.php';
$postData = file_get_contents("php://input");
$data = json_decode($postData, true);
@@ -42,6 +43,8 @@ if (
]));
}
+ $ssrf = validate_webhook_url_for_ssrf($url, $db, $i18n);
+
// Set the message parameters
$message = translate('test_notification', $i18n);
@@ -49,6 +52,8 @@ if (
// Set the URL and other options
curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
+ curl_setopt($ch, CURLOPT_RESOLVE, ["{$ssrf['host']}:{$ssrf['port']}:{$ssrf['ip']}"]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
curl_setopt($ch, CURLOPT_HTTPHEADER, $customheaders);
diff --git a/endpoints/notifications/testwebhooknotifications.php b/endpoints/notifications/testwebhooknotifications.php
index 7e0880e..14b9eed 100644
--- a/endpoints/notifications/testwebhooknotifications.php
+++ b/endpoints/notifications/testwebhooknotifications.php
@@ -2,6 +2,7 @@
require_once '../../includes/connect_endpoint.php';
require_once '../../includes/validate_endpoint.php';
+require_once '../../includes/ssrf_helper.php';
// Variables available: {{days_until}}, {{subscription_name}}, {{subscription_price}}, {{subscription_currency}}, {{subscription_category}}, {{subscription_date}}, {{subscription_payer}}, {{subscription_days_until_payment}}, {{subscription_notes}}, {{subscription_url}}
$fakeSubscription = [
@@ -48,6 +49,8 @@ if (
]));
}
+ $ssrf = validate_webhook_url_for_ssrf($url, $db, $i18n);
+
// Replace placeholders in the payload with fake subscription data
foreach ($fakeSubscription as $key => $value) {
$placeholder = "{{" . $key . "}}";
@@ -61,6 +64,8 @@ if (
// Set the URL and other options
curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
+ curl_setopt($ch, CURLOPT_RESOLVE, ["{$ssrf['host']}:{$ssrf['port']}:{$ssrf['ip']}"]);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $requestmethod);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
if (!empty($customheaders)) {
diff --git a/endpoints/user/delete_avatar.php b/endpoints/user/delete_avatar.php
index ae9ec47..559a444 100644
--- a/endpoints/user/delete_avatar.php
+++ b/endpoints/user/delete_avatar.php
@@ -7,6 +7,21 @@ $input = json_decode(file_get_contents('php://input'), true);
if (isset($input['avatar'])) {
$baseDir = realpath("../../images/uploads/logos/avatars/");
$avatar = $input['avatar'];
+ $avatarPath = "images/uploads/logos/avatars/" . $avatar;
+
+ $stmt = $db->prepare("SELECT id FROM uploaded_avatars WHERE user_id = :userId AND path = :path");
+ $stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
+ $stmt->bindValue(':path', $avatarPath, SQLITE3_TEXT);
+ $result = $stmt->execute();
+ $ownership = $result->fetchArray(SQLITE3_ASSOC);
+
+ if (!$ownership) {
+ echo json_encode([
+ "success" => false,
+ "message" => "Security Error: You do not have permission to delete this file."
+ ]);
+ exit;
+ }
$cleanAvatar = rawurldecode($avatar);
$cleanAvatar = preg_replace('/[^a-zA-Z0-9_\-\.]/', '', $cleanAvatar);
@@ -16,7 +31,7 @@ if (isset($input['avatar'])) {
if ($filePath === false || strpos($filePath, $baseDir) !== 0) {
echo json_encode([
"success" => false,
- "message" => "Invalid file path"
+ "message" => "Invalid file path."
]);
exit;
}
@@ -27,12 +42,15 @@ if (isset($input['avatar'])) {
$result = $stmt->execute();
$userAvatar = $result->fetchArray(SQLITE3_ASSOC)['avatar'];
- // Check if $avatar matches the avatar in the user table
- if ($avatar === $userAvatar) {
+ // Check if $avatarPath matches the avatar in the user table
+ if ($avatarPath === $userAvatar) {
echo json_encode(array("success" => false, "message" => "Avatar in use"));
} else {
if (file_exists($filePath)) {
unlink($filePath);
+ $delStmt = $db->prepare("DELETE FROM uploaded_avatars WHERE id = :id");
+ $delStmt->bindValue(':id', $ownership['id'], SQLITE3_INTEGER);
+ $delStmt->execute();
echo json_encode(array("success" => true, "message" => translate("success", $i18n)));
} else {
echo json_encode(array("success" => false, "message" => translate("error", $i18n)));
diff --git a/endpoints/user/save_user.php b/endpoints/user/save_user.php
index e94661a..cfd3b53 100644
--- a/endpoints/user/save_user.php
+++ b/endpoints/user/save_user.php
@@ -255,6 +255,13 @@ if (
}
$name = $file['name'];
$avatar = resizeAndUploadAvatar($_FILES['profile_pic'], '../../images/uploads/logos/avatars/', $name);
+
+ if ($avatar !== "") {
+ $stmt = $db->prepare("INSERT INTO uploaded_avatars (user_id, path) VALUES (:userId, :path)");
+ $stmt->bindParam(':userId', $userId, SQLITE3_INTEGER);
+ $stmt->bindParam(':path', $avatar, SQLITE3_TEXT);
+ $stmt->execute();
+ }
}
if (isset($_POST['password']) && $_POST['password'] != "" && !$demoMode) {
diff --git a/includes/i18n/ca.php b/includes/i18n/ca.php
index 2bb4803..b53715a 100644
--- a/includes/i18n/ca.php
+++ b/includes/i18n/ca.php
@@ -386,6 +386,9 @@ $i18n = [
"disable_password_login" => "Desactivar l'inici de sessió amb contrasenya",
"smtp_settings" => "Configuració SMTP",
"smtp_usage_info" => "S'utilitza per recuperar contrasenyes i enviar altres correus electrònics del sistema.",
+ "security_settings" => "Configuració de seguretat",
+ "ssrf_protection_info" => "Per evitar atacs de Server-Side Request Forgery (SSRF), Wallos bloqueja per defecte les notificacions webhook a adreces de xarxa privades o internes.",
+ "local_webhook_info" => "Si necessiteu enviar webhooks a serveis locals (com Home Assistant, Gotify o Node-RED), introduïu les seves adreces IP o noms d'amfitrió anteriorment com una llista separada per comes (p. ex., <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Tasques de Manteniment",
"orphaned_logos" => "Logotips orfes",
"update" => "Actualitzar",
diff --git a/includes/i18n/cs.php b/includes/i18n/cs.php
index 13d2763..78e4af3 100644
--- a/includes/i18n/cs.php
+++ b/includes/i18n/cs.php
@@ -386,6 +386,9 @@ $i18n = [
"disable_password_login" => "Zakázat přihlašování pomocí hesla",
"smtp_settings" => "Nastavení SMTP",
"smtp_usage_info" => "Bude použito pro obnovení hesla a další systémové e-maily.",
+ "security_settings" => "Nastavení zabezpečení",
+ "ssrf_protection_info" => "Aby se předešlo útokům Server-Side Request Forgery (SSRF), Wallos ve výchozím nastavení blokuje webhook notifikace směrem na soukromé nebo interní síťové adresy.",
+ "local_webhook_info" => "Pokud potřebujete posílat webhooks na lokální služby (např. Home Assistant, Gotify nebo Node-RED), zadejte jejich IP adresy nebo názvy hostitelů výše jako seznam oddělený čárkami (např. <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Úkoly údržby",
"orphaned_logos" => "Osiřelá loga",
"update" => "Aktualizace",
diff --git a/includes/i18n/da.php b/includes/i18n/da.php
index 09d5f34..821ee85 100644
--- a/includes/i18n/da.php
+++ b/includes/i18n/da.php
@@ -385,6 +385,9 @@ $i18n = [
"create_user_automatically" => "Opret bruger automatisk",
"disable_password_login" => "Deaktivér adgangskode-login",
"smtp_settings" => "SMTP-indstillinger",
+ "security_settings" => "Sikkerhedsindstillinger",
+ "ssrf_protection_info" => "For at forhindre Server-Side Request Forgery (SSRF) angreb blokerer Wallos som standard webhook-notifikationer til private eller interne netværksadresser.",
+ "local_webhook_info" => "Hvis du skal sende webhooks til lokale tjenester (som Home Assistant, Gotify eller Node-RED), indtast deres IP-adresser eller værtsnavne ovenfor som en kommasepareret liste (fx <code>192.168.1.100,192.168.1.101</code>).",
"smtp_usage_info" => "Vil blive brugt til adgangskodenulstilling og andre systemmails.",
// Maintenance Tasks
"maintenance_tasks" => "Vedligeholdelsesopgaver",
diff --git a/includes/i18n/de.php b/includes/i18n/de.php
index cc4aff4..ea6cd6a 100644
--- a/includes/i18n/de.php
+++ b/includes/i18n/de.php
@@ -385,6 +385,9 @@ $i18n = [
"disable_password_login" => "Passwort-Login deaktivieren",
"smtp_settings" => "SMTP Einstellungen",
"smtp_usage_info" => "Wird für die Passwortwiederherstellung und andere System-E-Mails verwendet",
+ "security_settings" => "Sicherheitseinstellungen",
+ "ssrf_protection_info" => "Um Server-Side Request Forgery (SSRF)-Angriffe zu verhindern, blockiert Wallos standardmäßig Webhook-Benachrichtigungen an private oder interne Netzwerkadressen.",
+ "local_webhook_info" => "Wenn Sie Webhooks an lokale Dienste (z. B. Home Assistant, Gotify oder Node-RED) senden müssen, geben Sie deren IP-Adressen oder Hostnamen oben als durch Kommas getrennte Liste ein (z. B. <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Wartungsaufgaben",
"orphaned_logos" => "Verwaiste Logos",
"update" => "Update",
diff --git a/includes/i18n/el.php b/includes/i18n/el.php
index cb96bee..b713e67 100644
--- a/includes/i18n/el.php
+++ b/includes/i18n/el.php
@@ -384,6 +384,9 @@ $i18n = [
"create_user_automatically" => "Δημιουργία χρήστη αυτόματα",
"disable_password_login" => "Απενεργοποίηση σύνδεσης με κωδικό πρόσβασης",
"smtp_settings" => "SMTP ρυθμίσεις",
+ "security_settings" => "Ρυθμίσεις ασφάλειας",
+ "ssrf_protection_info" => "Για να αποτρέψετε επιθέσεις Server-Side Request Forgery (SSRF), το Wallos αποκλείει από προεπιλογή τις ειδοποιήσεις webhook σε ιδιωτικές ή εσωτερικές διευθύνσεις δικτύου.",
+ "local_webhook_info" => "Εάν πρέπει να στείλετε webhooks σε τοπικές υπηρεσίες (όπως Home Assistant, Gotify ή Node-RED), εισάγετε τις διευθύνσεις IP ή τα ονόματα κεντρικού υπολογιστή τους παραπάνω ως λίστα χωρισμένη με κόμματα (π.χ. <code>192.168.1.100,192.168.1.101</code>).",
"smtp_usage_info" => "Θα χρησιμοποιηθεί για ανάκτηση κωδικού πρόσβασης και άλλα μηνύματα ηλεκτρονικού ταχυδρομείου συστήματος.",
"maintenance_tasks" => "Εργασίες συντήρησης",
"orphaned_logos" => "Ορφανά λογότυπα",
diff --git a/includes/i18n/en.php b/includes/i18n/en.php
index 9ee31d9..c4ba827 100644
--- a/includes/i18n/en.php
+++ b/includes/i18n/en.php
@@ -386,6 +386,9 @@ $i18n = [
"disable_password_login" => "Disable password login",
"smtp_settings" => "SMTP Settings",
"smtp_usage_info" => "Will be used for password recovery and other system emails.",
+ "security_settings" => "Security Settings",
+ "ssrf_protection_info" => "To prevent Server-Side Request Forgery (SSRF) attacks, Wallos blocks webhook notifications to private or internal network addresses by default.",
+ "local_webhook_info" => "If you need to send webhooks to local services (like Home Assistant, Gotify, or Node-RED), enter their IP addresses or hostnames above as a comma-separated list (e.g., <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Maintenance Tasks",
"orphaned_logos" => "Orphaned Logos",
"update" => "Update",
diff --git a/includes/i18n/es.php b/includes/i18n/es.php
index 377e437..6d63077 100644
--- a/includes/i18n/es.php
+++ b/includes/i18n/es.php
@@ -385,6 +385,9 @@ $i18n = [
"disable_password_login" => "Deshabilitar inicio de sesión con contraseña",
"smtp_settings" => "Configuración SMTP",
"smtp_usage_info" => "Se utilizará para recuperar contraseñas y otros correos electrónicos del sistema.",
+ "security_settings" => "Configuración de seguridad",
+ "ssrf_protection_info" => "Para evitar ataques de falsificación de solicitudes del lado del servidor (SSRF), Wallos bloquea por defecto las notificaciones webhook a direcciones de red privadas o internas.",
+ "local_webhook_info" => "Si necesita enviar webhooks a servicios locales (como Home Assistant, Gotify o Node-RED), introduzca sus direcciones IP o nombres de host arriba como una lista separada por comas (p. ej., <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Tareas de Mantenimiento",
"orphaned_logos" => "Logotipos huérfanos",
"update" => "Actualizar",
diff --git a/includes/i18n/fr.php b/includes/i18n/fr.php
index 9371cd2..b743332 100644
--- a/includes/i18n/fr.php
+++ b/includes/i18n/fr.php
@@ -385,6 +385,9 @@ $i18n = [
"disable_password_login" => "Désactiver la connexion par mot de passe",
"smtp_settings" => "Paramètres SMTP",
"smtp_usage_info" => "Sera utilisé pour la récupération du mot de passe et d'autres e-mails système.",
+ "security_settings" => "Paramètres de sécurité",
+ "ssrf_protection_info" => "Pour prévenir les attaques Server-Side Request Forgery (SSRF), Wallos bloque par défaut les notifications webhook vers des adresses réseau privées ou internes.",
+ "local_webhook_info" => "Si vous devez envoyer des webhooks vers des services locaux (comme Home Assistant, Gotify ou Node-RED), saisissez leurs adresses IP ou noms d'hôte ci-dessus sous forme d'une liste séparée par des virgules (par ex. <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Tâches de maintenance",
"orphaned_logos" => "Logos orphelins",
"update" => "Mise à jour",
diff --git a/includes/i18n/id.php b/includes/i18n/id.php
index 7390ccd..7982ac7 100644
--- a/includes/i18n/id.php
+++ b/includes/i18n/id.php
@@ -386,6 +386,9 @@ $i18n = [
"disable_password_login" => "Nonaktifkan masuk dengan kata sandi",
"smtp_settings" => "Pengaturan SMTP",
"smtp_usage_info" => "Akan digunakan untuk pemulihan kata sandi dan email sistem lainnya.",
+ "security_settings" => "Pengaturan Keamanan",
+ "ssrf_protection_info" => "Untuk mencegah serangan Server-Side Request Forgery (SSRF), Wallos secara default memblokir notifikasi webhook ke alamat jaringan pribadi atau internal.",
+ "local_webhook_info" => "Jika Anda perlu mengirim webhook ke layanan lokal (seperti Home Assistant, Gotify, atau Node-RED), masukkan alamat IP atau nama host mereka di atas sebagai daftar yang dipisahkan koma (mis., <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Tugas Pemeliharaan",
"orphaned_logos" => "Logo Yatim Piatu",
"update" => "Perbarui",
diff --git a/includes/i18n/it.php b/includes/i18n/it.php
index 3342063..8308d76 100644
--- a/includes/i18n/it.php
+++ b/includes/i18n/it.php
@@ -404,6 +404,9 @@ $i18n = [
"disable_password_login" => "Disabilita la connessione con password",
"smtp_settings" => "Impostazioni SMTP",
"smtp_usage_info" => "Verrà utilizzato per il recupero della password e altre e-mail di sistema.",
+ "security_settings" => "Impostazioni di sicurezza",
+ "ssrf_protection_info" => "Per prevenire attacchi Server-Side Request Forgery (SSRF), Wallos blocca per impostazione predefinita le notifiche webhook verso indirizzi di rete privati o interni.",
+ "local_webhook_info" => "Se è necessario inviare webhook a servizi locali (come Home Assistant, Gotify o Node-RED), inserisci i loro indirizzi IP o nomi host sopra come elenco separato da virgole (ad es. <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Compiti di manutenzione",
"orphaned_logos" => "Loghi orfani",
"update" => "Aggiorna",
diff --git a/includes/i18n/jp.php b/includes/i18n/jp.php
index c3aaf75..3836189 100644
--- a/includes/i18n/jp.php
+++ b/includes/i18n/jp.php
@@ -386,6 +386,9 @@ $i18n = [
"disable_password_login" => "パスワードログインを無効にする",
"smtp_settings" => "SMTP設定",
"smtp_usage_info" => "パスワードの回復やその他のシステム電子メールに使用されます。",
+ "security_settings" => "セキュリティ設定",
+ "ssrf_protection_info" => "Server-Side Request Forgery(SSRF)攻撃を防ぐために、Wallosはデフォルトでプライベートまたは内部ネットワークアドレスへのWebhook通知をブロックします。",
+ "local_webhook_info" => "Home Assistant、Gotify、Node-REDなどのローカルサービスにWebhookを送信する必要がある場合は、それらのIPアドレスまたはホスト名を上記にカンマ区切りで入力してください(例:<code>192.168.1.100,192.168.1.101</code>)。",
"maintenance_tasks" => "メンテナンスタスク",
"orphaned_logos" => "孤立したロゴ",
"update" => "更新",
diff --git a/includes/i18n/ko.php b/includes/i18n/ko.php
index b10680b..58a9f83 100644
--- a/includes/i18n/ko.php
+++ b/includes/i18n/ko.php
@@ -385,6 +385,9 @@ $i18n = [
"disable_password_login" => "비밀번호 로그인 비활성화",
"smtp_settings" => "SMTP 설정",
"smtp_usage_info" => "비밀번호 복구 및 기타 시스템 이메일에 사용됩니다.",
+ "security_settings" => "보안 설정",
+ "ssrf_protection_info" => "서버 측 요청 위조(SSRF) 공격을 방지하기 위해 Wallos는 기본적으로 개인 또는 내부 네트워크 주소로의 webhook 알림을 차단합니다.",
+ "local_webhook_info" => "Home Assistant, Gotify 또는 Node-RED와 같은 로컬 서비스로 webhook을 보내야 하는 경우 해당 IP 주소 또는 호스트 이름을 위에 쉼표로 구분된 목록으로 입력하세요(예: <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "유지보수 작업",
"orphaned_logos" => "고아 로고",
"update" => "업데이트",
diff --git a/includes/i18n/nl.php b/includes/i18n/nl.php
index 51c61e1..5f43f0c 100644
--- a/includes/i18n/nl.php
+++ b/includes/i18n/nl.php
@@ -386,6 +386,9 @@ $i18n = [
"disable_password_login" => "Wachtwoordlogin uitschakelen",
"smtp_settings" => "SMTP-instellingen",
"smtp_usage_info" => "Wordt gebruikt voor wachtwoordherstel en andere systeem e-mails.",
+ "security_settings" => "Beveiligingsinstellingen",
+ "ssrf_protection_info" => "Om Server-Side Request Forgery (SSRF) aanvallen te voorkomen, blokkeert Wallos standaard webhookmeldingen naar privé- of interne netwerkadressen.",
+ "local_webhook_info" => "Als u webhooks naar lokale services moet sturen (zoals Home Assistant, Gotify of Node-RED), voer dan hun IP-adressen of hostnamen hierboven in als een door komma's gescheiden lijst (bijv. <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Onderhoudstaken",
"orphaned_logos" => "Ongebruikte logo's",
"update" => "Bijwerken",
diff --git a/includes/i18n/pl.php b/includes/i18n/pl.php
index 66a7a2d..5f4bb1c 100644
--- a/includes/i18n/pl.php
+++ b/includes/i18n/pl.php
@@ -385,6 +385,9 @@ $i18n = [
"disable_password_login" => "Wyłącz logowanie za pomocą hasła",
"smtp_settings" => "Ustawienia SMTP",
"smtp_usage_info" => "Będzie używany do odzyskiwania hasła i innych e-maili systemowych.",
+ "security_settings" => "Ustawienia zabezpieczeń",
+ "ssrf_protection_info" => "Aby zapobiec atakom Server-Side Request Forgery (SSRF), Wallos domyślnie blokuje powiadomienia webhook wysyłane na prywatne lub wewnętrzne adresy sieciowe.",
+ "local_webhook_info" => "Jeśli musisz wysyłać webhooki do lokalnych usług (np. Home Assistant, Gotify lub Node-RED), wprowadź ich adresy IP lub nazwy hostów powyżej jako listę oddzieloną przecinkami (np. <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Zadania konserwacyjne",
"orphaned_logos" => "Osierocone logo",
"update" => "Aktualizacja",
diff --git a/includes/i18n/pt.php b/includes/i18n/pt.php
index 06d8b8e..d7654bf 100644
--- a/includes/i18n/pt.php
+++ b/includes/i18n/pt.php
@@ -385,6 +385,9 @@ $i18n = [
"disable_password_login" => "Desactivar login por password",
"smtp_settings" => "Definições SMTP",
"smtp_usage_info" => "Será usado para recuperações de password e outros emails do sistema.",
+ "security_settings" => "Configurações de Segurança",
+ "ssrf_protection_info" => "Para evitar ataques Server-Side Request Forgery (SSRF), o Wallos bloqueia por padrão notificações webhook para endereços de rede privados ou internos.",
+ "local_webhook_info" => "Se precisar enviar webhooks para serviços locais (como Home Assistant, Gotify ou Node-RED), insira seus endereços IP ou nomes de host acima como uma lista separada por vírgulas (por exemplo <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Tarefas de Manutenção",
"orphaned_logos" => "Logos Órfãos",
"update" => "Actualizar",
diff --git a/includes/i18n/pt_br.php b/includes/i18n/pt_br.php
index 73fbfc9..dfc6ae8 100644
--- a/includes/i18n/pt_br.php
+++ b/includes/i18n/pt_br.php
@@ -385,6 +385,9 @@ $i18n = [
"disable_password_login" => "Desativar login por senha",
"smtp_settings" => "Configurações SMTP",
"smtp_usage_info" => "Será usado para recuperação de senha e outros e-mails do sistema.",
+ "security_settings" => "Configurações de Segurança",
+ "ssrf_protection_info" => "Para evitar ataques Server-Side Request Forgery (SSRF), o Wallos bloqueia por padrão notificações webhook para endereços de rede privados ou internos.",
+ "local_webhook_info" => "Se precisar enviar webhooks para serviços locais (como Home Assistant, Gotify ou Node-RED), insira seus endereços IP ou nomes de host acima como uma lista separada por vírgulas (por exemplo <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Tarefas de manutenção",
"orphaned_logos" => "Logos órfãos",
"update" => "Atualizar",
diff --git a/includes/i18n/ru.php b/includes/i18n/ru.php
index d158fd1..6130741 100644
--- a/includes/i18n/ru.php
+++ b/includes/i18n/ru.php
@@ -384,6 +384,9 @@ $i18n = [
"create_user_automatically" => "Автоматически создавать пользователей",
"disable_password_login" => "Отключить вход по паролю",
"smtp_settings" => "Настройки SMTP",
+ "security_settings" => "Параметры безопасности",
+ "ssrf_protection_info" => "Чтобы предотвратить атаки Server-Side Request Forgery (SSRF), Wallos по умолчанию блокирует уведомления webhook на приватные или внутренние сетевые адреса.",
+ "local_webhook_info" => "Если вам нужно отправлять вебхуки на локальные сервисы (например, Home Assistant, Gotify или Node-RED), введите их IP-адреса или имена хостов выше через запятую (например <code>192.168.1.100,192.168.1.101</code>).",
"smtp_usage_info" => "Будет использоваться для восстановления пароля и других системных писем.",
"maintenance_tasks" => "Задачи обслуживания",
"orphaned_logos" => "Потерянные логотипы",
diff --git a/includes/i18n/sl.php b/includes/i18n/sl.php
index 32ad4c8..2a5be0b 100644
--- a/includes/i18n/sl.php
+++ b/includes/i18n/sl.php
@@ -378,6 +378,9 @@ $i18n = [
"disable_password_login" => "Onemogoči prijavo z geslom",
"smtp_settings" => "Nastavitve SMTP",
"smtp_usage_info" => "Uporabljeno bo za obnovitev gesla in druge sistemske e-pošte.",
+ "security_settings" => "Varnostne nastavitve",
+ "ssrf_protection_info" => "Za preprečevanje napadov Server-Side Request Forgery (SSRF) Wallos privzeto blokira webhook obvestila na zasebne ali notranje omrežne naslove.",
+ "local_webhook_info" => "Če morate pošiljati webhooke na lokalne storitve (npr. Home Assistant, Gotify ali Node-RED), vnesite njihove IP naslove ali imena gostiteljev zgoraj kot seznam, ločen z vejico (npr. <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Vzdrževalne naloge",
"orphaned_logos" => "Osamljeni logotipi",
"update" => "Posodobi",
diff --git a/includes/i18n/sr.php b/includes/i18n/sr.php
index 315edf6..5c0dd95 100644
--- a/includes/i18n/sr.php
+++ b/includes/i18n/sr.php
@@ -385,6 +385,9 @@ $i18n = [
"disable_password_login" => "Онемогући пријаву лозинком",
"smtp_settings" => "SMTP подешавања",
"smtp_usage_info" => "SMTP се користи за слање е-поште за обавештења.",
+ "security_settings" => "Поставке безбедности",
+ "ssrf_protection_info" => "Како би се спречили напади Server-Side Request Forgery (SSRF), Wallos подразумевано блокира webhook обавештења ка приватним или унутрашњим мрежним адресама.",
+ "local_webhook_info" => "Ако треба да шаљете вебхуке ка локалним сервисима (нпр. Home Assistant, Gotify или Node-RED), унесите њихове IP адресе или имена хостова горе, одвојене зарезима (нпр. <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Одржавање",
"orphaned_logos" => "Породични логотипови",
"update" => "Ажурирај",
diff --git a/includes/i18n/sr_lat.php b/includes/i18n/sr_lat.php
index 9949f1f..6640172 100644
--- a/includes/i18n/sr_lat.php
+++ b/includes/i18n/sr_lat.php
@@ -385,6 +385,9 @@ $i18n = [
"disable_password_login" => "Onemoguči prijavu z geslom",
"smtp_settings" => "SMTP podešavanja",
"smtp_usage_info" => "Koristiće se za oporavak lozinke i druge sistemske e-poruke.",
+ "security_settings" => "Podešavanja bezbednosti",
+ "ssrf_protection_info" => "Kako bi se sprečile Server-Side Request Forgery (SSRF) napadi, Wallos podrazumevano blokira webhook obaveštenja ka privatnim ili internim mrežnim adresama.",
+ "local_webhook_info" => "Ako treba da šaljete webhooks ka lokalnim servisima (npr. Home Assistant, Gotify ili Node-RED), unesite njihove IP adrese ili imena hostova gore, odvojene zarezima (npr. <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Održavanje",
"orphaned_logos" => "Nepovezani logotipi",
"update" => "Ažuriraj",
diff --git a/includes/i18n/tr.php b/includes/i18n/tr.php
index d1ee8f3..f63de9b 100644
--- a/includes/i18n/tr.php
+++ b/includes/i18n/tr.php
@@ -385,6 +385,9 @@ $i18n = [
"disable_password_login" => "Parola ile giriş devre dışı bırakılsın",
"smtp_settings" => "SMTP Ayarları",
"smtp_usage_info" => "Şifre kurtarma ve diğer sistem e-postaları için kullanılacaktır.",
+ "security_settings" => "Güvenlik Ayarları",
+ "ssrf_protection_info" => "Sunucu tarafı istek sahteciliği (SSRF) saldırılarını önlemek için Wallos, varsayılan olarak webhook bildirimlerini özel veya dahili ağ adreslerine engeller.",
+ "local_webhook_info" => "Webhooks'u yerel hizmetlere (ör. Home Assistant, Gotify veya Node-RED) göndermeniz gerekiyorsa, IP adreslerini veya ana bilgisayar adlarını yukarıya virgülle ayrılmış bir liste olarak girin (ör. <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Bakım Görevleri",
"orphaned_logos" => "Yetim Logolar",
"update" => "Güncelle",
diff --git a/includes/i18n/uk.php b/includes/i18n/uk.php
index 3a19158..077ac7e 100644
--- a/includes/i18n/uk.php
+++ b/includes/i18n/uk.php
@@ -385,6 +385,9 @@ $i18n = [
"create_user_automatically" => "Автоматично створювати користувача при вході",
"disable_password_login" => "Відключити вхід за паролем",
"smtp_usage_info" => "Буде використовуватися для відновлення пароля та інших системних листів.",
+ "security_settings" => "Налаштування безпеки",
+ "ssrf_protection_info" => "Щоб запобігти атакам Server-Side Request Forgery (SSRF), Wallos за замовчуванням блокує вебхуки до приватних або внутрішніх мережевих адрес.",
+ "local_webhook_info" => "Якщо вам потрібно надсилати вебхуки до локальних сервісів (наприклад, Home Assistant, Gotify або Node-RED), введіть їх IP-адреси або імена хостів вище як список, розділений комами (наприклад <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Завдання обслуговування",
"orphaned_logos" => "Втрачений логотип",
"update" => "Оновити",
diff --git a/includes/i18n/vi.php b/includes/i18n/vi.php
index bd5ca1a..9e4b323 100644
--- a/includes/i18n/vi.php
+++ b/includes/i18n/vi.php
@@ -386,6 +386,9 @@ $i18n = [
"disable_password_login" => "Vô hiệu hóa đăng nhập bằng mật khẩu",
"smtp_settings" => "Cài đặt SMTP",
"smtp_usage_info" => "Sẽ được sử dụng cho việc khôi phục mật khẩu và các email hệ thống khác.",
+ "security_settings" => "Cài đặt bảo mật",
+ "ssrf_protection_info" => "Để ngăn chặn các cuộc tấn công Server-Side Request Forgery (SSRF), Wallos mặc định chặn các thông báo webhook đến các địa chỉ mạng riêng hoặc nội bộ.",
+ "local_webhook_info" => "Nếu bạn cần gửi webhooks đến các dịch vụ cục bộ (như Home Assistant, Gotify hoặc Node-RED), hãy nhập địa chỉ IP hoặc tên máy chủ của chúng ở trên dưới dạng danh sách cách nhau bởi dấu phẩy (ví dụ: <code>192.168.1.100,192.168.1.101</code>).",
"maintenance_tasks" => "Nhiệm vụ bảo trì",
"orphaned_logos" => "Logo bị bỏ rơi",
"update" => "Cập nhật",
diff --git a/includes/i18n/zh_cn.php b/includes/i18n/zh_cn.php
index 4b8361b..d6cb81f 100644
--- a/includes/i18n/zh_cn.php
+++ b/includes/i18n/zh_cn.php
@@ -404,6 +404,9 @@ $i18n = [
"disable_password_login" => "禁用密码登录",
"smtp_settings" => "SMTP 设置",
"smtp_usage_info" => "将用于密码恢复和其他系统电子邮件。",
+ "security_settings" => "安全设置",
+ "ssrf_protection_info" => "为防止服务端请求伪造(SSRF)攻击,Wallos 默认阻止发送到私有或内部网络地址的 webhook 通知。",
+ "local_webhook_info" => "如果需要将 webhook 发送到本地服务(例如 Home Assistant、Gotify 或 Node-RED),请在上方以逗号分隔的列表中输入它们的 IP 地址或主机名(例如 <code>192.168.1.100,192.168.1.101</code>)。",
"maintenance_tasks" => "维护任务",
"orphaned_logos" => "孤立的 Logo",
"update" => "更新",
diff --git a/includes/i18n/zh_tw.php b/includes/i18n/zh_tw.php
index 4b30543..b15e9e3 100644
--- a/includes/i18n/zh_tw.php
+++ b/includes/i18n/zh_tw.php
@@ -386,6 +386,9 @@ $i18n = [
"disable_password_login" => "停用密碼登入",
"smtp_settings" => "SMTP 設定",
"smtp_usage_info" => "用於密碼重設和其他系統郵件。",
+ "security_settings" => "安全設定",
+ "ssrf_protection_info" => "為了防止服務端請求偽造(SSRF)攻擊,Wallos 預設會阻止發送到私人或內部網路位址的 webhook 通知。",
+ "local_webhook_info" => "如果您需要將 webhook 發送到本地服務(例如 Home Assistant、Gotify 或 Node-RED),請在上方以逗號分隔的列表中輸入它們的 IP 位址或主機名稱(例如 <code>192.168.1.100,192.168.1.101</code>)。",
"maintenance_tasks" => "維護工作",
"orphaned_logos" => "未使用的圖示",
"update" => "更新",
diff --git a/includes/ssrf_helper.php b/includes/ssrf_helper.php
new file mode 100644
index 0000000..5d66520
--- /dev/null
+++ b/includes/ssrf_helper.php
@@ -0,0 +1,68 @@
+<?php
+
+/**
+ * Validates a webhook URL against SSRF attacks and checks the admin allowlist.
+ * If validation fails, it kills the script and outputs a JSON error response.
+ * * @param string $url The destination URL to check
+ * @param SQLite3 $db The database connection
+ * @param array $i18n The translation array
+ * @return array Returns an array with ['host', 'ip', 'port'] for cURL hardening
+ */
+function validate_webhook_url_for_ssrf($url, $db, $i18n) {
+ $parsedUrl = parse_url($url);
+
+ // Fallback if parse_url fails completely
+ if (!$parsedUrl || !isset($parsedUrl['host'])) {
+ die(json_encode([
+ "success" => false,
+ "message" => translate("error", $i18n)
+ ]));
+ }
+
+ $urlHost = $parsedUrl['host'];
+ $port = $parsedUrl['port'] ?? '';
+ $ip = gethostbyname($urlHost);
+
+ // CATCH DNS FAILURES
+ if ($ip === $urlHost && filter_var($urlHost, FILTER_VALIDATE_IP) === false) {
+ die(json_encode([
+ "success" => false,
+ "message" => "Error: Could not resolve the hostname. Please check the URL or your server's DNS."
+ ]));
+ }
+
+ $hostWithPort = $port ? $urlHost . ':' . $port : $urlHost;
+ $ipWithPort = $port ? $ip . ':' . $port : $ip;
+
+ // Check if it's a private IP
+ $is_private = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) === false;
+
+ if ($is_private) {
+ $stmt = $db->prepare("SELECT local_webhook_notifications_allowlist FROM admin LIMIT 1");
+ $result = $stmt->execute();
+ $row = $result->fetchArray(SQLITE3_ASSOC);
+
+ $allowlist_str = $row ? $row['local_webhook_notifications_allowlist'] : '';
+ $allowlist = array_filter(array_map('trim', explode(',', $allowlist_str)));
+
+ if (!in_array($urlHost, $allowlist) &&
+ !in_array($ip, $allowlist) &&
+ !in_array($hostWithPort, $allowlist) &&
+ !in_array($ipWithPort, $allowlist)) {
+
+ die(json_encode([
+ "success" => false,
+ "message" => "Security Block: The target IP/Port is private and not present in the Webhook Allowlist."
+ ]));
+ }
+ }
+
+ // Determine the exact port being targeted for cURL DNS rebinding protection
+ $targetPort = $port ?: (strtolower($parsedUrl['scheme'] ?? 'http') === 'https' ? 443 : 80);
+
+ return [
+ 'host' => $urlHost,
+ 'ip' => $ip,
+ 'port' => $targetPort
+ ];
+}
\ No newline at end of file
diff --git a/includes/version.php b/includes/version.php
index 8365178..8ec1516 100644
--- a/includes/version.php
+++ b/includes/version.php
@@ -1,3 +1,3 @@
<?php
-$version = "v4.6.1";
+$version = "v4.6.2";
?>
\ No newline at end of file
diff --git a/migrations/000043.php b/migrations/000043.php
new file mode 100644
index 0000000..2c4a520
--- /dev/null
+++ b/migrations/000043.php
@@ -0,0 +1,24 @@
+<?php
+
+/* * This migration adds a column to the admin table to store a comma-separated
+* allowlist of hostnames and IPs that can be used in webhook notifications.
+* This prevents SSRF attacks on internal services.
+*/
+
+// Check if the column already exists to prevent errors on multiple runs
+$query = $db->query("PRAGMA table_info(admin)");
+$columnExists = false;
+
+while ($row = $query->fetchArray(SQLITE3_ASSOC)) {
+ if ($row['name'] === 'local_webhook_notifications_allowlist') {
+ $columnExists = true;
+ break;
+ }
+}
+
+if (!$columnExists) {
+ // Add the column with an empty string as the default
+ $db->exec("ALTER TABLE admin ADD COLUMN local_webhook_notifications_allowlist TEXT DEFAULT ''");
+}
+
+?>
\ No newline at end of file
diff --git a/migrations/000044.php b/migrations/000044.php
new file mode 100644
index 0000000..5bc8141
--- /dev/null
+++ b/migrations/000044.php
@@ -0,0 +1,66 @@
+<?php
+
+/* * This migration creates the uploaded_avatars table to isolate custom avatars
+ * by user_id, preventing IDOR deletion vulnerabilities. It also migrates existing
+ * avatars based on whether the instance is single-tenant or multi-tenant.
+ */
+
+// Check if the table already exists to prevent duplicate migration runs
+$tableCheck = $db->querySingle("SELECT name FROM sqlite_master WHERE type='table' AND name='uploaded_avatars'");
+
+if (!$tableCheck) {
+ // Create the uploaded_avatars table
+ $db->exec("
+ CREATE TABLE IF NOT EXISTS uploaded_avatars (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ user_id INTEGER NOT NULL,
+ path TEXT NOT NULL
+ )
+ ");
+
+ // Check if solo user or multiple users
+ $userCount = $db->querySingle("SELECT COUNT(*) FROM user");
+
+ if ($userCount === 1) {
+ // SOLO USER MIGRATION
+ $userId = $db->querySingle("SELECT id FROM user LIMIT 1");
+
+ $avatarDir = '../../images/uploads/logos/avatars';
+
+ if (is_dir($avatarDir)) {
+ $files = scandir($avatarDir);
+
+ $stmt = $db->prepare("INSERT INTO uploaded_avatars (user_id, path) VALUES (:user_id, :path)");
+
+ foreach ($files as $file) {
+ // Skip directories and hidden files (like .gitkeep or .htaccess)
+ if ($file !== '.' && $file !== '..' && is_file($avatarDir . '/' . $file)) {
+ // Store the path exactly as the app expects it in the database
+ $relativePath = 'images/uploads/logos/avatars/' . $file;
+
+ $stmt->bindValue(':user_id', $userId, SQLITE3_INTEGER);
+ $stmt->bindValue(':path', $relativePath, SQLITE3_TEXT);
+ $stmt->execute();
+ }
+ }
+ }
+ } elseif ($userCount > 1) {
+ // MULTI-USER MIGRATION
+ $results = $db->query("SELECT id, avatar FROM user");
+
+ $stmt = $db->prepare("INSERT INTO uploaded_avatars (user_id, path) VALUES (:user_id, :path)");
+
+ while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
+ $userId = $row['id'];
+ $avatarPath = $row['avatar'];
+
+ if (strpos($avatarPath, 'images/uploads/logos/avatars/') === 0) {
+ $stmt->bindValue(':user_id', $userId, SQLITE3_INTEGER);
+ $stmt->bindValue(':path', $avatarPath, SQLITE3_TEXT);
+ $stmt->execute();
+ }
+ }
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/passwordreset.php b/passwordreset.php
index 5a12239..5f59f61 100644
--- a/passwordreset.php
+++ b/passwordreset.php
@@ -32,6 +32,7 @@ if (isset($_COOKIE['colorTheme'])) {
$settings = $db->querySingle("SELECT * FROM admin", true);
if ($settings['smtp_address'] == "" || $settings['server_url'] == "") {
header("Location: .");
+ exit();
} else {
$resetPasswordEnabled = true;
}
@@ -187,8 +188,8 @@ if (isset($_POST['password']) && $_POST['password'] != "" && isset($_POST['confi
if (!$hideForm) {
?>
<div class="form-group">
- <input type="hidden" name="token" value="<?= $token ?>">
- <input type="hidden" name="email" value="<?= $email ?>">
+ <input type="hidden" name="token" value="<?= htmlspecialchars($token ?? '', ENT_QUOTES, 'UTF-8') ?>">
+ <input type="hidden" name="email" value="<?= htmlspecialchars($email ?? '', ENT_QUOTES, 'UTF-8') ?>">
<label for="password"><?= translate('password', $i18n) ?>:</label>
<input type="password" id="password" name="password" autocomplete="new-password" required>
</div>
diff --git a/profile.php b/profile.php
index 7564b08..1627e04 100644
--- a/profile.php
+++ b/profile.php
@@ -1,5 +1,16 @@
<?php
require_once 'includes/header.php';
+
+// Fetch the avatars belonging to the logged-in user
+$uploadedAvatars = [];
+
+$stmt = $db->prepare("SELECT path FROM uploaded_avatars WHERE user_id = :user_id");
+$stmt->bindValue(':user_id', $userId, SQLITE3_INTEGER);
+$result = $stmt->execute();
+
+while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
+ $uploadedAvatars[] = $row['path'];
+}
?>
<script src="scripts/libs/sortable.min.js"></script>
@@ -29,29 +40,34 @@ require_once 'includes/header.php';
<input type="hidden" name="avatar" value="<?= htmlspecialchars($userData['avatar'], ENT_QUOTES, 'UTF-8') ?>" id="avatarUser" />
<div class="avatar-select" id="avatarSelect">
<div class="avatar-list">
- <?php foreach (scandir('images/avatars') as $index => $image): ?>
+ <?php foreach (scandir('images/avatars') as $image): ?>
<?php if (!str_starts_with($image, '.')): ?>
<img src="images/avatars/<?= $image ?>" alt="<?= $image ?>" class="avatar-option"
data-src="images/avatars/<?= $image ?>">
<?php endif ?>
<?php endforeach ?>
- <?php foreach (scandir('images/uploads/logos/avatars') as $index => $image): ?>
- <?php if (!str_starts_with($image, '.')): ?>
- <div class="avatar-container" data-src="<?= $image ?>">
- <img src="images/uploads/logos/avatars/<?= $image ?>" alt="<?= $image ?>"
- class="avatar-option" data-src="images/uploads/logos/avatars/<?= $image ?>">
- <div class="remove-avatar" onclick="deleteAvatar('<?= $image ?>')"
- title="Delete avatar">
- <i class="fa-solid fa-xmark"></i>
- </div>
+
+ <?php foreach ($uploadedAvatars as $path): ?>
+ <?php
+ $filename = basename($path);
+ ?>
+ <div class="avatar-container" data-src="<?= $filename ?>">
+ <img src="<?= $path ?>" alt="<?= $filename ?>"
+ class="avatar-option" data-src="<?= $path ?>">
+
+ <div class="remove-avatar" onclick="deleteAvatar('<?= $filename ?>')"
+ title="Delete avatar">
+ <i class="fa-solid fa-xmark"></i>
</div>
- <?php endif ?>
+ </div>
<?php endforeach ?>
+
<label for="profile_pic" class="add-avatar"
title="<?= translate('upload_avatar', $i18n) ?>">
<i class="fa-solid fa-arrow-up-from-bracket"></i>
</label>
</div>
+
<input type="file" id="profile_pic" class="hidden-input" name="profile_pic"
accept="image/jpeg, image/png, image/gif, image/webp"
onChange="successfulUpload(this, '<?= addslashes(translate('file_type_error', $i18n)) ?>')" />
diff --git a/scripts/admin.js b/scripts/admin.js
index a19b293..46e49ec 100644
--- a/scripts/admin.js
+++ b/scripts/admin.js
@@ -229,6 +229,40 @@ function saveAccountRegistrationsButton() {
});
}
+function saveSecuritySettingsButton() {
+ const button = document.getElementById('saveSecuritySettingsButton');
+ button.disabled = true;
+
+ const allowlist = document.getElementById('local_webhook_notifications_allowlist').value;
+
+ const data = {
+ local_webhook_notifications_allowlist: allowlist
+ };
+
+ fetch('endpoints/admin/savesecuritysettings.php', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-CSRF-Token': window.csrfToken,
+ },
+ body: JSON.stringify(data)
+ })
+ .then(response => response.json())
+ .then(data => {
+ if (data.success) {
+ showSuccessMessage(data.message);
+ button.disabled = false;
+ } else {
+ showErrorMessage(data.message);
+ button.disabled = false;
+ }
+ })
+ .catch(error => {
+ showErrorMessage(error);
+ button.disabled = false;
+ });
+}
+
function removeUser(userId) {
const data = {
userId: userId
diff --git a/scripts/profile.js b/scripts/profile.js
index d4c06ab..e9a90d3 100644
--- a/scripts/profile.js
+++ b/scripts/profile.js
@@ -21,6 +21,7 @@ document.addEventListener('DOMContentLoaded', function () {
document.getElementById("avatar").src = document.getElementById("avatarImg").src;
const newUsername = document.getElementById("username").value;
document.getElementById("user").textContent = newUsername;
+ document.getElementById("profile_pic").value = "";
showSuccessMessage(data.message);
if (data.reload) {