From a5389c1ad51cfee9cf04a0260bfea32b153885d9 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 13 May 2010 18:29:19 +0000 Subject: Prevent PL/Tcl from loading the "unknown" module from pltcl_modules unless that is a regular table or view owned by a superuser. This prevents a trojan horse attack whereby any unprivileged SQL user could create such a table and insert code into it that would then get executed in other users' sessions whenever they call pltcl functions. Worse yet, because the code was automatically loaded into both the "normal" and "safe" interpreters at first use, the attacker could execute unrestricted Tcl code in the "normal" interpreter without there being any pltclu functions anywhere, or indeed anyone else using pltcl at all: installing pltcl is sufficient to open the hole. Change the initialization logic so that the "unknown" code is only loaded into an interpreter when the interpreter is first really used. (That doesn't add any additional security in this particular context, but it seems a prudent change, and anyway the former behavior violated the principle of least astonishment.) Security: CVE-2010-1170 --- doc/src/sgml/pltcl.sgml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/pltcl.sgml b/doc/src/sgml/pltcl.sgml index 899891bee51..73bffd64682 100644 --- a/doc/src/sgml/pltcl.sgml +++ b/doc/src/sgml/pltcl.sgml @@ -1,4 +1,4 @@ - + PL/Tcl - Tcl Procedural Language @@ -690,8 +690,10 @@ CREATE TRIGGER trig_mytab_modcount BEFORE INSERT OR UPDATE ON mytab It recognizes a special table, pltcl_modules, which is presumed to contain modules of Tcl code. If this table exists, the module unknown is fetched from the table - and loaded into the Tcl interpreter immediately after creating - the interpreter. + and loaded into the Tcl interpreter immediately before the first + execution of a PL/Tcl function in a database session. (This + happens separately for PL/Tcl and PL/TclU, if both are used, + because separate interpreters are used for the two languages.) While the unknown module could actually contain any @@ -718,7 +720,11 @@ CREATE TRIGGER trig_mytab_modcount BEFORE INSERT OR UPDATE ON mytab The tables pltcl_modules and pltcl_modfuncs must be readable by all, but it is wise to make them owned and - writable only by the database administrator. + writable only by the database administrator. As a security + precaution, PL/Tcl will ignore pltcl_modules (and thus, + not attempt to load the unknown module) unless it is + owned by a superuser. But update privileges on this table can be + granted to other users, if you trust them sufficiently. -- cgit v1.2.3