mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 05:51:08 +08:00
SECURITY: Prevent arbitrary topic custom fields from being set
Why this change? The `PostsController#create` action allows arbitrary topic custom fields to be set by any user that can create a topic. Without any restrictions, this opens us up to potential security issues where plugins may be using topic custom fields in security sensitive areas. What does this change do? 1. This change introduces the `register_editable_topic_custom_field` plugin API which allows plugins to register topic custom fields that are editable either by staff users only or all users. The registered editable topic custom fields are stored in `DiscoursePluginRegistry` and is called by a new method `Topic#editable_custom_fields` which is then used in the `PostsController#create` controller action. When an unpermitted custom fields is present in the `meta_data` params, a 400 response code is returned. 2. Removes all reference to `meta_data` on a topic as it is confusing since we actually mean topic custom fields instead.
This commit is contained in:

committed by
Penar Musaraj

parent
0ed20fe1cd
commit
4cb7472376
@ -77,6 +77,9 @@ class DiscoursePluginRegistry
|
||||
define_filtered_register :staff_user_custom_fields
|
||||
define_filtered_register :public_user_custom_fields
|
||||
|
||||
define_filtered_register :staff_editable_topic_custom_fields
|
||||
define_filtered_register :public_editable_topic_custom_fields
|
||||
|
||||
define_filtered_register :self_editable_user_custom_fields
|
||||
define_filtered_register :staff_editable_user_custom_fields
|
||||
|
||||
|
Reference in New Issue
Block a user