Rank Creation function not validating user inputs.
The rank creation function in the WordPoints plugin does not sanitise or validate the name, type, and group parameters before inserting them into the database, which may allow SQL injection. The report also claims that a specially crafted ID passed to the get_data() function could lead to database exposure.
Originally disclosed on HackerOne
- Disclosed after 47 days
SQL Injection Attack, command injection and arbitrary code execution Possible.
By source code review, I found that rank creation parameters (name, type, group) for wordpoints_add_rank() in ranks.php are not sanitized or validated. It may allow an attacker to Inject arbitrary code during rank creation which is then passed to SQL for database update leading to SQL Injection Attack.
$inserted = $wpdb->insert( $wpdb->wordpoints_ranks , array( 'name' => $name, 'type' => $type, 'rank_group' => $group, 'blog_id' => $wpdb->blogid, 'site_id' => $wpdb->siteid, ) );
$rank_id = (int) $wpdb->insert_id;
foreach ( $meta as $meta_key => $meta_value ) {
wordpoints_add_rank_meta( $rank_id, $meta_key, $meta_value );
}
Similarly for retrieving Rank by get_data() in class-wordpoints-rank.php using specially crafted ID may lead database exposure) public static function get_data( $id ) {
$rank_data = wp_cache_get( $id, 'wordpoints_ranks' );
if ( false !== $rank_data ) {
return $rank_data;
}
global $wpdb;
$rank_data = $wpdb->get_row(
$wpdb->prepare(
"
SELECT id, name, type, rank_group, blog_id, site_id
FROM {$wpdb->wordpoints_ranks}
WHERE id = %d
"
, $id
)
);
if ( null === $rank_data ) {
return false;
}
wp_cache_add( $rank_data->id, $rank_data, 'wordpoints_ranks' );
return $rank_data;
}
}
Note: Data from user or cache cannot be trusted and properly validate before passing to function or database:
Refer: http://php.net/manual/en/filter.filters.sanitize.php Command Injection : https://www.owasp.org/index.php/Command_Injection PHP SQL Injection: http://php.net/manual/en/security.database.sql-injection.php
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely missing input validation and use of unprepared SQL statements when inserting rank data, and insufficient validation of the ID parameter in get_data().
Impact
An attacker could potentially execute SQL injection attacks, and the report also suggests command injection and arbitrary code execution are possible, though no proof is provided.
What the attacker needed
Access to rank creation function; ability to supply crafted input
The fix
The rank creation parameters should be properly sanitised and validated before being passed to the database, and the get_data() function should ensure the ID is properly validated.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This report is about a WordPress plugin that lets you create 'ranks'. The code that saves a new rank does not check what you type into the name, type, and group fields. If an attacker can reach that function, they might be able to insert database commands instead of normal text, which is called SQL injection.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.