Recently, a foreign security researcher found a vulnerability on the Apache server that uses the Rewritelog () function in the modules/mappers/mod_rewrite.c file to incorrectly process certain escape sequences, as a result, malicious attackers can inject specially crafted HTTP requests into log files. If an HTTP request contains the escape sequence of the terminal simulator, attackers may be allowed to execute commands without administrator privileges.
Apache 2.2.x is known to have this vulnerability, but other versions may also be affected. The official release of this vulnerability is as follows:
Index: CHANGES===================================================================--- CHANGES (revision 1469310)+++ CHANGES (working copy)@@ -1,8 +1,11 @@ -*- coding: utf-8 -*- Changes with Apache 2.2.25 + *) SECURITY: CVE-2013-1862 (cve.mitre.org)+ mod_rewrite: Ensure that client data written to the RewriteLog is+ escaped to prevent terminal escape sequences from entering the+ log file. [Joe Orton] - Changes with Apache 2.2.24 *) SECURITY: CVE-2012-3499 (cve.mitre.org)Index: modules/mappers/mod_rewrite.c===================================================================--- modules/mappers/mod_rewrite.c (revision 1469310)+++ modules/mappers/mod_rewrite.c (working copy)@@ -500,11 +500,11 @@ logline = apr_psprintf(r->pool, "%s %s %s %s [%s/sid#%pp][rid#%pp/%s%s%s] " "(%d) %s%s%s%s" APR_EOL_STR,- rhost ? rhost : "UNKNOWN-HOST",- rname ? rname : "-",- r->user ? (*r->user ? r->user : "\"\"") : "-",+ rhost ? ap_escape_logitem(r->pool, rhost) : "UNKNOWN-HOST",+ rname ? ap_escape_logitem(r->pool, rname) : "-",+ r->user ? (*r->user ? ap_escape_logitem(r->pool, r->user) : "\"\"") : "-", current_logtime(r),- ap_get_server_name(r),+ ap_escape_logitem(r->pool, ap_get_server_name(r)), (void *)(r->server), (void *)r, r->main ? "subreq" : "initial",@@ -514,7 +514,7 @@ perdir ? "[perdir " : "", perdir ? perdir : "", perdir ? "] ": "",- text);+ ap_escape_logitem(r->pool, text)); nbytes = strlen(logline); apr_file_write(conf->rewritelogfp, logline, &nbytes);
Patch address: http://people.apache.org /~ Jorton/mod_rewrite-CVE-2013-1862.patch
Mod_rewrite.c source file address for study