You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by so...@apache.org on 2018/07/18 19:29:52 UTC

[trafficserver] branch 6.2.x updated: Restrict access to request headers for ESI variables

This is an automated email from the ASF dual-hosted git repository.

sorber pushed a commit to branch 6.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/6.2.x by this push:
     new 1279f7d  Restrict access to request headers for ESI variables
1279f7d is described below

commit 1279f7d76c2aa4976ffd1c2a342e410bd2585165
Author: Kit Chan <ki...@apache.org>
AuthorDate: Tue Jul 3 17:32:56 2018 -0700

    Restrict access to request headers for ESI variables
    
    (cherry picked from commit 2f4a5b7a3eb4904d59913d4b38e54a4caeecceae)
    
     Conflicts:
    	plugins/esi/lib/Variables.cc
    	plugins/esi/test/vars_test.cc
---
 doc/admin-guide/plugins/esi.en.rst         | 2 +-
 plugins/experimental/esi/lib/Variables.cc  | 6 ++++++
 plugins/experimental/esi/test/vars_test.cc | 2 ++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/doc/admin-guide/plugins/esi.en.rst b/doc/admin-guide/plugins/esi.en.rst
index 8215b68..f82b40e 100644
--- a/doc/admin-guide/plugins/esi.en.rst
+++ b/doc/admin-guide/plugins/esi.en.rst
@@ -151,4 +151,4 @@ Differences from Spec - http://www.w3.org/TR/esi-lang
 
 5. HTTP_COOKIE supports fetching for sub-key
 
-6. HTTP_HEADER supports accessing request headers as variables
+6. HTTP_HEADER supports accessing request headers as variables except "Cookie"
diff --git a/plugins/experimental/esi/lib/Variables.cc b/plugins/experimental/esi/lib/Variables.cc
index aca3fec..8b2e92f 100644
--- a/plugins/experimental/esi/lib/Variables.cc
+++ b/plugins/experimental/esi/lib/Variables.cc
@@ -235,6 +235,12 @@ Variables::getValue(const string &name) const
     return EMPTY_STRING;
   }
 
+  // Disallow Cookie retrieval though HTTP_HEADER
+  if (dict_index == HTTP_HEADER && ((attr_len == 6) && (strncasecmp(attr, "Cookie", 6) == 0))) {
+    _errorLog("[%s] Cannot use HTTP_HEADER to retrieve Cookie", __FUNCTION__);
+    return EMPTY_STRING;
+  }
+
   // change variable name to use only the attribute field
   search_key.assign(attr, attr_len);
 
diff --git a/plugins/experimental/esi/test/vars_test.cc b/plugins/experimental/esi/test/vars_test.cc
index 0f81112..047c8b5 100644
--- a/plugins/experimental/esi/test/vars_test.cc
+++ b/plugins/experimental/esi/test/vars_test.cc
@@ -418,12 +418,14 @@ main()
     esi_vars.populate(HttpHeader("hdr1", -1, "hval1", -1));
     esi_vars.populate(HttpHeader("Hdr2", -1, "hval2", -1));
     esi_vars.populate(HttpHeader("@Intenal-hdr1", -1, "internal-hval1", -1));
+    esi_vars.populate(HttpHeader("cookie", -1, "x=y", -1));
 
     assert(esi_vars.getValue("HTTP_HEADER{hdr1}") == "hval1");
     assert(esi_vars.getValue("HTTP_HEADER{hdr2}") == "");
     assert(esi_vars.getValue("HTTP_HEADER{Hdr2}") == "hval2");
     assert(esi_vars.getValue("HTTP_HEADER{non-existent}") == "");
     assert(esi_vars.getValue("HTTP_HEADER{@Intenal-hdr1}") == "internal-hval1");
+    assert(esi_vars.getValue("HTTP_HEADER{cookie}") == "");
   }
 
   cout << endl << "All tests passed!" << endl;