diff options
author | Erik Dubbelboer <erik@dubbelboer.com> | 2021-09-08 10:42:57 +0300 |
---|---|---|
committer | Erik Dubbelboer <erik@dubbelboer.com> | 2021-09-08 10:42:57 +0300 |
commit | b57e3b0e2f23dd59325fb0026944bba0acebecda (patch) | |
tree | 729b0e64dce0074138daee6220d2423c59daa107 | |
parent | f62fd146d2b14757796d132df6416fd76581880d (diff) |
Fix CSRF bugs
-rw-r--r-- | includes/header.inc.php | 4 | ||||
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | js/frame.js | 2 | ||||
-rw-r--r-- | js/index.js | 6 |
4 files changed, 9 insertions, 5 deletions
diff --git a/includes/header.inc.php b/includes/header.inc.php index aa618f1..9602370 100644 --- a/includes/header.inc.php +++ b/includes/header.inc.php @@ -35,5 +35,9 @@ header('Cache-Control: private'); <script src="js/<?php echo $js; ?>.js?v<?=$version?>"></script> <?php } ?> +<script> +phpRedisAdmin_csrfToken = '<?php echo $csrfToken; ?>'; +</script> + </head> <body> @@ -245,7 +245,7 @@ if ($databases > 1) { ?> </p> <button id="selected_all_keys">Select all</button> <button id="operations"> -<a href="delete.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&batch_del=1" class="batch_del">Delete selected<img src="images/delete.png" style="width: 1em;height: 1em;vertical-align: middle;" title="Delete selected" alt="[X]"></a> +<a href="delete.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&batch_del=1&csrf=<?php echo $csrfToken; ?>" class="batch_del">Delete selected<img src="images/delete.png" style="width: 1em;height: 1em;vertical-align: middle;" title="Delete selected" alt="[X]"></a> </button> </div> <div id="keys"> diff --git a/js/frame.js b/js/frame.js index b3b84b5..1a77e34 100644 --- a/js/frame.js +++ b/js/frame.js @@ -18,7 +18,7 @@ $(function() { $.ajax({ type: "POST", url: this.href, - data: 'post=1', + data: 'post=1&csrf=' + phpRedisAdmin_csrfToken, success: function(url) { top.location.href = top.location.pathname+url; } diff --git a/js/index.js b/js/index.js index 3557014..a3ba627 100644 --- a/js/index.js +++ b/js/index.js @@ -28,7 +28,7 @@ $(function() { $.ajax({ type: "POST", url: this.href, - data: 'post=1&selected_keys=' + selected_keys, + data: 'post=1&selected_keys=' + selected_keys + '&csrf=' + phpRedisAdmin_csrfToken, success: function(url) { top.location.href = top.location.pathname+url; } @@ -41,7 +41,7 @@ $(function() { $.ajax({ type: "POST", url: this.href, - data: 'post=1', + data: 'post=1&csrf=' + phpRedisAdmin_csrfToken, success: function(url) { top.location.href = top.location.pathname+url; } @@ -74,7 +74,7 @@ $(function() { $.ajax({ type: "POST", url: href, - data: 'post=1', + data: 'post=1&csrf=' + phpRedisAdmin_csrfToken, success: function() { window.location.reload(); } |