1 From 69a2e8d7ec581695a62527cb2252e7350f314ffa Mon Sep 17 00:00:00 2001
2 From: Daniel Stenberg <daniel@haxx.se>
3 Date: Thu, 23 Apr 2015 15:58:21 +0200
4 Subject: [PATCH] CURLOPT_HEADEROPT: default to separate
6 Make the HTTP headers separated by default for improved security and
7 reduced risk for information leakage.
9 Bug: http://curl.haxx.se/docs/adv_20150429.html
10 Reported-by: Yehezkel Horowitz, Oren Souroujon
12 docs/libcurl/opts/CURLOPT_HEADEROPT.3 | 12 ++++++------
14 tests/data/test1527 | 2 +-
15 tests/data/test287 | 2 +-
16 tests/libtest/lib1527.c | 1 +
17 5 files changed, 10 insertions(+), 8 deletions(-)
19 --- a/docs/libcurl/opts/CURLOPT_HEADEROPT.3
20 +++ b/docs/libcurl/opts/CURLOPT_HEADEROPT.3
22 .\" * | (__| |_| | _ <| |___
23 .\" * \___|\___/|_| \_\_____|
25 -.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
26 +.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
28 .\" * This software is licensed as described in the file COPYING, which
29 .\" * you should have received as part of this distribution. The terms
30 @@ -31,10 +31,10 @@ CURLcode curl_easy_setopt(CURL *handle,
31 Pass a long that is a bitmask of options of how to deal with headers. The two
32 mutually exclusive options are:
34 -\fBCURLHEADER_UNIFIED\fP - keep working as before. This means
35 -\fICURLOPT_HTTPHEADER(3)\fP headers will be used in requests both to servers
36 -and proxies. With this option enabled, \fICURLOPT_PROXYHEADER(3)\fP will not
38 +\fBCURLHEADER_UNIFIED\fP - the headers specified in
39 +\fICURLOPT_HTTPHEADER(3)\fP will be used in requests both to servers and
40 +proxies. With this option enabled, \fICURLOPT_PROXYHEADER(3)\fP will not have
43 \fBCURLHEADER_SEPARATE\fP - makes \fICURLOPT_HTTPHEADER(3)\fP headers only get
44 sent to a server and not to a proxy. Proxy headers must be set with
45 @@ -44,7 +44,7 @@ headers. When doing CONNECT, libcurl wil
46 headers only to the proxy and then \fICURLOPT_HTTPHEADER(3)\fP headers only to
50 +CURLHEADER_SEPARATE (changed in 7.42.1, ased CURLHEADER_UNIFIED before then)
56 @@ -605,6 +605,7 @@ CURLcode Curl_init_userdefined(struct Us
57 set->ssl_enable_alpn = TRUE;
59 set->expect_100_timeout = 1000L; /* Wait for a second by default. */
60 + set->sep_headers = TRUE; /* separated header lists by default */
64 --- a/tests/data/test1527
65 +++ b/tests/data/test1527
66 @@ -45,7 +45,7 @@ http-proxy
70 -Check same headers are generated without CURLOPT_PROXYHEADER
71 +Check same headers are generated with CURLOPT_HEADEROPT == CURLHEADER_UNIFIED
74 http://the.old.moo.1527:%HTTPPORT/1527 %HOSTIP:%PROXYPORT
75 --- a/tests/data/test287
76 +++ b/tests/data/test287
77 @@ -28,7 +28,7 @@ http
78 HTTP proxy CONNECT with custom User-Agent header
81 -http://test.remote.example.com.287:%HTTPPORT/path/287 -H "User-Agent: looser/2007" --proxy http://%HOSTIP:%HTTPPORT --proxytunnel
82 +http://test.remote.example.com.287:%HTTPPORT/path/287 -H "User-Agent: looser/2015" --proxy http://%HOSTIP:%HTTPPORT --proxytunnel --proxy-header "User-Agent: looser/2007"
86 --- a/tests/libtest/lib1527.c
87 +++ b/tests/libtest/lib1527.c
88 @@ -83,6 +83,7 @@ int test(char *URL)
89 test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
90 test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
91 test_setopt(curl, CURLOPT_INFILESIZE, strlen(data));
92 + test_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_UNIFIED);
94 res = curl_easy_perform(curl);