f0d6ab
From d9d5fea585b23991f76532a9b07de7fcd3b649f4 Mon Sep 17 00:00:00 2001
f0d6ab
From: Graham Dumpleton <Graham.Dumpleton@gmail.com>
f0d6ab
Date: Wed, 21 May 2014 16:16:47 +1000
f0d6ab
Subject: [PATCH] Local privilege escalation when using daemon mode.
f0d6ab
 (CVE-2014-0240)
f0d6ab
f0d6ab
---
f0d6ab
 mod_wsgi.c | 13 +++++++++++++
f0d6ab
 1 file changed, 13 insertions(+)
f0d6ab
f0d6ab
diff --git a/mod_wsgi.c b/mod_wsgi.c
f0d6ab
index 32b2903..3ef911b 100644
f0d6ab
--- a/mod_wsgi.c
f0d6ab
+++ b/mod_wsgi.c
f0d6ab
@@ -10756,6 +10756,19 @@ static void wsgi_setup_access(WSGIDaemonProcess *daemon)
f0d6ab
         ap_log_error(APLOG_MARK, WSGI_LOG_ALERT(errno), wsgi_server,
f0d6ab
                      "mod_wsgi (pid=%d): Unable to change to uid=%ld.",
f0d6ab
                      getpid(), (long)daemon->group->uid);
f0d6ab
+
f0d6ab
+        /*
f0d6ab
+         * On true UNIX systems this should always succeed at
f0d6ab
+         * this point. With certain Linux kernel versions though
f0d6ab
+         * we can get back EAGAIN where the target user had
f0d6ab
+         * reached their process limit. In that case will be left
f0d6ab
+         * running as wrong user. Just exit on all failures to be
f0d6ab
+         * safe. Don't die immediately to avoid a fork bomb.
f0d6ab
+         */
f0d6ab
+
f0d6ab
+        sleep(20);
f0d6ab
+
f0d6ab
+        exit(-1);
f0d6ab
     }
f0d6ab
 
f0d6ab
 #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
f0d6ab
-- 
f0d6ab
2.0.3
f0d6ab