Ticket #4720 (closed defect: fixed)

Opened 1 year ago

Last modified 10 months ago

Users without unfiltered_html capability can post arbitrary html

Reported by: xknown Assigned to: anonymous
Priority: high Milestone: 2.2.3
Component: Security Version: 2.2.2
Severity: major Keywords: has-patch
Cc:

Description

The user only needs to tamper data sent to post.php or page.php and add a field named no_filter with any value.

Attachments

admin-functions.php.diff (0.6 kB) - added by xknown on 08/13/07 02:04:59.
Unset $_POSTno_filter? in write_post and edit_post

Change History

08/13/07 02:04:59 changed by xknown

  • attachment admin-functions.php.diff added.

Unset $_POSTno_filter? in write_post and edit_post

08/13/07 02:19:24 changed by xknown

The attached file is a proposed fix for 2.2 branch, I hope this ticket gets more attention now.

(follow-up: ↓ 3 ) 08/13/07 05:17:00 changed by JeremyVisser

I can't reproduce on WP 2.2.2. Can you provide exact steps to reproduce this? Are you sure this happens on a fresh installation of WordPress? Perhaps a plugin is causing this?

Trunk is definitely not vulnerable, as grepping the source tree doesn't return anything for a search of 'no_filter'.

(in reply to: ↑ 2 ; follow-up: ↓ 6 ) 08/13/07 06:45:44 changed by westi

Replying to JeremyVisser:

I can't reproduce on WP 2.2.2. Can you provide exact steps to reproduce this? Are you sure this happens on a fresh installation of WordPress? Perhaps a plugin is causing this? Trunk is definitely not vulnerable, as grepping the source tree doesn't return anything for a search of 'no_filter'.

Trunk is vulnerable - search for $no_filter for more info.

08/14/07 15:30:40 changed by Nazgul

  • milestone set to 2.2.3.

08/14/07 17:09:07 changed by Nazgul

  • keywords set to has-patch.
  • priority changed from normal to high.
  • severity changed from normal to major.

(in reply to: ↑ 3 ) 08/14/07 19:21:01 changed by xknown

Replying to JeremyVisser:

I can't reproduce on WP 2.2.2. Can you provide exact steps to reproduce this? Are you sure this happens on a fresh installation of WordPress? Perhaps a plugin is causing this? Trunk is definitely not vulnerable, as grepping the source tree doesn't return anything for a search of 'no_filter'.

Try the following bookmarklet on wp-admin/post-new.php, it should work on WP 2.2.x

08/14/07 20:41:22 changed by Otto42

  • status changed from new to closed.
  • resolution set to invalid.
  • milestone deleted.

I just checked out a fresh copy of trunk from svn and the text "no_filter" does not appear anywhere in it whatsoever. grep -i -r no_filter * returned no results.

This has got to be a problem with a plugin or something. Even if no_filter is set and even if you have register_globals on to turn it into $no_filter, there's no check for $no_filter anywhere in the code.

Marked as invalid.

08/14/07 20:43:57 changed by Otto42

  • version deleted.

08/14/07 20:49:34 changed by westi

  • status changed from closed to reopened.
  • version set to 2.2.2.
  • resolution deleted.
  • milestone set to 2.2.3.

This is fixed on trunk.

But 2.2 has the no_filter code still it was removed for 2.3 in the changes for #4620 I think.

08/15/07 16:47:19 changed by Otto42

Okay, I see the $no_filter in wp-includes/post.php, however I still fail to see how this would be expected to work. Nothing sets $no_filter anywhere. You might be able to set it if you had register_globals on (which no sane host has), however wp_unregister_GLOBALS() should unset $no_filter even in that case, when wp-settings.php gets included.

I see no possible way that this can actually work, even with 2.2.2. What am I missing here?

08/15/07 16:49:55 changed by Otto42

Question to xknown (original submitter): Have you actually done this and made it work? Can you provide exact reproduction details? Or is this a purely theoretical thing you found while looking through the code?

Because I just tried it with a local install of 2.2.2 and was unable to reproduce it.

08/15/07 16:55:53 changed by Otto42

Edit: AH HA! Okay, it only works when you use POST parameters. It will not work with GET parameters. register_globals is not required.

The problem is this line in admin-functions.php: $post_ID = wp_insert_post( $_POST );

That's unsafe, you're passing $_POST directly to wp_insert_post, which then goes on to do an extract() on the variable, setting any local function variables you like.

The $_POST should be filtered for valid parameters in some fashion before passing it off to wp_insert_post().

08/16/07 17:37:11 changed by ryan

xknown's patch looks like it will suffice for 2.2. 2.3 has already removed no_filter.

09/03/07 16:28:20 changed by ryan

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [6018]) Unset no_filter. Props xknown. fixes #4720