summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera2020-02-10 14:47:09 +0000
committerAlvaro Herrera2020-02-10 14:47:09 +0000
commitac1a998ed8c535a165e7f95179ee954df075f920 (patch)
treea31e4a6de221804787aef49fc6edf34492325f12
parent7f97b5e891d23db0e44f3292177c62fcb57bd766 (diff)
Fix priv checks for ALTER <object> DEPENDS ON EXTENSION
Marking an object as dependant on an extension did not have any privilege check whatsoever; this allowed any user to mark objects as droppable by anyone able to DROP EXTENSION, which could be used to cause system-wide havoc. Disallow by checking that the calling user owns the mentioned object. (No constraints are placed on the extension.) Security: CVE-2020-1720 Reported-by: Tom Lane Discussion: 31605.1566429043@sss.pgh.pa.us
-rw-r--r--src/backend/commands/alter.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 4f8147907c4..acb580df880 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -431,6 +431,17 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
&rel, AccessExclusiveLock, false);
/*
+ * Verify that the user is entitled to run the command.
+ *
+ * We don't check any privileges on the extension, because that's not
+ * needed. The object owner is stipulating, by running this command, that
+ * the extension owner can drop the object whenever they feel like it,
+ * which is not considered a problem.
+ */
+ check_object_ownership(GetUserId(),
+ stmt->objectType, address, stmt->object, rel);
+
+ /*
* If a relation was involved, it would have been opened and locked. We
* don't need the relation here, but we'll retain the lock until commit.
*/