WordPress Privilege Escalation through Post Types
A logic flaw in WordPress's post submission allowed a low-privileged user to create posts of any custom post type by passing a post ID via a GET parameter, bypassing the nonce check tied to the post type. This let attackers use administrator-only features of plugins, leading to stored XSS and object injection in core and, with Contact Form 7, reading the wp-config.php file.
Published on sonarsource.com
A logic flaw in the way WordPress created blog posts allowed attackers to access features only administrators were supposed to have (CVE-2018-20152). This lead to a Stored XSS and Object Injection in the WordPress core and more severe vulnerabilities in WordPress’s most popular plugins Contact Form 7 and Jetpack.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
A contributor could create posts of any type, leading to stored XSS and object injection in core and, with Contact Form 7, reading database credentials; the text notes XMLRPC and REST API do not allow setting arbitrary post meta, limiting some plugin exploits.
What the attacker needed
A contributor-level account; a vulnerable plugin installed
The fix
WordPress patched the authorization check, and plugin developers should explicitly set capability and capability_type when registering post types.
How it was found
- Obtain a valid nonce for a normal post as a low-privileged user.
- Send a request with a post ID in the GET parameter and a chosen post_type in the POST data.
- WordPress pulls the post type from the database for the nonce check, which passes.
- Because the POST post_ID is not set, WordPress calls wp_insert_post() and uses the attacker-supplied post_type.
- Use the created post to access plugin features, such as setting a local file attachment in Contact Form 7.
- Submit the form to receive the wp-config.php contents by email.
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 write-up has not been written yet. The Original tab links to the source.
WordPress lets plugins add new kinds of content, called custom post types, and normally only administrators can use them. The bug was that a user with a low role could trick WordPress into thinking they were allowed to create any kind of post, so they could use features meant only for admins. That could let them run malicious scripts or, with a popular plugin, read the site's secret configuration file.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.