Ticket #10751 (closed defect (bug): fixed)

Opened 2 years ago

Last modified 2 years ago

kses filter fields when displaying

Reported by: ryan Owned by: ryan
Priority: normal Milestone: 2.9
Component: Security Version:
Severity: normal Keywords: has-patch
Cc:

Description

Currently, some DB fields are trusted when being displayed. Usually this is fine since everything is run through kses upon save. However, some recent attacks have manipulated DB values to cover their tracks, making DB information untrustworthy. Where possible, we should run values through kses not just upon save, but upon display as well. This would thwart the recent example where the first_name field was modified to contain JS that hid a bogus admin user.

Attachments

10751.diff Download (9.0 KB) - added by ryan 2 years ago.
Add kses to display filters. Add sanitize_user_object() and sanitize_user_field(). First cut.
10751-2.patch Download (21.7 KB) - added by azaozz 2 years ago.

Change History

ryan2 years ago

Add kses to display filters. Add sanitize_user_object() and sanitize_user_field(). First cut.

  • Keywords has-patch added

azaozz2 years ago

Added wp_strip_all_tags() that removes all parts of the <script> and <style> tags and sanitize_text_field() that can check text input both on save and retrieve from the db (it can be used in filters instead of 'trim' and 'strip_tags').

comment:3   ryan2 years ago

Nice. Working well for me so far.

comment:4   ryan2 years ago

One thing with the full tag stripping on display is that you can't see that there is naughty stuff in the DB.

Yes, was wondering if we should strip the naughty stuff or return an empty string instead. The empty string could potentially break something but on the other hand if somebody is trying an exploit the filtered string won't be any good either. Another option would be to return some kind of warning, perhaps [content filtered] or something when we are in the admin.

comment:6   ryan2 years ago

(In [11929]) Filter fields through kses upon display. Introduce sanitize_user_object() and sanitize_user_field(). see #10751

comment:7   ryan2 years ago

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.