source: branches/fc19-dev/server/common/patches/httpd-mod_status-security.patch @ 2422

Last change on this file since 2422 was 2422, checked in by tboning, 11 years ago
Rebase Scripts httpd patches for httpd 2.4:
File size: 3.5 KB
RevLine 
[2422]1From 0c2aac95f8df4e7c243ea00d54d4050e32f7868b Mon Sep 17 00:00:00 2001
2From: Alexander Chernyakhovsky <achernya@mit.edu>
3Date: Fri, 3 May 2013 21:39:17 -0400
4Subject: [PATCH 2/4] Prevent mod_status from taking effect in .htaccess files
5
6Introduce a directive to the Apache configuration that is only
7permitted in a directory context, called "PermitStatusHandler", to
8prevent users from enabling mod_status from their .htaccess files.
9
10Signed-off-by: Quentin Smith <quentin@mit.edu>
11Signed-off-by: Geoffrey Thomas <geofft@mit.edu>
12---
13 modules/generators/mod_status.c |   60 +++++++++++++++++++++++++++++++++++++--
14 1 file changed, 57 insertions(+), 3 deletions(-)
15
16diff --git a/modules/generators/mod_status.c b/modules/generators/mod_status.c
17index 0237f1d..c7fd0e0 100644
18--- a/modules/generators/mod_status.c
19+++ b/modules/generators/mod_status.c
20@@ -103,6 +103,56 @@ APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap, STATUS, int, status_hook,
21 static pid_t child_pid;
22 #endif
23 
24+typedef struct {
25+  int permit_status_handler;
26+} status_config_rec;
27+
28+/*
29+ * command-related code. This is here to prevent use of ExtendedStatus
30+ * without status_module included.
31+ */
32+static const char *set_extended_status(cmd_parms *cmd, void *dummy, int arg)
33+{
34+    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
35+    if (err != NULL) {
36+        return err;
37+    }
38+    ap_extended_status = arg;
39+    return NULL;
40+}
41+
42+static const char *set_reqtail(cmd_parms *cmd, void *dummy, int arg)
43+{
44+    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
45+    if (err != NULL) {
46+        return err;
47+    }
48+    ap_mod_status_reqtail = arg;
49+    return NULL;
50+}
51+
52+static void *create_status_dir_config(apr_pool_t *p, char *d)
53+{
54+  status_config_rec *conf = apr_pcalloc(p, sizeof(*conf));
55+  conf->permit_status_handler = 0;
56+  return conf;
57+}
58+
59+static const command_rec status_module_cmds[] =
60+{
61+    AP_INIT_FLAG("ExtendedStatus", set_extended_status, NULL, RSRC_CONF,
62+      "\"On\" to enable extended status information, \"Off\" to disable"),
63+    AP_INIT_FLAG("SeeRequestTail", set_reqtail, NULL, RSRC_CONF,
64+      "For verbose requests, \"On\" to see the last 63 chars of the request, "
65+      "\"Off\" (default) to see the first 63 in extended status display"),
66+    AP_INIT_FLAG("PermitStatusHandler", ap_set_flag_slot,
67+                (void *)APR_OFFSETOF(status_config_rec, permit_status_handler),
68+                ACCESS_CONF,
69+      "As a security measure, only permit status handlers where this flag "
70+      "is set. Only legal in directory context, not .htaccess."),
71+    {NULL}
72+};
73+
74 /* Format the number of bytes nicely */
75 static void format_byte_out(request_rec *r, apr_off_t bytes)
76 {
77@@ -207,8 +257,12 @@ static int status_handler(request_rec *r)
78     int times_per_thread;
79 #endif
80 
81-    if (strcmp(r->handler, STATUS_MAGIC_TYPE) && strcmp(r->handler,
82-            "server-status")) {
83+    status_config_rec *conf = ap_get_module_config(r->per_dir_config,
84+                                                  &status_module);
85+
86+    if ((strcmp(r->handler, STATUS_MAGIC_TYPE) &&
87+         strcmp(r->handler, "server-status")) ||
88+       !conf->permit_status_handler) {
89         return DECLINED;
90     }
91 
92@@ -974,7 +1028,7 @@ static void register_hooks(apr_pool_t *p)
93 AP_DECLARE_MODULE(status) =
94 {
95     STANDARD20_MODULE_STUFF,
96-    NULL,                       /* dir config creater */
97+    create_status_dir_config,   /* dir config creater */
98     NULL,                       /* dir merger --- default is to override */
99     NULL,                       /* server config */
100     NULL,                       /* merge server config */
101--
1021.7.9.6 (Apple Git-31.1)
103
Note: See TracBrowser for help on using the repository browser.