Fix column-privilege leak in error-message paths
authorStephen Frost <sfrost@snowman.net>
Mon, 12 Jan 2015 22:04:11 +0000 (17:04 -0500)
committerStephen Frost <sfrost@snowman.net>
Wed, 28 Jan 2015 17:33:29 +0000 (12:33 -0500)
commit3a20633694c1a1b1a260eed2aa4fa7ece46e07ca
tree90d4df976b97e0e67c8bdd7b3513a809abab8fe2
parent8c418fbd9ba0227f9089b17d437d97d293772c76
Fix column-privilege leak in error-message paths

While building error messages to return to the user,
BuildIndexValueDescription and ri_ReportViolation would happily include
the entire key or entire row in the result returned to the user, even if
the user didn't have access to view all of the columns being included.

Instead, include only those columns which the user is providing or which
the user has select rights on.  If the user does not have any rights
to view the table or any of the columns involved then no detail is
provided and a NULL value is returned from BuildIndexValueDescription.
Note that, for key cases, the user must have access to all of the
columns for the key to be shown; a partial key will not be returned.

Back-patch all the way, as column-level privileges are now in all
supported versions.

This has been assigned CVE-2014-8161, but since the issue and the patch
have already been publicized on pgsql-hackers, there's no point in trying
to hide this commit.
src/backend/access/index/genam.c
src/backend/access/nbtree/nbtinsert.c
src/backend/commands/copy.c
src/backend/commands/trigger.c
src/backend/executor/execMain.c
src/backend/executor/execUtils.c
src/backend/utils/adt/ri_triggers.c
src/backend/utils/sort/tuplesort.c
src/test/regress/expected/privileges.out
src/test/regress/sql/privileges.sql