Skip to content

Commit 7f5b410

Browse files
author
Daniel Neto
committed
fix: Add CSRF token validation in save.json.php and include token in AJAX request
https://github.com/WWBN/AVideo/security/advisories/GHSA-qpjj-c8vg-wqw7
1 parent db22311 commit 7f5b410

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

admin/index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,14 @@ public function addItem(MenuAdmin $menu)
347347
</div>
348348
</div>
349349
<script>
350+
var adminSaveToken = '<?php echo getToken(); ?>';
350351
$(document).ready(function() {
351352
$('.adminOptionsForm').submit(function(e) {
352353
e.preventDefault();
353354
modal.showPleaseWait();
354355
$.ajax({
355356
url: webSiteRootURL + 'admin/save.json.php',
356-
data: $(this).serialize(),
357+
data: $(this).serialize() + '&globalToken=' + encodeURIComponent(adminSaveToken),
357358
type: 'post',
358359
success: function(response) {
359360
modal.hidePleaseWait();

admin/save.json.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
if (!User::isAdmin()) {
99
die('{"error":"' . __("Permission denied") . '"}');
1010
}
11+
if (!isGlobalTokenValid()) {
12+
die('{"error":"' . __("Invalid or missing CSRF token") . '"}');
13+
}
1114

1215
$pluginName = $_POST['pluginName'];
1316

0 commit comments

Comments
 (0)