From ca991408c1572fc2919055995238e8c1e6ab5791 Mon Sep 17 00:00:00 2001 From: Ferywir <65760459+Ferywir@users.noreply.github.com> Date: Tue, 23 Jun 2026 09:31:08 +0200 Subject: [PATCH] fix(admin): verify CSRF token in village admin Mods [#139] (#259) editVillageOwner, renameVillage, editBuildings and editResources are POSTed to directly, bypassing admin.php's central csrf_verify(). Add csrf_verify() (after the admin access check, via the shared GameEngine/Admin/csrf.php) and csrf_field() in their forms (editVillage.tpl, village.tpl, editResources.tpl). Co-authored-by: Claude Opus 4.8 --- Admin/Templates/editResources.tpl | 1 + Admin/Templates/editVillage.tpl | 1 + Admin/Templates/village.tpl | 2 ++ GameEngine/Admin/Mods/editBuildings.php | 5 +++++ GameEngine/Admin/Mods/editResources.php | 5 +++++ GameEngine/Admin/Mods/editVillageOwner.php | 5 +++++ GameEngine/Admin/Mods/renameVillage.php | 5 +++++ 7 files changed, 24 insertions(+) diff --git a/Admin/Templates/editResources.tpl b/Admin/Templates/editResources.tpl index 177d4c79..eb3bbfaa 100644 --- a/Admin/Templates/editResources.tpl +++ b/Admin/Templates/editResources.tpl @@ -44,6 +44,7 @@ if($id){
+ diff --git a/Admin/Templates/editVillage.tpl b/Admin/Templates/editVillage.tpl index 11ef09fd..da7a2416 100644 --- a/Admin/Templates/editVillage.tpl +++ b/Admin/Templates/editVillage.tpl @@ -45,6 +45,7 @@ if(isset($id)) { include("search2.tpl"); ?>
+ diff --git a/Admin/Templates/village.tpl b/Admin/Templates/village.tpl index 3a587d8e..fb9984ce 100644 --- a/Admin/Templates/village.tpl +++ b/Admin/Templates/village.tpl @@ -119,6 +119,7 @@ if(isset($id)){ Owner + @@ -130,6 +131,7 @@ if(isset($id)){ Name + diff --git a/GameEngine/Admin/Mods/editBuildings.php b/GameEngine/Admin/Mods/editBuildings.php index 554fa06e..12c4e23d 100755 --- a/GameEngine/Admin/Mods/editBuildings.php +++ b/GameEngine/Admin/Mods/editBuildings.php @@ -18,6 +18,11 @@ if (empty($_SESSION['access']) || $_SESSION['access'] < 9) { die('

Access Denied: You are not Admin!

'); } +// Issue #139: this Mod is POSTed to directly, so it must verify the CSRF token +// itself (it does not go through admin.php's central csrf_verify()). +require_once(__DIR__ . '/../csrf.php'); +csrf_verify(); + include_once("../../config.php"); // --------------------------------------------------------------------------- diff --git a/GameEngine/Admin/Mods/editResources.php b/GameEngine/Admin/Mods/editResources.php index a59ae493..0efa76b4 100755 --- a/GameEngine/Admin/Mods/editResources.php +++ b/GameEngine/Admin/Mods/editResources.php @@ -17,6 +17,11 @@ if (empty($_SESSION['access']) || $_SESSION['access'] < 9) { die("Access Denied: You are not Admin!"); } +// Issue #139: this Mod is POSTed to directly, so it must verify the CSRF token +// itself (it does not go through admin.php's central csrf_verify()). +require_once(__DIR__ . '/../csrf.php'); +csrf_verify(); + include_once("../../config.php"); // --------------------------------------------------------------------------- diff --git a/GameEngine/Admin/Mods/editVillageOwner.php b/GameEngine/Admin/Mods/editVillageOwner.php index 8c99d0e7..cfb40b37 100755 --- a/GameEngine/Admin/Mods/editVillageOwner.php +++ b/GameEngine/Admin/Mods/editVillageOwner.php @@ -17,6 +17,11 @@ if (empty($_SESSION['access']) || $_SESSION['access'] < 9) { die("Access Denied: You are not Admin!"); } +// Issue #139: this Mod is POSTed to directly, so it must verify the CSRF token +// itself (it does not go through admin.php's central csrf_verify()). +require_once(__DIR__ . '/../csrf.php'); +csrf_verify(); + include_once("../../config.php"); // --------------------------------------------------------------------------- diff --git a/GameEngine/Admin/Mods/renameVillage.php b/GameEngine/Admin/Mods/renameVillage.php index 9332d109..e17a94c6 100755 --- a/GameEngine/Admin/Mods/renameVillage.php +++ b/GameEngine/Admin/Mods/renameVillage.php @@ -17,6 +17,11 @@ if (empty($_SESSION['access']) || $_SESSION['access'] < 9) { die("Access Denied: You are not Admin!"); } +// Issue #139: this Mod is POSTed to directly, so it must verify the CSRF token +// itself (it does not go through admin.php's central csrf_verify()). +require_once(__DIR__ . '/../csrf.php'); +csrf_verify(); + include_once("../../config.php"); // ---------------------------------------------------------------------------