From: Nick Kew Date: Tue, 18 Aug 2009 22:23:38 +0000 (+0000) Subject: Backport mod_dbd docs updates, since we're shipping an APU version X-Git-Tag: 2.2.14~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af991694201c73763308bfc73f63b13cf9646d63;p=thirdparty%2Fapache%2Fhttpd.git Backport mod_dbd docs updates, since we're shipping an APU version with the FreeTDS and ODBC drivers. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@805607 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/mod/mod_dbd.xml b/docs/manual/mod/mod_dbd.xml index df9c05f9821..45d91b72405 100644 --- a/docs/manual/mod/mod_dbd.xml +++ b/docs/manual/mod/mod_dbd.xml @@ -114,6 +114,43 @@ APR_DECLARE_OPTIONAL_FN(void, ap_dbd_prepare, (server_rec*, const char*, const c or to provide their own directives and use ap_dbd_prepare.

+
+SECURITY WARNING +

Any web/database application needs to secure itself against SQL + injection attacks. In most cases, Apache DBD is safe, because + applications use prepared statements, and untrusted inputs are + only ever used as data. Of course, if you use it via third-party + modules, you should ascertain what precautions they may require.

+

However, the FreeTDS driver is inherently + unsafe. The underlying library doesn't support + prepared statements, so the driver emulates them, and the + untrusted input is merged into the SQL statement.

+

It can be made safe by untainting all inputs: + a process inspired by Perl's taint checking. Each input + is matched against a regexp, and only the match is used, + according to the Perl idiom:

+ +
  $untrusted =~ /([a-z]+)/;
+  $trusted = $1;
+
+

To use this, the untainting regexps must be included in the + prepared statements configured. The regexp follows immediately + after the % in the prepared statement, and is enclosed in + curly brackets {}. For example, if your application expects + alphanumeric input, you can use:

+ + "SELECT foo FROM bar WHERE input = %s" + +

with other drivers, and suffer nothing worse than a failed query. + But with FreeTDS you'd need:

+ + "SELECT foo FROM bar WHERE input = %{([A-Za-z0-9]+)}s" + +

Now anything that doesn't match the regexp's $1 match is + discarded, so the statement is safe.

+

An alternative to this may be the third-party ODBC driver, + which offers the security of genuine prepared statements.

+
DBDriver Specify an SQL driver @@ -143,8 +180,12 @@ APR_DECLARE_OPTIONAL_FN(void, ap_dbd_prepare, (server_rec*, const char*, const c password, database name, hostname and port number for connection.

Connection string parameters for current drivers include:

+
FreeTDS (for MSSQL and SyBase - see SECURITY note)
+
username, password, appname, dbname, host, charset, lang, server
MySQL
-
host, port, user, pass, dbname, sock
+
host, port, user, pass, dbname, sock, flags, fldsz, group, reconnect
+
ODBC
+
datasource, user, password, connect, ctimeout, stimeout, access, txmode, bufsize
Oracle
user, pass, dbname, server
PostgreSQL