]> granicus.if.org Git - pgbouncer/commitdiff
new config var: disable_pqexec
authorMarko Kreen <markokr@gmail.com>
Mon, 6 Sep 2010 14:00:32 +0000 (17:00 +0300)
committerMarko Kreen <markokr@gmail.com>
Mon, 6 Sep 2010 14:00:32 +0000 (17:00 +0300)
doc/config.txt
include/bouncer.h
src/client.c
src/main.c

index de608173c58209ab33a199b9f4ccf4b0022029d9..08a6d3a9b9cc211da5fa44bc97c9974234c37434 100644 (file)
@@ -175,6 +175,15 @@ specified here, so that pgbouncer knows that they are handled by admin and it ca
 
 Default: empty
 
+==== disable_pqexec ====
+
+Disable Simple Query protocol (PQexec).  Unlike Extended Query protocol, Simple Query
+allows multiple queries in one packet, which allows some classes of SQL-injection
+attacks.  Disabling it can improve security.  Obviously this means only clients that
+exclusively use Extended Query protocol will stay working.
+
+Default: 0
+
 === Log settings ===
 
 ==== syslog ====
index 277f58dba23448d021c6928ab4d24a4b14d32630..e989dcac7dc8e29ac35bcff3b4577acf530444ff 100644 (file)
@@ -340,6 +340,7 @@ extern usec_t cf_query_wait_timeout;
 extern usec_t cf_client_idle_timeout;
 extern usec_t cf_client_login_timeout;
 extern int cf_server_round_robin;
+extern int cf_disable_pqexec;
 
 extern int cf_auth_type;
 extern char *cf_auth_file;
index c23b561d5c59c1e0acc1dfcbf0f063d8b1e2c850..f659a8d39f2dd4db0d01929868f98fd701eeaeef 100644 (file)
@@ -291,14 +291,19 @@ static bool handle_client_work(PgSocket *client, PktHdr *pkt)
 
        switch (pkt->type) {
 
-       /* request immidiate response from server */
-       case 'H':               /* Flush */
-       case 'S':               /* Sync */
-
        /* one-packet queries */
        case 'Q':               /* Query */
+               if (cf_disable_pqexec) {
+                       slog_error(client, "Client used 'Q' packet type.");
+                       disconnect_client(client, true, "PQexec disallowed");
+                       return false;
+               }
        case 'F':               /* FunctionCall */
 
+       /* request immidiate response from server */
+       case 'H':               /* Flush */
+       case 'S':               /* Sync */
+
        /* copy end markers */
        case 'c':               /* CopyDone(F/B) */
        case 'f':               /* CopyFail(F/B) */
index 560b100f757d8ed0090238ca7990e4057c825eff..8ebc01fc7af3aa0253dc5f1dfec4ae05c2cea5df 100644 (file)
@@ -98,6 +98,7 @@ char *cf_server_reset_query = "";
 char *cf_server_check_query = "select 1";
 usec_t cf_server_check_delay = 30 * USEC;
 int cf_server_round_robin = 0;
+int cf_disable_pqexec = 0;
 
 char *cf_ignore_startup_params = "";
 
@@ -174,6 +175,7 @@ ConfElem bouncer_params[] = {
 {"server_round_robin", true, CF_INT, &cf_server_round_robin},
 {"suspend_timeout",    true, CF_TIME, &cf_suspend_timeout},
 {"ignore_startup_parameters", true, CF_STR, &cf_ignore_startup_params},
+{"disable_pqexec",     false, CF_INT, &cf_disable_pqexec},
 
 {"pkt_buf",            false, CF_INT, &cf_sbuf_len},
 {"sbuf_loopcnt",       true, CF_INT, &cf_sbuf_loopcnt},