The Database Explorer implements multiple layers of security to protect against common web vulnerabilities and ensure safe database operations.
manage_options capability (administrator only)check_permissions() method in DatabaseExplorer classif (!current_user_can("manage_options")) {
return; // Don't add menu item
}
public static function check_permissions($request) {
if (!current_user_can("manage_options")) {
return new \WP_Error("rest_forbidden", ...);
}
// Nonce verification...
return true;
}
wp_authenticate() functionwp_restX-WP-Nonce (preferred)_wpnonce parameterwp_verify_nonce() functionlmnFetch utility function/^[a-zA-Z0-9_]+$/ (alphanumeric and underscores only)validate_table_name() methodSHOW TABLES LIKE %s-- comments/* */ commentsabsint(), must be > 0absint(), must be > 0 and <= 500sanitize_text_field()sanitize_text_field()$wpdb->esc_like() for LIKE queries$wpdb->prepare()esc_like()esc_sql() used after validationDESCRIBE query// Validate table name
$validated = self::validate_table_name($table_name);
if (!$validated) return error;
// Escape after validation
$escaped = esc_sql($table_name);
// Use in query
$query = "SELECT * FROM `{$escaped}`";
esc_html() before JSON encodingescapeHtml() utility functionv-html rendering$wpdb->prefix dynamicallyCore Tables (12):
Multisite Tables (6, if enabled):
private static function is_wordpress_table($table_name) {
$table_prefix = $wpdb->prefix;
$standard_tables = self::get_standard_wp_tables();
if (strpos($table_name, $table_prefix) !== 0) {
return false;
}
$base_table_name = substr($table_name, strlen($table_prefix));
if (in_array($base_table_name, $standard_tables)) {
return true;
}
// Multisite numbered tables...
return false;
}
[Database Explorer] User {username} ({id}) deleted table: {table_name}verify-password instead of passwordnew-password valueA comprehensive security audit was performed on the Database Explorer feature. See the Security Audit Report for detailed findings and fixes.
The Database Explorer security implementation follows: