Issue Details (XML | Word | Printable)

Key: CORE-5823
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dmitriy Starodubov
Reporter: Sergey Borisov
Votes: 0
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
Firebird Core

No permission for SELECT access to blob field in stored procedure.

Created: 10/May/18 01:04 PM   Updated: 02/Aug/19 02:18 PM
Component/s: None
Affects Version/s: 3.0.4
Fix Version/s: 3.0.5

Environment: TEST
Issue Links:
Duplicate
 

QA Status: Done successfully


 Description  « Hide
CREATE ROLE TEST_ROLE;

CREATE TABLE TEST (
    ID INTEGER,
    BLB BLOB SUB_TYPE 1 SEGMENT SIZE 80
);
INSERT INTO TEST (ID, BLB) VALUES (1, 'blob1');
commit;

SET TERM ^ ;

create procedure TEST_PROC (ID integer)
returns (BLB TYPE OF COLUMN TEST.BLB)
as
begin
  FOR SELECT BLB
  from TEST
  WHERE ID = :ID
  into BLB
  DO suspend;
end^

SET TERM ; ^

GRANT SELECT ON TEST TO PROCEDURE TEST_PROC;
GRANT EXECUTE ON PROCEDURE TEST_PROC TO TEST_ROLE;
GRANT TEST_ROLE TO USERNAME;

connect 'server:base' user 'USERNAME' role 'TEST_ROLE';

/* Next query mistakenly generate error:
This user does not have privilege to perform this operation on object.
no permission for SELECT access to TABLE TEST.
*/
select * from TEST_PROC(1);



 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Vlad Khorsun added a comment - 10/May/18 01:15 PM
Blob access check was added in 3.0.4, iirc, see CORE-5801
Are you sure you see it at 3.0.3 ?

Sergey Borisov added a comment - 10/May/18 01:20 PM
You're right. 3.0.4.

Sergey Borisov added a comment - 10/May/18 01:28 PM
Where is the description of the CORE-5801? I can not find.

Vlad Khorsun added a comment - 10/May/18 01:42 PM
It is about unauthorized access to blobs. Details will be available when 3.0.4 gets released.

Nick added a comment - 10/May/18 03:58 PM
From one side it is a security. From other side it is not so useful to grant access to table.
I think we must to have parameter in config for disabling this security feature.

Adriano dos Santos Fernandes added a comment - 10/May/18 04:29 PM
Agree with Nick. For example, how it will be possible that a view or SP returns a subset (including blob) of a table that the user can't access directly?

Vlad Khorsun added a comment - 10/May/18 04:44 PM
So, blob access check should be more smart, just that.

First, if PSQL unit have own privileges to access blob (table) and want to return such blob to the client - should it be allowed or we need to introduce additional privilege ?
Second, if it is allowed, such blob id (s) should be marked somehow and bypass additional check of access.


Sergey Borisov added a comment - 11/May/18 04:19 AM
If I change the type of the returned parameter to varhar (10000) is s/p, then the error does not occur. Is this normal behavior?

Nick added a comment - 18/May/18 05:21 AM
There is another way for implementation:
if blob id was selected in active connection then it can be accessed from this connection at any time. But can't be accessed from another.

Vlad Khorsun added a comment - 19/May/18 09:59 AM
Sergey,

can't say if it is normal, but it is expected.

Pavel added a comment - 05/Feb/19 03:27 PM
This access check creates a lot of problems for me in my program. I need to give "publuc select" to the whole table if there is a blob. In my opinion, build 3.0.3 in this regard is more correct as I have to publish more data to the pact fact. (It turns out that the incident of aggravating the control in this way makes any control refuse at all). Version 3.0.5 on which the bug is closed, as I understand it, simply declares it as the correct behavior. Because I did not see any changes in 3.0.5. In my opinion, this behavior violates a fairly well-defined rights understanding scheme that coalesced in Firebird to 3.0.4.

Dmitry Yemanov added a comment - 05/Feb/19 04:06 PM
It wasn't "just closed", the fix was committed 21-Jan-2019.

Vlad Khorsun added a comment - 05/Feb/19 04:26 PM
PSQL unit's privileges still have no effect after the fix, seems we need to rethink it

Vlad Khorsun added a comment - 05/Feb/19 04:36 PM
Re-check it again and now i see that

GRANT EXECUTE ON PROCEDURE TO USERNAME;

is enough for USERNAME to execute procedure and access blob, even without a TEST_ROLE.
So, i see no problem currently.



Pavel,
why do you think you need to grant SELECT privs to PUBLIC ?

Pavel added a comment - 06/Feb/19 07:56 AM - edited
Yes, it really works on a test example. However, I definitely have a problem in my application. While I could not highlight the essence. I already see that in my case the error does not occur during the "select". The error occurs when the BLOB itself is read on isc_open_blob2.

I still keep looking for the reason for this behavior.

Vlad Khorsun added a comment - 06/Feb/19 08:10 AM
Pavel,

provide me with reproducible test case and i could help to find the reason

Pavel added a comment - 06/Feb/19 12:11 PM
Thanks for the response Vlad!

All the same, I found a problem. It was definitely my fault.

However, you may be wondering what happened:

I closed the query and even changed the transaction after select. Then I tried to call the blob (query closed, transaction changed). isc_open_blob2 retur error select privilegy for table ....