fix exploit for viewing private dmails
This commit is contained in:
@@ -5,7 +5,9 @@ class DmailsController < ApplicationController
|
|||||||
|
|
||||||
def new
|
def new
|
||||||
if params[:respond_to_id]
|
if params[:respond_to_id]
|
||||||
@dmail = Dmail.find(params[:respond_to_id]).build_response(:forward => params[:forward])
|
parent = Dmail.find(params[:respond_to_id])
|
||||||
|
check_privilege(parent)
|
||||||
|
@dmail = parent.build_response(:forward => params[:forward])
|
||||||
else
|
else
|
||||||
@dmail = Dmail.new(params[:dmail])
|
@dmail = Dmail.new(params[:dmail])
|
||||||
end
|
end
|
||||||
@@ -58,6 +60,7 @@ class DmailsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def check_privilege(dmail)
|
def check_privilege(dmail)
|
||||||
if !dmail.visible_to?(CurrentUser.user, params[:key])
|
if !dmail.visible_to?(CurrentUser.user, params[:key])
|
||||||
raise User::PrivilegeError
|
raise User::PrivilegeError
|
||||||
|
|||||||
@@ -22,6 +22,12 @@ class DmailsControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "with a respond_to_id" do
|
context "with a respond_to_id" do
|
||||||
|
should "check privileges" do
|
||||||
|
@user2 = FactoryGirl.create(:user)
|
||||||
|
get :new, {:respond_to_id => @dmail}, {:user_id => @user2.id}
|
||||||
|
assert_response 403
|
||||||
|
end
|
||||||
|
|
||||||
should "prefill the fields" do
|
should "prefill the fields" do
|
||||||
get :new, {:respond_to_id => @dmail}, {:user_id => @user.id}
|
get :new, {:respond_to_id => @dmail}, {:user_id => @user.id}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|||||||
Reference in New Issue
Block a user