|
|
9d7d3f |
From 0b7dd36575821bd6e4e86f7b51ac001e69abddf9 Mon Sep 17 00:00:00 2001
|
|
|
9d7d3f |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
9d7d3f |
Date: Fri, 12 Apr 2013 15:53:39 +0200
|
|
|
9d7d3f |
Subject: [PATCH 1/3] test1216: test tailmatching cookie domains
|
|
|
9d7d3f |
|
|
|
9d7d3f |
This test is an attempt to repeat the problem YAMADA Yasuharu reported
|
|
|
9d7d3f |
at http://curl.haxx.se/mail/lib-2013-04/0108.html
|
|
|
9d7d3f |
|
|
|
9d7d3f |
Conflicts:
|
|
|
9d7d3f |
|
|
|
9d7d3f |
tests/data/Makefile.am
|
|
|
9d7d3f |
|
|
|
9d7d3f |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
9d7d3f |
---
|
|
|
9d7d3f |
tests/data/Makefile.am | 2 +-
|
|
|
9d7d3f |
tests/data/Makefile.in | 2 +-
|
|
|
9d7d3f |
tests/data/test1216 | 62 ++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
9d7d3f |
3 files changed, 64 insertions(+), 2 deletions(-)
|
|
|
9d7d3f |
create mode 100644 tests/data/test1216
|
|
|
9d7d3f |
|
|
|
9d7d3f |
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
|
|
|
9d7d3f |
index 9f569a3..d714e5d 100644
|
|
|
9d7d3f |
--- a/tests/data/Makefile.am
|
|
|
9d7d3f |
+++ b/tests/data/Makefile.am
|
|
|
9d7d3f |
@@ -77,7 +77,7 @@ test1110 test1111 test1112 test1113 test1114 test1115 test1116 test1117 \
|
|
|
9d7d3f |
test1118 test1119 test1120 test1121 test1122 test1123 test1124 test1125 \
|
|
|
9d7d3f |
test1126 test1127 test1128 test1129 test1130 test1131 test1132 test1133 \
|
|
|
9d7d3f |
test1200 test1201 test1202 test1203 test1204 test1205 test1206 test1207 \
|
|
|
9d7d3f |
-test1208 test1209 test1210 test1211 \
|
|
|
9d7d3f |
+test1208 test1209 test1210 test1211 test1216 \
|
|
|
9d7d3f |
test1220 test1221 test1222 test1223 \
|
|
|
9d7d3f |
test1300 test1301 test1302 test1303 test1304 test1305 \
|
|
|
9d7d3f |
test1306 test1307 test1308 test1309 test1310 test1311 test1312 test1313 \
|
|
|
9d7d3f |
diff --git a/tests/data/Makefile.in b/tests/data/Makefile.in
|
|
|
9d7d3f |
index d5b0918..a070266 100644
|
|
|
9d7d3f |
--- a/tests/data/Makefile.in
|
|
|
9d7d3f |
+++ b/tests/data/Makefile.in
|
|
|
9d7d3f |
@@ -341,7 +341,7 @@ test1110 test1111 test1112 test1113 test1114 test1115 test1116 test1117 \
|
|
|
9d7d3f |
test1118 test1119 test1120 test1121 test1122 test1123 test1124 test1125 \
|
|
|
9d7d3f |
test1126 test1127 test1128 test1129 test1130 test1131 test1132 test1133 \
|
|
|
9d7d3f |
test1200 test1201 test1202 test1203 test1204 test1205 test1206 test1207 \
|
|
|
9d7d3f |
-test1208 test1209 test1210 test1211 \
|
|
|
9d7d3f |
+test1208 test1209 test1210 test1211 test1216 \
|
|
|
9d7d3f |
test1220 test1221 test1222 test1223 \
|
|
|
9d7d3f |
test1300 test1301 test1302 test1303 test1304 test1305 \
|
|
|
9d7d3f |
test1306 test1307 test1308 test1309 test1310 test1311 test1312 test1313 \
|
|
|
9d7d3f |
diff --git a/tests/data/test1216 b/tests/data/test1216
|
|
|
9d7d3f |
new file mode 100644
|
|
|
9d7d3f |
index 0000000..e63fe92
|
|
|
9d7d3f |
--- /dev/null
|
|
|
9d7d3f |
+++ b/tests/data/test1216
|
|
|
9d7d3f |
@@ -0,0 +1,62 @@
|
|
|
9d7d3f |
+<testcase>
|
|
|
9d7d3f |
+<info>
|
|
|
9d7d3f |
+<keywords>
|
|
|
9d7d3f |
+HTTP
|
|
|
9d7d3f |
+HTTP GET
|
|
|
9d7d3f |
+HTTP proxy
|
|
|
9d7d3f |
+cookies
|
|
|
9d7d3f |
+</keywords>
|
|
|
9d7d3f |
+</info>
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+# Server-side
|
|
|
9d7d3f |
+<reply>
|
|
|
9d7d3f |
+<data>
|
|
|
9d7d3f |
+HTTP/1.1 200 OK
|
|
|
9d7d3f |
+Server: Microsoft-IIS/4.0
|
|
|
9d7d3f |
+Date: Tue, 25 Sep 2001 19:37:44 GMT
|
|
|
9d7d3f |
+Content-Type: text/html
|
|
|
9d7d3f |
+Connection: close
|
|
|
9d7d3f |
+Content-Length: 21
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+This server says moo
|
|
|
9d7d3f |
+</data>
|
|
|
9d7d3f |
+</reply>
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+# Client-side
|
|
|
9d7d3f |
+<client>
|
|
|
9d7d3f |
+<server>
|
|
|
9d7d3f |
+http
|
|
|
9d7d3f |
+</server>
|
|
|
9d7d3f |
+ <name>
|
|
|
9d7d3f |
+HTTP cookie domains tailmatching the host name
|
|
|
9d7d3f |
+ </name>
|
|
|
9d7d3f |
+ <command>
|
|
|
9d7d3f |
+http://example.fake/c/1216 http://bexample.fake/c/1216 -b log/injar1216 -x %HOSTIP:%HTTPPORT
|
|
|
9d7d3f |
+</command>
|
|
|
9d7d3f |
+<file name="log/injar1216">
|
|
|
9d7d3f |
+example.fake FALSE /a FALSE 2139150993 mooo indeed
|
|
|
9d7d3f |
+example.fake FALSE /b FALSE 0 moo1 indeed
|
|
|
9d7d3f |
+example.fake FALSE /c FALSE 2139150993 moo2 indeed
|
|
|
9d7d3f |
+</file>
|
|
|
9d7d3f |
+</client>
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+# Verify data after the test has been "shot"
|
|
|
9d7d3f |
+<verify>
|
|
|
9d7d3f |
+<strip>
|
|
|
9d7d3f |
+^User-Agent:.*
|
|
|
9d7d3f |
+</strip>
|
|
|
9d7d3f |
+<protocol>
|
|
|
9d7d3f |
+GET http://example.fake/c/1216 HTTP/1.1
|
|
|
9d7d3f |
+Host: example.fake
|
|
|
9d7d3f |
+Accept: */*
|
|
|
9d7d3f |
+Proxy-Connection: Keep-Alive
|
|
|
9d7d3f |
+Cookie: moo2=indeed
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+GET http://bexample.fake/c/1216 HTTP/1.1
|
|
|
9d7d3f |
+Host: bexample.fake
|
|
|
9d7d3f |
+Accept: */*
|
|
|
9d7d3f |
+Proxy-Connection: Keep-Alive
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+</protocol>
|
|
|
9d7d3f |
+</verify>
|
|
|
9d7d3f |
+</testcase>
|
|
|
9d7d3f |
--
|
|
|
9d7d3f |
1.7.1
|
|
|
9d7d3f |
|
|
|
9d7d3f |
|
|
|
9d7d3f |
From 6c5a78d0407788b1092bbc8a19b68b01ccb75f8a Mon Sep 17 00:00:00 2001
|
|
|
9d7d3f |
From: YAMADA Yasuharu <yasuharu.yamada@access-company.com>
|
|
|
9d7d3f |
Date: Thu, 11 Apr 2013 00:17:15 +0200
|
|
|
9d7d3f |
Subject: [PATCH 2/3] cookie: fix tailmatching to prevent cross-domain leakage
|
|
|
9d7d3f |
|
|
|
9d7d3f |
Cookies set for 'example.com' could accidentaly also be sent by libcurl
|
|
|
9d7d3f |
to the 'bexample.com' (ie with a prefix to the first domain name).
|
|
|
9d7d3f |
|
|
|
9d7d3f |
This is a security vulnerabilty, CVE-2013-1944.
|
|
|
9d7d3f |
|
|
|
9d7d3f |
Bug: http://curl.haxx.se/docs/adv_20130412.html
|
|
|
9d7d3f |
|
|
|
9d7d3f |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
9d7d3f |
---
|
|
|
9d7d3f |
lib/cookie.c | 24 +++++++++++++++++++-----
|
|
|
9d7d3f |
1 files changed, 19 insertions(+), 5 deletions(-)
|
|
|
9d7d3f |
|
|
|
9d7d3f |
diff --git a/lib/cookie.c b/lib/cookie.c
|
|
|
9d7d3f |
index 18b9155..d4fd78a 100644
|
|
|
9d7d3f |
--- a/lib/cookie.c
|
|
|
9d7d3f |
+++ b/lib/cookie.c
|
|
|
9d7d3f |
@@ -118,15 +118,29 @@ static void freecookie(struct Cookie *co)
|
|
|
9d7d3f |
free(co);
|
|
|
9d7d3f |
}
|
|
|
9d7d3f |
|
|
|
9d7d3f |
-static bool tailmatch(const char *little, const char *bigone)
|
|
|
9d7d3f |
+static bool tailmatch(const char *cooke_domain, const char *hostname)
|
|
|
9d7d3f |
{
|
|
|
9d7d3f |
- size_t littlelen = strlen(little);
|
|
|
9d7d3f |
- size_t biglen = strlen(bigone);
|
|
|
9d7d3f |
+ size_t cookie_domain_len = strlen(cooke_domain);
|
|
|
9d7d3f |
+ size_t hostname_len = strlen(hostname);
|
|
|
9d7d3f |
|
|
|
9d7d3f |
- if(littlelen > biglen)
|
|
|
9d7d3f |
+ if(hostname_len < cookie_domain_len)
|
|
|
9d7d3f |
return FALSE;
|
|
|
9d7d3f |
|
|
|
9d7d3f |
- return Curl_raw_equal(little, bigone+biglen-littlelen) ? TRUE : FALSE;
|
|
|
9d7d3f |
+ if(!Curl_raw_equal(cooke_domain, hostname+hostname_len-cookie_domain_len))
|
|
|
9d7d3f |
+ return FALSE;
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+ /* A lead char of cookie_domain is not '.'.
|
|
|
9d7d3f |
+ RFC6265 4.1.2.3. The Domain Attribute says:
|
|
|
9d7d3f |
+ For example, if the value of the Domain attribute is
|
|
|
9d7d3f |
+ "example.com", the user agent will include the cookie in the Cookie
|
|
|
9d7d3f |
+ header when making HTTP requests to example.com, www.example.com, and
|
|
|
9d7d3f |
+ www.corp.example.com.
|
|
|
9d7d3f |
+ */
|
|
|
9d7d3f |
+ if(hostname_len == cookie_domain_len)
|
|
|
9d7d3f |
+ return TRUE;
|
|
|
9d7d3f |
+ if('.' == *(hostname + hostname_len - cookie_domain_len - 1))
|
|
|
9d7d3f |
+ return TRUE;
|
|
|
9d7d3f |
+ return FALSE;
|
|
|
9d7d3f |
}
|
|
|
9d7d3f |
|
|
|
9d7d3f |
/*
|
|
|
9d7d3f |
--
|
|
|
9d7d3f |
1.7.1
|
|
|
9d7d3f |
|
|
|
9d7d3f |
|
|
|
9d7d3f |
From 6284e78c9421911a24349621c5b63684823d12f7 Mon Sep 17 00:00:00 2001
|
|
|
9d7d3f |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
9d7d3f |
Date: Fri, 12 Apr 2013 15:55:57 +0200
|
|
|
9d7d3f |
Subject: [PATCH 3/3] test1218: another cookie tailmatch test
|
|
|
9d7d3f |
|
|
|
9d7d3f |
These tests verify commit 3604fde3d3c9b0d, the fix for the "cookie
|
|
|
9d7d3f |
domain tailmatch" vulnerability. See
|
|
|
9d7d3f |
http://curl.haxx.se/docs/adv_20130412.html
|
|
|
9d7d3f |
|
|
|
9d7d3f |
Conflicts:
|
|
|
9d7d3f |
|
|
|
9d7d3f |
tests/data/Makefile.am
|
|
|
9d7d3f |
|
|
|
9d7d3f |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
9d7d3f |
---
|
|
|
9d7d3f |
tests/data/Makefile.am | 2 +-
|
|
|
9d7d3f |
tests/data/Makefile.in | 2 +-
|
|
|
9d7d3f |
tests/data/test1218 | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
9d7d3f |
3 files changed, 63 insertions(+), 2 deletions(-)
|
|
|
9d7d3f |
create mode 100644 tests/data/test1218
|
|
|
9d7d3f |
|
|
|
9d7d3f |
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
|
|
|
9d7d3f |
index d714e5d..3e8dae0 100644
|
|
|
9d7d3f |
--- a/tests/data/Makefile.am
|
|
|
9d7d3f |
+++ b/tests/data/Makefile.am
|
|
|
9d7d3f |
@@ -77,7 +77,7 @@ test1110 test1111 test1112 test1113 test1114 test1115 test1116 test1117 \
|
|
|
9d7d3f |
test1118 test1119 test1120 test1121 test1122 test1123 test1124 test1125 \
|
|
|
9d7d3f |
test1126 test1127 test1128 test1129 test1130 test1131 test1132 test1133 \
|
|
|
9d7d3f |
test1200 test1201 test1202 test1203 test1204 test1205 test1206 test1207 \
|
|
|
9d7d3f |
-test1208 test1209 test1210 test1211 test1216 \
|
|
|
9d7d3f |
+test1208 test1209 test1210 test1211 test1216 test1218 \
|
|
|
9d7d3f |
test1220 test1221 test1222 test1223 \
|
|
|
9d7d3f |
test1300 test1301 test1302 test1303 test1304 test1305 \
|
|
|
9d7d3f |
test1306 test1307 test1308 test1309 test1310 test1311 test1312 test1313 \
|
|
|
9d7d3f |
diff --git a/tests/data/Makefile.in b/tests/data/Makefile.in
|
|
|
9d7d3f |
index a070266..71c9422 100644
|
|
|
9d7d3f |
--- a/tests/data/Makefile.in
|
|
|
9d7d3f |
+++ b/tests/data/Makefile.in
|
|
|
9d7d3f |
@@ -341,7 +341,7 @@ test1110 test1111 test1112 test1113 test1114 test1115 test1116 test1117 \
|
|
|
9d7d3f |
test1118 test1119 test1120 test1121 test1122 test1123 test1124 test1125 \
|
|
|
9d7d3f |
test1126 test1127 test1128 test1129 test1130 test1131 test1132 test1133 \
|
|
|
9d7d3f |
test1200 test1201 test1202 test1203 test1204 test1205 test1206 test1207 \
|
|
|
9d7d3f |
-test1208 test1209 test1210 test1211 test1216 \
|
|
|
9d7d3f |
+test1208 test1209 test1210 test1211 test1216 test1218 \
|
|
|
9d7d3f |
test1220 test1221 test1222 test1223 \
|
|
|
9d7d3f |
test1300 test1301 test1302 test1303 test1304 test1305 \
|
|
|
9d7d3f |
test1306 test1307 test1308 test1309 test1310 test1311 test1312 test1313 \
|
|
|
9d7d3f |
diff --git a/tests/data/test1218 b/tests/data/test1218
|
|
|
9d7d3f |
new file mode 100644
|
|
|
9d7d3f |
index 0000000..7d86547
|
|
|
9d7d3f |
--- /dev/null
|
|
|
9d7d3f |
+++ b/tests/data/test1218
|
|
|
9d7d3f |
@@ -0,0 +1,61 @@
|
|
|
9d7d3f |
+<testcase>
|
|
|
9d7d3f |
+<info>
|
|
|
9d7d3f |
+<keywords>
|
|
|
9d7d3f |
+HTTP
|
|
|
9d7d3f |
+HTTP GET
|
|
|
9d7d3f |
+HTTP proxy
|
|
|
9d7d3f |
+cookies
|
|
|
9d7d3f |
+</keywords>
|
|
|
9d7d3f |
+</info>
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+# This test is very similar to 1216, only that it sets the cookies from the
|
|
|
9d7d3f |
+# first site instead of reading from a file
|
|
|
9d7d3f |
+<reply>
|
|
|
9d7d3f |
+<data>
|
|
|
9d7d3f |
+HTTP/1.1 200 OK
|
|
|
9d7d3f |
+Date: Tue, 25 Sep 2001 19:37:44 GMT
|
|
|
9d7d3f |
+Set-Cookie: domain=.example.fake; bug=fixed;
|
|
|
9d7d3f |
+Content-Length: 21
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+This server says moo
|
|
|
9d7d3f |
+</data>
|
|
|
9d7d3f |
+</reply>
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+# Client-side
|
|
|
9d7d3f |
+<client>
|
|
|
9d7d3f |
+<server>
|
|
|
9d7d3f |
+http
|
|
|
9d7d3f |
+</server>
|
|
|
9d7d3f |
+ <name>
|
|
|
9d7d3f |
+HTTP cookies and domains with same prefix
|
|
|
9d7d3f |
+ </name>
|
|
|
9d7d3f |
+ <command>
|
|
|
9d7d3f |
+http://example.fake/c/1218 http://example.fake/c/1218 http://bexample.fake/c/1218 -b nonexisting -x %HOSTIP:%HTTPPORT
|
|
|
9d7d3f |
+</command>
|
|
|
9d7d3f |
+</client>
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+# Verify data after the test has been "shot"
|
|
|
9d7d3f |
+<verify>
|
|
|
9d7d3f |
+<strip>
|
|
|
9d7d3f |
+^User-Agent:.*
|
|
|
9d7d3f |
+</strip>
|
|
|
9d7d3f |
+<protocol>
|
|
|
9d7d3f |
+GET http://example.fake/c/1218 HTTP/1.1
|
|
|
9d7d3f |
+Host: example.fake
|
|
|
9d7d3f |
+Accept: */*
|
|
|
9d7d3f |
+Proxy-Connection: Keep-Alive
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+GET http://example.fake/c/1218 HTTP/1.1
|
|
|
9d7d3f |
+Host: example.fake
|
|
|
9d7d3f |
+Accept: */*
|
|
|
9d7d3f |
+Proxy-Connection: Keep-Alive
|
|
|
9d7d3f |
+Cookie: bug=fixed
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+GET http://bexample.fake/c/1218 HTTP/1.1
|
|
|
9d7d3f |
+Host: bexample.fake
|
|
|
9d7d3f |
+Accept: */*
|
|
|
9d7d3f |
+Proxy-Connection: Keep-Alive
|
|
|
9d7d3f |
+
|
|
|
9d7d3f |
+</protocol>
|
|
|
9d7d3f |
+</verify>
|
|
|
9d7d3f |
+</testcase>
|
|
|
9d7d3f |
--
|
|
|
9d7d3f |
1.7.1
|
|
|
9d7d3f |
|