Fix exploit allowing dmail filters to be set on other users.
Exploit:
curl \
-u $USERNAME:$API_KEY \
-X PUT "http://danbooru.donmai.us/maintenance/user/dmail_filter.json?dmail_id=1" \
-d "dmail_filter[words]=owned&dmail_filter[user_id]=2"
...where dmail_id is any dmail you own (doesn't matter which) and user_id is the victim.
This commit is contained in:
@@ -10,7 +10,7 @@ module Maintenance
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
@dmail_filter = CurrentUser.dmail_filter || DmailFilter.new
|
@dmail_filter = CurrentUser.dmail_filter || DmailFilter.new
|
||||||
@dmail_filter.update_attributes(params[:dmail_filter])
|
@dmail_filter.update(params.require(:dmail_filter).permit(:words), :as => CurrentUser.role)
|
||||||
flash[:notice] = "Filter updated"
|
flash[:notice] = "Filter updated"
|
||||||
redirect_to(dmail_path(@dmail.id))
|
redirect_to(dmail_path(@dmail.id))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class DmailFilter < ActiveRecord::Base
|
class DmailFilter < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
attr_accessible :user_id, :words, :as => [:moderator, :janitor, :gold, :member, :anonymous, :default, :builder, :admin]
|
attr_accessible :words, :as => [:moderator, :janitor, :gold, :member, :anonymous, :default, :builder, :admin]
|
||||||
validates_presence_of :user
|
validates_presence_of :user
|
||||||
before_validation :initialize_user
|
before_validation :initialize_user
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user