pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Fix column-privilege leak in error-message paths
9+ messages / 2 participants
[nested] [flat]
* pgsql: Fix column-privilege leak in error-message paths
@ 2015-01-28 17:33 Stephen Frost <sfrost@snowman.net>
0 siblings, 0 replies; 9+ messages in thread
From: Stephen Frost @ 2015-01-28 17:33 UTC (permalink / raw)
To: pgsql-committers
Fix column-privilege leak in error-message paths
While building error messages to return to the user,
BuildIndexValueDescription, ExecBuildSlotValueDescription 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
and ExecBuildSlotValueDescription. 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.
Branch
------
REL9_2_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/d49f84b084d82aac3ddc387f9f306c28240f62f7
Modified Files
--------------
src/backend/access/index/genam.c | 60 ++++++++++-
src/backend/access/nbtree/nbtinsert.c | 10 +-
src/backend/commands/copy.c | 6 +-
src/backend/commands/trigger.c | 6 ++
src/backend/executor/execMain.c | 168 +++++++++++++++++++++++-------
src/backend/executor/execUtils.c | 12 ++-
src/backend/utils/adt/ri_triggers.c | 86 +++++++++++----
src/backend/utils/sort/tuplesort.c | 9 +-
src/test/regress/expected/privileges.out | 32 ++++++
src/test/regress/sql/privileges.sql | 25 +++++
10 files changed, 344 insertions(+), 70 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 9+ messages in thread
* pgsql: Fix column-privilege leak in error-message paths
@ 2015-01-28 17:33 Stephen Frost <sfrost@snowman.net>
0 siblings, 0 replies; 9+ messages in thread
From: Stephen Frost @ 2015-01-28 17:33 UTC (permalink / raw)
To: pgsql-committers
Fix column-privilege leak in error-message paths
While building error messages to return to the user,
BuildIndexValueDescription, ExecBuildSlotValueDescription 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
and ExecBuildSlotValueDescription. 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.
Branch
------
REL9_4_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/3cc74a3d61f26e6558ee662b6700f74962bd1d8b
Modified Files
--------------
src/backend/access/index/genam.c | 60 +++++++++-
src/backend/access/nbtree/nbtinsert.c | 10 +-
src/backend/commands/copy.c | 6 +-
src/backend/commands/matview.c | 7 ++
src/backend/commands/trigger.c | 6 +
src/backend/executor/execMain.c | 186 ++++++++++++++++++++++++------
src/backend/executor/execUtils.c | 12 +-
src/backend/utils/adt/ri_triggers.c | 79 ++++++++++---
src/backend/utils/sort/tuplesort.c | 9 +-
src/test/regress/expected/privileges.out | 31 +++++
src/test/regress/sql/privileges.sql | 25 ++++
11 files changed, 361 insertions(+), 70 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 9+ messages in thread
* pgsql: Fix column-privilege leak in error-message paths
@ 2015-01-28 17:33 Stephen Frost <sfrost@snowman.net>
0 siblings, 0 replies; 9+ messages in thread
From: Stephen Frost @ 2015-01-28 17:33 UTC (permalink / raw)
To: pgsql-committers
Fix column-privilege leak in error-message paths
While building error messages to return to the user,
BuildIndexValueDescription, ExecBuildSlotValueDescription 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
and ExecBuildSlotValueDescription. 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.
Branch
------
REL9_3_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/4b987421612131eb15e9cdb0c0363b2a9fb95325
Modified Files
--------------
src/backend/access/index/genam.c | 60 ++++++++++-
src/backend/access/nbtree/nbtinsert.c | 10 +-
src/backend/commands/copy.c | 6 +-
src/backend/commands/trigger.c | 6 ++
src/backend/executor/execMain.c | 166 ++++++++++++++++++++++++------
src/backend/executor/execUtils.c | 12 ++-
src/backend/utils/adt/ri_triggers.c | 79 ++++++++++----
src/backend/utils/sort/tuplesort.c | 9 +-
src/test/regress/expected/privileges.out | 31 ++++++
src/test/regress/sql/privileges.sql | 25 +++++
10 files changed, 338 insertions(+), 66 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 9+ messages in thread
* pgsql: Fix column-privilege leak in error-message paths
@ 2015-01-28 17:33 Stephen Frost <sfrost@snowman.net>
0 siblings, 0 replies; 9+ messages in thread
From: Stephen Frost @ 2015-01-28 17:33 UTC (permalink / raw)
To: pgsql-committers
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.
Branch
------
REL9_1_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/9406884af19e2620a14059e64d4eb6ab430ab328
Modified Files
--------------
src/backend/access/index/genam.c | 60 ++++++++++++++++++++-
src/backend/access/nbtree/nbtinsert.c | 10 ++--
src/backend/commands/copy.c | 6 ++-
src/backend/commands/trigger.c | 6 +++
src/backend/executor/execMain.c | 9 ++++
src/backend/executor/execUtils.c | 12 +++--
src/backend/utils/adt/ri_triggers.c | 85 ++++++++++++++++++++++--------
src/backend/utils/sort/tuplesort.c | 9 ++--
src/test/regress/expected/privileges.out | 28 ++++++++++
src/test/regress/sql/privileges.sql | 25 +++++++++
10 files changed, 215 insertions(+), 35 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 9+ messages in thread
* pgsql: Fix column-privilege leak in error-message paths
@ 2015-01-28 17:33 Stephen Frost <sfrost@snowman.net>
0 siblings, 1 reply; 9+ messages in thread
From: Stephen Frost @ 2015-01-28 17:33 UTC (permalink / raw)
To: pgsql-committers
Fix column-privilege leak in error-message paths
While building error messages to return to the user,
BuildIndexValueDescription, ExecBuildSlotValueDescription 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
and ExecBuildSlotValueDescription. 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.
Further, in master only, do not return any data for cases where row
security is enabled on the relation and row security should be applied
for the user. This required a bit of refactoring and moving of things
around related to RLS- note the addition of utils/misc/rls.c.
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.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/804b6b6db4dcfc590a468e7be390738f9f7755fb
Modified Files
--------------
src/backend/access/index/genam.c | 71 ++++++++++-
src/backend/access/nbtree/nbtinsert.c | 10 +-
src/backend/commands/copy.c | 10 +-
src/backend/commands/createas.c | 4 +-
src/backend/commands/matview.c | 7 ++
src/backend/commands/trigger.c | 6 +
src/backend/executor/execMain.c | 193 +++++++++++++++++++++++------
src/backend/executor/execUtils.c | 12 +-
src/backend/rewrite/rowsecurity.c | 81 +-----------
src/backend/utils/adt/ri_triggers.c | 87 ++++++++++---
src/backend/utils/cache/plancache.c | 2 +-
src/backend/utils/misc/Makefile | 2 +-
src/backend/utils/misc/guc.c | 2 +-
src/backend/utils/misc/rls.c | 114 +++++++++++++++++
src/backend/utils/sort/tuplesort.c | 9 +-
src/include/rewrite/rowsecurity.h | 36 ------
src/include/utils/rls.h | 58 +++++++++
src/test/regress/expected/privileges.out | 31 +++++
src/test/regress/expected/rowsecurity.out | 3 -
src/test/regress/sql/privileges.sql | 25 ++++
20 files changed, 569 insertions(+), 194 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 9+ messages in thread
* pgsql: Fix column-privilege leak in error-message paths
@ 2015-01-28 17:33 Stephen Frost <sfrost@snowman.net>
0 siblings, 0 replies; 9+ messages in thread
From: Stephen Frost @ 2015-01-28 17:33 UTC (permalink / raw)
To: pgsql-committers
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.
Branch
------
REL9_0_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/3a20633694c1a1b1a260eed2aa4fa7ece46e07ca
Modified Files
--------------
src/backend/access/index/genam.c | 60 ++++++++++++++++++++-
src/backend/access/nbtree/nbtinsert.c | 10 ++--
src/backend/commands/copy.c | 8 +++
src/backend/commands/trigger.c | 6 +++
src/backend/executor/execMain.c | 9 ++++
src/backend/executor/execUtils.c | 12 +++--
src/backend/utils/adt/ri_triggers.c | 85 ++++++++++++++++++++++--------
src/backend/utils/sort/tuplesort.c | 9 ++--
src/test/regress/expected/privileges.out | 28 ++++++++++
src/test/regress/sql/privileges.sql | 25 +++++++++
10 files changed, 218 insertions(+), 34 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [COMMITTERS] pgsql: Fix column-privilege leak in error-message paths
@ 2015-01-29 22:06 Tom Lane <tgl@sss.pgh.pa.us>
parent: Stephen Frost <sfrost@snowman.net>
0 siblings, 2 replies; 9+ messages in thread
From: Tom Lane @ 2015-01-29 22:06 UTC (permalink / raw)
To: Stephen Frost <sfrost@snowman.net>; +Cc: pgsql-hackers@postgreSQL.org
Stephen Frost <sfrost@snowman.net> writes:
> Fix column-privilege leak in error-message paths
This patch is at least one brick shy of a load:
regression=# create table t1 (f1 int);
CREATE TABLE
regression=# create unique index on t1 (abs(f1));
CREATE INDEX
regression=# create user joe;
CREATE ROLE
regression=# grant insert on t1 to joe;
GRANT
regression=# \c - joe
You are now connected to database "regression" as user "joe".
regression=> insert into t1 values (1);
INSERT 0 1
regression=> insert into t1 values (1);
ERROR: attribute 0 of relation with OID 45155 does not exist
The cause of that is the logic added to BuildIndexValueDescription, which
ignores the possibility that some of the index columns are expressions
(which will have a zero in indkey[]).
I'm not sure that it's worth trying to drill down and determine exactly
which column(s) are referenced by an expression. I'd be content if we
just decided that any index expression is off-limits to someone without
full SELECT access, which could be achieved with something like
{
AttrNumber attnum = idxrec->indkey.values[keyno];
- aclresult = pg_attribute_aclcheck(indrelid, attnum, GetUserId(),
- ACL_SELECT);
-
- if (aclresult != ACLCHECK_OK)
+ if (attnum == InvalidAttrNumber ||
+ pg_attribute_aclcheck(indrelid, attnum, GetUserId(),
+ ACL_SELECT) != ACLCHECK_OK)
{
/* No access, so clean up and return */
ReleaseSysCache(ht_idx);
(though a comment about it wouldn't be a bad thing either)
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [COMMITTERS] pgsql: Fix column-privilege leak in error-message paths
@ 2015-01-29 22:20 Stephen Frost <sfrost@snowman.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 9+ messages in thread
From: Stephen Frost @ 2015-01-29 22:20 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers@postgreSQL.org
* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Stephen Frost <sfrost@snowman.net> writes:
> > Fix column-privilege leak in error-message paths
>
> This patch is at least one brick shy of a load:
>
> regression=# create table t1 (f1 int);
> CREATE TABLE
> regression=# create unique index on t1 (abs(f1));
> CREATE INDEX
> regression=# create user joe;
> CREATE ROLE
> regression=# grant insert on t1 to joe;
> GRANT
> regression=# \c - joe
> You are now connected to database "regression" as user "joe".
> regression=> insert into t1 values (1);
> INSERT 0 1
> regression=> insert into t1 values (1);
> ERROR: attribute 0 of relation with OID 45155 does not exist
Urgh.
> The cause of that is the logic added to BuildIndexValueDescription, which
> ignores the possibility that some of the index columns are expressions
> (which will have a zero in indkey[]).
Ah, yes, I didn't expect that, clearly.
> I'm not sure that it's worth trying to drill down and determine exactly
> which column(s) are referenced by an expression. I'd be content if we
> just decided that any index expression is off-limits to someone without
> full SELECT access, which could be achieved with something like
Sounds perfectly reasonable to me.
> {
> AttrNumber attnum = idxrec->indkey.values[keyno];
>
> - aclresult = pg_attribute_aclcheck(indrelid, attnum, GetUserId(),
> - ACL_SELECT);
> -
> - if (aclresult != ACLCHECK_OK)
> + if (attnum == InvalidAttrNumber ||
> + pg_attribute_aclcheck(indrelid, attnum, GetUserId(),
> + ACL_SELECT) != ACLCHECK_OK)
> {
> /* No access, so clean up and return */
> ReleaseSysCache(ht_idx);
Yup, that looks good to me.
> (though a comment about it wouldn't be a bad thing either)
Agreed.
Will handle shortly.
Thanks!
Stephen
Attachments:
signature.asc (application/pgp-signature, 818B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [COMMITTERS] pgsql: Fix column-privilege leak in error-message paths
@ 2015-01-30 03:37 Stephen Frost <sfrost@snowman.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 9+ messages in thread
From: Stephen Frost @ 2015-01-30 03:37 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers@postgreSQL.org
Tom,
* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Stephen Frost <sfrost@snowman.net> writes:
> > Fix column-privilege leak in error-message paths
[...]
> The cause of that is the logic added to BuildIndexValueDescription, which
> ignores the possibility that some of the index columns are expressions
> (which will have a zero in indkey[]).
>
> I'm not sure that it's worth trying to drill down and determine exactly
> which column(s) are referenced by an expression. I'd be content if we
> just decided that any index expression is off-limits to someone without
> full SELECT access, which could be achieved with something like
Commit pushed with this approach.
> (though a comment about it wouldn't be a bad thing either)
and a comment added explaining it.
Thanks again for pointing it out and please let me know if you see any
further issues.
Stephen
Attachments:
signature.asc (application/pgp-signature, 818B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2015-01-30 03:37 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-01-28 17:33 pgsql: Fix column-privilege leak in error-message paths Stephen Frost <sfrost@snowman.net>
2015-01-29 22:06 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-01-29 22:20 ` Stephen Frost <sfrost@snowman.net>
2015-01-30 03:37 ` Stephen Frost <sfrost@snowman.net>
2015-01-28 17:33 pgsql: Fix column-privilege leak in error-message paths Stephen Frost <sfrost@snowman.net>
2015-01-28 17:33 pgsql: Fix column-privilege leak in error-message paths Stephen Frost <sfrost@snowman.net>
2015-01-28 17:33 pgsql: Fix column-privilege leak in error-message paths Stephen Frost <sfrost@snowman.net>
2015-01-28 17:33 pgsql: Fix column-privilege leak in error-message paths Stephen Frost <sfrost@snowman.net>
2015-01-28 17:33 pgsql: Fix column-privilege leak in error-message paths Stephen Frost <sfrost@snowman.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox