@@ -1882,6 +1882,42 @@ public function get_test_available_updates_disk_space() {
18821882 return $ result ;
18831883 }
18841884
1885+ /**
1886+ * Tests if registration is open to everyone and the default role is privileged.
1887+ *
1888+ * @since 7.0.0
1889+ *
1890+ * @return array The test results.
1891+ */
1892+ public function get_test_insecure_registration () {
1893+ $ users_can_register = get_option ( 'users_can_register ' );
1894+ $ default_role = get_option ( 'default_role ' );
1895+
1896+ $ result = array (
1897+ 'label ' => __ ( 'Open Registration with privileged default role ' ),
1898+ 'status ' => 'good ' ,
1899+ 'badge ' => array (
1900+ 'label ' => __ ( 'Security ' ),
1901+ 'color ' => 'blue ' ,
1902+ ),
1903+ 'description ' => '<p> ' . __ ( 'The combination of open registration setting and the default user role may lead to security issues. ' ) . '</p> ' ,
1904+ 'actions ' => '' ,
1905+ 'test ' => 'insecure_registration ' ,
1906+ );
1907+
1908+ if ( $ users_can_register && in_array ( $ default_role , array ( 'editor ' , 'administrator ' ), true ) ) {
1909+ $ result ['description ' ] = __ ( 'Registration is open to anyone, and the default role is set to a privileged role. ' );
1910+ $ result ['status ' ] = 'critical ' ;
1911+ $ result ['actions ' ] = sprintf (
1912+ '<p><a href="%s">%s</a></p> ' ,
1913+ esc_url ( admin_url ( 'options-general.php ' ) ),
1914+ __ ( 'Change these settings ' )
1915+ );
1916+ }
1917+
1918+ return $ result ;
1919+ }
1920+
18851921 /**
18861922 * Tests if plugin and theme temporary backup directories are writable or can be created.
18871923 *
@@ -2889,6 +2925,10 @@ public static function get_tests() {
28892925 'label ' => __ ( 'Autoloaded options ' ),
28902926 'test ' => 'autoloaded_options ' ,
28912927 ),
2928+ 'insecure_registration ' => array (
2929+ 'label ' => __ ( 'Open Registration with privileged default role ' ),
2930+ 'test ' => 'insecure_registration ' ,
2931+ ),
28922932 'search_engine_visibility ' => array (
28932933 'label ' => __ ( 'Search Engine Visibility ' ),
28942934 'test ' => 'search_engine_visibility ' ,
0 commit comments