Skip to content

Commit

Permalink
fix: CSRF in Logs form (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalnagar committed Jan 17, 2023
1 parent ea6958f commit e66f0f0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions admin/AdminClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ public function form_settings_general() {

public function custom_404_pro_admin_init() {
global $wpdb;
if(current_user_can('administrator')) {
if( current_user_can( 'administrator' ) && wp_verify_nonce( $_REQUEST['form-logs-options'], 'form-logs-options' ) ) {
if ( array_key_exists( 'action', $_REQUEST ) ) {
$action = sanitize_text_field($_REQUEST['action']);
if ( $action === 'c4p-logs--delete' ) {
if ( array_key_exists( 'path', $_REQUEST ) ) {
$this->helpers->delete_logs( sanitize_url($_REQUEST['path']) );
$this->helpers->delete_logs( $_REQUEST['path'] );
$message = urlencode( 'Log(s) successfully deleted!' );
wp_redirect( admin_url( 'admin.php?page=c4p-main&c4pmessage=' . $message . '&c4pmessageType=success' ) );
} else {
Expand Down
1 change: 1 addition & 0 deletions admin/views/logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<form id="form_logs" method="GET">
<!-- For plugins, we also need to ensure that the form posts back to our current page -->
<input type="hidden" name="page" value="<?php echo sanitize_text_field($_REQUEST['page']); ?>" />
<?php wp_nonce_field("form-logs-options", "form-logs-options"); ?>
<!-- Now we can render the completed list table -->
<p class="search-box">
<label class="screen-reader-text" for="search_id-search-input">Search</label>
Expand Down
2 changes: 1 addition & 1 deletion custom-404-pro.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin Name: Custom 404 Pro
Plugin URI: https://wordpress.org/plugins/custom-404-pro/
Description: Override the default 404 page with any page or a custom URL from the Admin Panel.
Version: 3.7.1
Version: 3.7.2
Author: Kunal Nagar
Author URI: https://www.kunalnagar.in
License: GPL-2.0+
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/kunalnagar88/10
Tags: wordpress, 404, 404 error page, 404 link, 404 page, broken link, custom 404, custom 404 error, custom 404 error page, custom 404 page, customize 404, customize 404 error page, customize 404 page, error, error page, missing, page, page not found, page not found error
Requires at least: 3.0.1
Tested up to: 6.1
Stable tag: 3.7.1
Stable tag: 3.7.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -55,6 +55,9 @@ Uninstall the plugin from the Plugins page (important!) and reinstall it. Never

== Changelog ==

= 3.7.2 =
* Fix CSRF vulnerability in Logs table

= 3.7.1 =
* Fix path vulnerability

Expand Down

0 comments on commit e66f0f0

Please sign in to comment.