-
-
Notifications
You must be signed in to change notification settings - Fork 258
Description
Usually, SQL SECURITY DEFINER is used to raise the current set of privileges for some particular task. However, if security definer is non-privileged, I'd expect the current set of privileges to be reduced accordingly to the owner. This is not really so though, see below.
- Usage of MON$ tables
When effective user is privileged, data from all attachments are seen, as expected. However, when effective user is not privileged and thus it should see only its own attachments, in fact it sees only attachments established by the session user. In other words, user A calls procedure with definer B which (ooops) sees attachments by user A. This looks unexpected and may also be considered as a security risk.
- System privileges
We check them as "session-user-allowed OR definer-user-allowed" (see Attachment::locksmith()). So if privileged user A calls procedure with non-privileged definer B, it still can perform every DBA action inside that procedure, like if it was executed under A's permissions. I'm not sure whether it's intended, but it looks inconsistent with other (SQL level) permissions that are checked for effective user B only (accordingly to the SQL spec, AFAIK). As for me, this looks like a bug.
Both cases are unlikely to be seen in real world databases, but IMO they deserve attention anyway.