Skip to content
Snippets Groups Projects
Commit aa27464b authored by Tom Lane's avatar Tom Lane
Browse files

Prevent execution of enum_recv() from SQL.

This function was misdeclared to take cstring when it should take internal.
This at least allows crashing the server, and in principle an attacker
might be able to use the function to examine the contents of server memory.

The correct fix is to adjust the system catalog contents (and fix the
regression tests that should have caught this but failed to).  However,
asking users to correct the catalog contents in existing installations
is a pain, so as a band-aid fix for the back branches, install a check
in enum_recv() to make it throw error if called with a cstring argument.
We will later revert this in HEAD in favor of correcting the catalogs.

Our thanks to Sumit Soni (via Secunia SVCRP) for reporting this issue.

Security: CVE-2013-0255
parent fea63237
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,19 @@ ...@@ -40,6 +40,19 @@
<itemizedlist> <itemizedlist>
<listitem>
<para>
Prevent execution of <function>enum_recv</> from SQL (Tom Lane)
</para>
<para>
The function was misdeclared, allowing a simple SQL command to crash the
server. In principle an attacker might be able to use it to examine the
contents of server memory. Our thanks to Sumit Soni (via Secunia SVCRP)
for reporting this issue. (CVE-2013-0255)
</para>
</listitem>
<listitem> <listitem>
<para> <para>
Fix SQL grammar to allow subscripting or field selection from a Fix SQL grammar to allow subscripting or field selection from a
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "postgres.h" #include "postgres.h"
#include "catalog/pg_enum.h" #include "catalog/pg_enum.h"
#include "catalog/pg_type.h"
#include "fmgr.h" #include "fmgr.h"
#include "utils/array.h" #include "utils/array.h"
#include "utils/builtins.h" #include "utils/builtins.h"
...@@ -99,6 +100,10 @@ enum_recv(PG_FUNCTION_ARGS) ...@@ -99,6 +100,10 @@ enum_recv(PG_FUNCTION_ARGS)
char *name; char *name;
int nbytes; int nbytes;
/* guard against pre-9.3 misdeclaration of enum_recv */
if (get_fn_expr_argtype(fcinfo->flinfo, 0) == CSTRINGOID)
elog(ERROR, "invalid argument for enum_recv");
name = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes); name = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes);
/* must check length to prevent Assert failure within SearchSysCache */ /* must check length to prevent Assert failure within SearchSysCache */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment