Skip to content

SQL SECURITY DEFINER has inconsistent behaviour if the object owner is non-privileged #6935

@dyemanov

Description

@dyemanov

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.

  1. 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.

  1. 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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions