Repair failure to check that a table is still compatible with a previously
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 2 Feb 2007 00:08:01 +0000 (00:08 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 2 Feb 2007 00:08:01 +0000 (00:08 +0000)
commit8c98788501c443b825b8d3bb4b036f11e92f7a66
tree6ac185d91935e522c68afff503109b0d70e2d2e7
parent3953b071632969a0041bd6c20e20914b2ef8f692
Repair failure to check that a table is still compatible with a previously
made query plan.  Use of ALTER COLUMN TYPE creates a hazard for cached
query plans: they could contain Vars that claim a column has a different
type than it now has.  Fix this by checking during plan startup that Vars
at relation scan level match the current relation tuple descriptor.  Since
at that point we already have at least AccessShareLock, we can be sure the
column type will not change underneath us later in the query.  However,
since a backend's locks do not conflict against itself, there is still a
hole for an attacker to exploit: he could try to execute ALTER COLUMN TYPE
while a query is in progress in the current backend.  Seal that hole by
rejecting ALTER TABLE whenever the target relation is already open in
the current backend.

This is a significant security hole: not only can one trivially crash the
backend, but with appropriate misuse of pass-by-reference datatypes it is
possible to read out arbitrary locations in the server process's memory,
which could allow retrieving database content the user should not be able
to see.  Our thanks to Jeff Trout for the initial report.

Security: CVE-2007-0556
13 files changed:
src/backend/commands/tablecmds.c
src/backend/executor/execMain.c
src/backend/executor/execQual.c
src/backend/executor/execScan.c
src/backend/executor/execUtils.c
src/backend/executor/nodeAgg.c
src/backend/executor/nodeGroup.c
src/backend/executor/nodeHashjoin.c
src/backend/executor/nodeMergejoin.c
src/backend/executor/nodeNestloop.c
src/backend/executor/nodeResult.c
src/backend/executor/nodeSubplan.c
src/include/executor/executor.h