From 37d69d6ab566255986c39d851a397dc35c586585 Mon Sep 17 00:00:00 2001 From: Ahmad Afandi Date: Mon, 31 Aug 2026 13:22:33 +0700 Subject: [PATCH] perbaikan ecryptString --- app/Http/Controllers/LogViewerController.php | 8 +- .../vendor/laravel-log-viewer/log.blade.php | 10 +-- tests/Feature/LogViewerControllerTest.php | 74 +++++++++++++++++++ 3 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 tests/Feature/LogViewerControllerTest.php diff --git a/app/Http/Controllers/LogViewerController.php b/app/Http/Controllers/LogViewerController.php index 0f5e780804..b8ee2ffe90 100644 --- a/app/Http/Controllers/LogViewerController.php +++ b/app/Http/Controllers/LogViewerController.php @@ -81,11 +81,11 @@ public function index() { $folderFiles = []; if ($this->request->input('f')) { - $this->log_viewer->setFolder(Crypt::decrypt($this->request->input('f'))); + $this->log_viewer->setFolder(Crypt::decryptString($this->request->input('f'))); $folderFiles = $this->log_viewer->getFolderFiles(true); } if ($this->request->input('l')) { - $this->log_viewer->setFile(Crypt::decrypt($this->request->input('l'))); + $this->log_viewer->setFile(Crypt::decryptString($this->request->input('l'))); } if ($early_return = $this->earlyReturn()) { @@ -143,7 +143,7 @@ public function index() private function earlyReturn() { if ($this->request->input('f')) { - $this->log_viewer->setFolder(Crypt::decrypt($this->request->input('f'))); + $this->log_viewer->setFolder(Crypt::decryptString($this->request->input('f'))); } if ($this->request->input('dl')) { @@ -178,7 +178,7 @@ private function earlyReturn() */ private function pathFromInput($input_string) { - return $this->log_viewer->pathToLogFile(Crypt::decrypt($this->request->input($input_string))); + return $this->log_viewer->pathToLogFile(Crypt::decryptString($this->request->input($input_string))); } /** diff --git a/resources/views/vendor/laravel-log-viewer/log.blade.php b/resources/views/vendor/laravel-log-viewer/log.blade.php index 22a1b5801f..f53e807aa5 100644 --- a/resources/views/vendor/laravel-log-viewer/log.blade.php +++ b/resources/views/vendor/laravel-log-viewer/log.blade.php @@ -30,7 +30,7 @@
@@ -43,22 +43,22 @@
@if ($current_file) Unduh Bersihkan File Hapus File @if (count($files) > 1) - + Hapus Semua file @endif diff --git a/tests/Feature/LogViewerControllerTest.php b/tests/Feature/LogViewerControllerTest.php new file mode 100644 index 0000000000..542ab9c84a --- /dev/null +++ b/tests/Feature/LogViewerControllerTest.php @@ -0,0 +1,74 @@ +withoutMiddleware([ + Authenticate::class, + RoleMiddleware::class, + PermissionMiddleware::class, + CompleteProfile::class, + GlobalShareMiddleware::class, + ]); +}); + +test('user-supplied log params are decrypted without unserialization', function () { + // Payload dibuat seolah-olah oleh penyerang yang memiliki APP_KEY: + // menyerupai Crypt::decrypt() lama (unserialize=true) terhadap input user. + // decryptString() mengembalikan string mentah tanpa unserialize, sehingga + // object tidak pernah diinstansiasi (tidak ada side effect __wakeup()). + $malicious = Crypt::encryptString(serialize(new ObjectInjectionGadget)); + + $this->get(route('setting.info-sistem').'?f='.urlencode($malicious)); + + expect(ObjectInjectionGadget::$wokenUp)->toBeFalse(); +});