c260e0
From 55689681595d76ee53d76d6698f5a99e18395857 Mon Sep 17 00:00:00 2001
c260e0
From: David Woodhouse <David.Woodhouse@intel.com>
c260e0
Date: Fri, 11 Jul 2014 11:09:34 +0100
c260e0
Subject: [PATCH 1/2] Don't clear GSSAPI state between each exchange in the
c260e0
 negotiation
c260e0
c260e0
GSSAPI doesn't work very well if we forget everything ever time.
c260e0
c260e0
XX: Is Curl_http_done() the right place to do the final cleanup?
c260e0
c260e0
Upstream-commit: f78ae415d24b9bd89d6c121c556e411fdb21c6aa
c260e0
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
c260e0
---
c260e0
 lib/http.c                | 6 ++++++
c260e0
 lib/http_negotiate.c      | 1 -
c260e0
 lib/http_negotiate_sspi.c | 1 -
c260e0
 3 files changed, 6 insertions(+), 2 deletions(-)
c260e0
c260e0
diff --git a/lib/http.c b/lib/http.c
c260e0
index e2448bc..c32eae0 100644
c260e0
--- a/lib/http.c
c260e0
+++ b/lib/http.c
c260e0
@@ -1404,6 +1404,12 @@ CURLcode Curl_http_done(struct connectdata *conn,
c260e0
 
c260e0
   Curl_unencode_cleanup(conn);
c260e0
 
c260e0
+#ifdef USE_HTTP_NEGOTIATE
c260e0
+  if(data->state.proxyneg.state == GSS_AUTHSENT ||
c260e0
+      data->state.negotiate.state == GSS_AUTHSENT)
c260e0
+    Curl_cleanup_negotiate(data);
c260e0
+#endif
c260e0
+
c260e0
   /* set the proper values (possibly modified on POST) */
c260e0
   conn->fread_func = data->set.fread_func; /* restore */
c260e0
   conn->fread_in = data->set.in; /* restore */
c260e0
diff --git a/lib/http_negotiate.c b/lib/http_negotiate.c
c260e0
index 535a427..b56e7d0 100644
c260e0
--- a/lib/http_negotiate.c
c260e0
+++ b/lib/http_negotiate.c
c260e0
@@ -343,7 +343,6 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
c260e0
   else
c260e0
     conn->allocptr.userpwd = userp;
c260e0
   free(encoded);
c260e0
-  Curl_cleanup_negotiate (conn->data);
c260e0
   return (userp == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK;
c260e0
 }
c260e0
 
c260e0
diff --git a/lib/http_negotiate_sspi.c b/lib/http_negotiate_sspi.c
c260e0
index 1381d52..678e605 100644
c260e0
--- a/lib/http_negotiate_sspi.c
c260e0
+++ b/lib/http_negotiate_sspi.c
c260e0
@@ -271,7 +271,6 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
c260e0
   else
c260e0
     conn->allocptr.userpwd = userp;
c260e0
   free(encoded);
c260e0
-  Curl_cleanup_negotiate (conn->data);
c260e0
   return (userp == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK;
c260e0
 }
c260e0
 
c260e0
-- 
c260e0
2.3.6
c260e0
c260e0
c260e0
From 28e84254779c0d4b31844d928e5dae8941128f05 Mon Sep 17 00:00:00 2001
c260e0
From: Daniel Stenberg <daniel@haxx.se>
c260e0
Date: Sat, 18 Apr 2015 23:50:16 +0200
c260e0
Subject: [PATCH 2/2] http_done: close Negotiate connections when done
c260e0
c260e0
When doing HTTP requests Negotiate authenticated, the entire connnection
c260e0
may become authenticated and not just the specific HTTP request which is
c260e0
otherwise how HTTP works, as Negotiate can basically use NTLM under the
c260e0
hood. curl was not adhering to this fact but would assume that such
c260e0
requests would also be authenticated per request.
c260e0
c260e0
CVE-2015-3148
c260e0
c260e0
Bug: http://curl.haxx.se/docs/adv_20150422B.html
c260e0
Reported-by: Isaac Boukris
c260e0
c260e0
Upstream-commit: 79b9d5f1a42578f807a6c94914bc65cbaa304b6d
c260e0
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
c260e0
---
c260e0
 lib/http.c | 8 +++++++-
c260e0
 1 file changed, 7 insertions(+), 1 deletion(-)
c260e0
c260e0
diff --git a/lib/http.c b/lib/http.c
c260e0
index c32eae0..04beeb1 100644
c260e0
--- a/lib/http.c
c260e0
+++ b/lib/http.c
c260e0
@@ -1406,8 +1406,14 @@ CURLcode Curl_http_done(struct connectdata *conn,
c260e0
 
c260e0
 #ifdef USE_HTTP_NEGOTIATE
c260e0
   if(data->state.proxyneg.state == GSS_AUTHSENT ||
c260e0
-      data->state.negotiate.state == GSS_AUTHSENT)
c260e0
+     data->state.negotiate.state == GSS_AUTHSENT) {
c260e0
+    /* add forbid re-use if http-code != 401/407 as a WA only needed for
c260e0
+     * 401/407 that signal auth failure (empty) otherwise state will be RECV
c260e0
+     * with current code */
c260e0
+    if((data->req.httpcode != 401) && (data->req.httpcode != 407))
c260e0
+      conn->bits.close = TRUE; /* Negotiate transfer completed */
c260e0
     Curl_cleanup_negotiate(data);
c260e0
+  }
c260e0
 #endif
c260e0
 
c260e0
   /* set the proper values (possibly modified on POST) */
c260e0
-- 
c260e0
2.3.6
c260e0