Always require SELECT permission for ON CONFLICT DO UPDATE.
authorDean Rasheed
Mon, 6 Nov 2017 09:15:11 +0000 (09:15 +0000)
committerDean Rasheed
Mon, 6 Nov 2017 09:15:11 +0000 (09:15 +0000)
commit045a18888f38bd46f5b50e145470095f461cc41c
tree0a8c3f3f5c4c45f93d1b97f1eec9c5e00998b3bd
parent014c5cd8767161995278bc1f4e2fcfb1b703dad1
Always require SELECT permission for ON CONFLICT DO UPDATE.

The update path of an INSERT ... ON CONFLICT DO UPDATE requires SELECT
permission on the columns of the arbiter index, but it failed to check
for that in the case of an arbiter specified by constraint name.

In addition, for a table with row level security enabled, it failed to
check updated rows against the table's SELECT policies when the update
path was taken (regardless of how the arbiter index was specified).

Backpatch to 9.5 where ON CONFLICT DO UPDATE and RLS were introduced.

Security: CVE-2017-15099
src/backend/catalog/pg_constraint.c
src/backend/parser/parse_clause.c
src/backend/rewrite/rowsecurity.c
src/include/catalog/pg_constraint.h
src/test/regress/expected/privileges.out
src/test/regress/expected/rowsecurity.out
src/test/regress/sql/privileges.sql
src/test/regress/sql/rowsecurity.sql