components/curl/patches/012-CVE-2013-1944.patch
author Craig Mohrman <craig.mohrman@oracle.com>
Mon, 11 May 2015 10:44:02 -0700
branchs11u2-sru
changeset 4270 279415c50b97
parent 2824 ed80ca124641
permissions -rw-r--r--
20761309 problem in UTILITY/GIT
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2824
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     1
From 3604fde3d3c9b0d0e389e079aecf470d123ba180 Mon Sep 17 00:00:00 2001
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     2
From: YAMADA Yasuharu <[email protected]>
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     3
Date: Thu, 11 Apr 2013 00:17:15 +0200
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     4
Subject: [PATCH] cookie: fix tailmatching to prevent cross-domain leakage
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     5
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     6
Cookies set for 'example.com' could accidentaly also be sent by libcurl
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     7
to the 'bexample.com' (ie with a prefix to the first domain name).
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     8
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     9
This is a security vulnerabilty, CVE-2013-1944.
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    10
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    11
Bug: http://curl.haxx.se/docs/adv_20130412.html
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    12
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    13
--- lib/cookie.c.orig	2013-11-18 14:05:59.517749330 -0800
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    14
+++ lib/cookie.c	2013-11-18 14:08:09.852442022 -0800
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    15
@@ -122,15 +122,29 @@
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    16
   free(co);
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    17
 }
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    18
 
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    19
-static bool tailmatch(const char *little, const char *bigone)
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    20
+static bool tailmatch(const char *cooke_domain, const char *hostname)
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    21
 {
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    22
-  size_t littlelen = strlen(little);
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    23
-  size_t biglen = strlen(bigone);
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    24
+  size_t cookie_domain_len = strlen(cooke_domain);
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    25
+  size_t hostname_len = strlen(hostname);
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    26
 
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    27
-  if(littlelen > biglen)
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    28
+  if(hostname_len < cookie_domain_len)
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    29
     return FALSE;
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    30
 
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    31
-  return (bool)Curl_raw_equal(little, bigone+biglen-littlelen);
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    32
+  if(!Curl_raw_equal(cooke_domain, hostname+hostname_len-cookie_domain_len))
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    33
+    return FALSE;
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    34
+
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    35
+  /* A lead char of cookie_domain is not '.'.
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    36
+     RFC6265 4.1.2.3. The Domain Attribute says:
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    37
+       For example, if the value of the Domain attribute is
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    38
+       "example.com", the user agent will include the cookie in the Cookie
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    39
+       header when making HTTP requests to example.com, www.example.com, and
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    40
+       www.corp.example.com.
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    41
+   */
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    42
+  if(hostname_len == cookie_domain_len)
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    43
+    return TRUE;
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    44
+  if('.' == *(hostname + hostname_len - cookie_domain_len - 1))
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    45
+    return TRUE;
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    46
+  return FALSE;
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    47
 }
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    48
 
ed80ca124641 15941200 curl "gmake test" failures
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    49
 /*