[Zope-Checkins] CVS: Zope/lib/python/ZTUtils - SimpleTree.py:1.4.42.1 Tree.py:1.15.2.4 Zope.py:1.11.42.3

Tres Seaver tseaver at zope.com
Thu Jan 8 18:34:35 EST 2004


Update of /cvs-repository/Zope/lib/python/ZTUtils
In directory cvs.zope.org:/tmp/cvs-serv30073/lib/python/ZTUtils

Modified Files:
      Tag: Zope-2_7-branch
	SimpleTree.py Tree.py Zope.py 
Log Message:


  Merge security audit work for the 2.7 branch:

    - Collector #1140: setting the access control implementation from
      the configuration file didn't work.  The ZOPE_SECURITY_POLICY
      environment variable is no longer honored.

    - Browsers that do not escape html in query strings such as 
      Internet Explorer 5.5 could potentially send a script tag in a 
      query string to the ZSearch interface for cross-site scripting.

    - FilteredSets (used within TopicIndex) are defined via an expression,
      which was naievely eval'ed.

    - The ZTUtils SimpleTree decompressed tree state data from the 
      request without checking for final size, which could allow for 
      certain types of DoS attacks.

    - Inadequate security assertions on administrative "find" methods 
      could potentially be abused.

    - Some improper security assertions on DTMLDocument objects could 
      potentially allow access to members that should be protected.

    - Class security was not properly intialized for PythonScripts, 
      potentially allowing access to variables that should be protected. 
      It turned out that most of the security assertions were in fact 
      activated as a side effect of other code, but this fix is still 
      appropriate to ensure that all security declarations are properly 
      applied.

    - The dtml-tree tag used an "eval" of user-supplied data; its 
      efforts to prevent abuse were ineffective.

    - XML-RPC marshalling of class instances used the instance 
      __dict__ to marshal the object, and could include attributes 
      prefixed with an underscore name. These attributes are considered 
      private in Zope and should generally not be disclosed.

    - Some property types were stored in a mutable data type (list) which 
      could potentially allow untrusted code to effect changes on those 
      properties without going through appropriate security checks in 
      particular scenarios.

    - Inadequate type checking could allow unicode values passed to 
      RESPONSE.write() to be passed into deeper layers of asyncore, 
      where an exception would eventually be generated at a level that 
      would cause the Zserver main loop to terminate.

    - The variables bound to page templates and Python scripts such as 
      "context" and "container" were not checked adequately, allowing 
      a script to potentially access those objects without ensuring the 
      necessary permissions on the part of the executing user.

    - Iteration over sequences could in some cases fail to check access 
      to an object obtained from the sequence. Subsequent checks (such 
      as for attributes access) of such an object would still be 
      performed, but it should not have been possible to obtain the 
      object in the first place.

    - List and dictionary instance methods such as the get method of 
      dictionary objects were not security aware and could return an 
      object without checking access to that object. Subsequent checks 
      (such as for attributes access) of such an object would still be 
      performed, but it should not have been possible to obtain the 
      object in the first place.

    - Use of 'import as. in Python scripts could potentially rebind 
      names in ways that could be used to avoid appropriate security 
      checks.

    - A number of newer built-ins (min, max, enumerate, iter, sum)
      were either unavailable in untrusted code or did not perform
      adequate security checking.

    - Unpacking via function calls, variable assignment, exception 
      variables and other contexts did not perform adequate security 
      checks, potentially allowing access to objects that should have 
      been protected.

    - DTMLMethods with proxy rights could incorrectly transfer those 
      rights via acquisition when traversing to a parent object.



=== Zope/lib/python/ZTUtils/SimpleTree.py 1.4 => 1.4.42.1 ===
--- Zope/lib/python/ZTUtils/SimpleTree.py:1.4	Thu Oct  3 17:08:40 2002
+++ Zope/lib/python/ZTUtils/SimpleTree.py	Thu Jan  8 18:34:03 2004
@@ -16,6 +16,7 @@
 __version__='$Revision$'[11:-2]
 
 from Tree import TreeMaker, TreeNode, b2a
+from cgi import escape
 
 class SimpleTreeNode(TreeNode):
     def branch(self):
@@ -35,9 +36,10 @@
         obid = self.id
         pre = self.aq_acquire('tree_pre')
 
-        return {'link': '?%s-setstate=%s,%s,%s#%s' % (pre, setst[0],
-                                                      exnum, obid, obid),
-        'img': '<img src="%s/p_/%s" alt="%s" border="0">' % (base, img, setst)}
+        return {'link': '?%s-setstate=%s,%s,%s#%s' % \
+                        (pre, setst[0], exnum, obid, obid),
+                'img': '<img src="%s/p_/%s" alt="%s" border="0">' % \
+                        (escape(base, 1), img, setst)}
 
 
 class SimpleTreeMaker(TreeMaker):


=== Zope/lib/python/ZTUtils/Tree.py 1.15.2.3 => 1.15.2.4 ===
--- Zope/lib/python/ZTUtils/Tree.py:1.15.2.3	Thu Dec 11 13:03:56 2003
+++ Zope/lib/python/ZTUtils/Tree.py	Thu Jan  8 18:34:03 2004
@@ -220,7 +220,7 @@
                            type(0L):1, type(None):1 }.has_key):
     return is_simple(type(ob))
 
-from binascii import b2a_base64, a2b_base64
+import base64
 from string import translate, maketrans
 import zlib
 
@@ -232,23 +232,11 @@
 
     Encoded string use only alpahnumeric characters, and "._-".
     '''
-    s = str(s)
-    if len(s) <= 57:
-        return translate(b2a_base64(s)[:-1], a2u_map)
-    frags = []
-    for i in range(0, len(s), 57):
-        frags.append(b2a_base64(s[i:i + 57])[:-1])
-    return translate(''.join(frags), a2u_map)
+    return translate(base64.encodestring(str(s)), a2u_map)
 
 def a2b(s):
     '''Decode a b2a-encoded string.'''
-    s = translate(s, u2a_map)
-    if len(s) <= 76:
-        return a2b_base64(s)
-    frags = []
-    for i in range(0, len(s), 76):
-        frags.append(a2b_base64(s[i:i + 76]))
-    return ''.join(frags)
+    return base64.decodestring(translate(s, u2a_map))
 
 def encodeExpansion(nodes, compress=1):
     '''Encode the expanded node ids of a tree into a string.
@@ -288,8 +276,9 @@
     if s[0] == ':': # Compressed state
         dec = zlib.decompressobj()
         s = dec.decompress(a2b(s[1:]), maxsize)
-        if dec.decompress('', 1):
+        if dec.unconsumed_tail:
             raise ValueError('Encoded node map too large')
+        del dec
     
     map = m = {}
     mstack = []


=== Zope/lib/python/ZTUtils/Zope.py 1.11.42.2 => 1.11.42.3 ===
--- Zope/lib/python/ZTUtils/Zope.py:1.11.42.2	Fri Oct 24 16:13:36 2003
+++ Zope/lib/python/ZTUtils/Zope.py	Thu Jan  8 18:34:04 2004
@@ -30,7 +30,7 @@
     Unauthorized = 'Unauthorized'
     def guarded_getitem(object, index):
         v = object[index]
-        if getSecurityManager().validate(object, object, index, v):
+        if getSecurityManager().validate(object, object, None, v):
             return v
         raise Unauthorized, 'unauthorized access to element %s' % `i`
 else:




More information about the Zope-Checkins mailing list