question

sqlqa avatar image
sqlqa asked

how is it possible user able to execute inside sp who doesn't have execute permission?

I have two sps as see below SP 1 CODE: create PROCEDURE [dbo].[SP1] ( @p_empid int ) AS begin select emp_id,emp_sal from dbname.dbo.emptest where emp_id=@p_empid end SP 2 CODE: create proc dbo.[SP2] ( @p_empid int ) as begin exec [SP1] @p_empid end Explanation: Second SP SP2 using first SP SP1 execution But My doubt is User have SP2 execute permission but doesn't have SP1 execute permission When I see user execute SP1 he get error as Msg 229, Level 14, State 5, Procedure SP1, Line 1 EXECUTE permission denied on object 'SP1', database 'RM', schema 'dbo' But When user Execute SP2 He is able to execute SP2 without any error( i.e User doesnt have SP1 permission but user have only SP2 execute permission) How is it possible? Can any one explain to me? Note: User have doesnt have execute permission in SP1 but User have execute permission in SP2 SP2 contains SP1 but how wonder User have able to run and execute SP2 without any error.
stored-proceduresexecute-sql-task
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Grant Fritchey avatar image
Grant Fritchey answered
If the owner of SP2, which the user in question has permission to execute, has permission to execute SP1, then the user, by extension, gets that permission, but only through the execution of SP2. So, if you don't want the user to execute SP2, you have to explicitly revoke that privilege, or they'll be able to execute SP1 through SP2. Alternatively, you can make SP2 owned by some other user that doesn't have access to SP1. But then... execution of SP1 through SP2 is not going to work correctly.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.