Vulnerability – Open Redirect
-
Hello. I had a security audit of my website and they found a couple slight vulnerability in your plugin.
Location: password-protected\password-protected.php
if ( isset( $_REQUEST['password-protected'] ) && $_REQUEST['password-protected'] == 'logout' ) { $this->logout(); if ( isset( $_REQUEST['redirect_to'] ) ) { $redirect_to = esc_url_raw( $_REQUEST['redirect_to'], array( 'http', 'https' )); } else { $redirect_to = home_url( '/' ); } wp_redirect( $redirect_to ); exit(); }
The redirect_to parameter can contain a malicious URL value and could cause the web application to redirect the request to the specified URL.
The logout parameter should only work for authenticated users and the redirect_to url should be sanitized and validated. Also, only relative paths should be accepted.
There is already a defined function for this in the class but it is not used in the logout method:
function safe_redirect( $location, $status = 302 ) { $location = wp_sanitize_redirect( $location ); $location = wp_validate_redirect( $location, home_url() ); wp_redirect( $location, $status ); }
They also found something in password-protected\admin\admin.php
function sanitize_ip_addresses( $val ) { $ip_addresses = explode( "\n", $val ); $ip_addresses = array_map( 'sanitize_text_field', $ip_addresses ); $ip_addresses = array_map( 'trim', $ip_addresses ); $ip_addresses = array_filter( $ip_addresses ); $val = implode( "\n", $ip_addresses ); return $val; }
The code does not validate the user input IP address correctly. This could be used to trick the application and change its flow.
Better validation needs to be implemented that will only accept IPv4 and IPv6 IP address patterns.
Are there any plans to make a patch for this in the near future? Otherwise I’d need to maintain this plugin on my own.
Thank you.
- The topic ‘Vulnerability – Open Redirect’ is closed to new replies.