Uploaded image for project: 'mod_python'
  1. mod_python
  2. MODPYTHON-34

mod_python.publisher index.py exposes underscore prefixed variables

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 3.1.4
    • 3.2.7
    • publisher
    • None

    Description

      If index.py is used with mod_python.publisher, all underscore prefixed
      variables are actually visible and not hidden as they should. This could
      result in exposure of login/passwd information stored in _auth_ as a
      dictionary, plus any other private data in underscore prefixed variables.

      See following exchange from mailing list. This may require a security
      fix release.

      You have found a bug in mod_python.publisher. It shouldn't be visible,
      but the code which handles defaulting to "index.py" doesn't reapply the
      rule which stops access to "_" variables.

      Ie., early in code in publisher.py, it has a check:

      1. if any part of the path begins with "_", abort
        if func_path[0] == '' or func_path.count("."):
        raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND

      After that point though it has:

      try:
      module = apache.import_module(module_name,
      autoreload=autoreload,
      log=log,
      path=[path])
      except ImportError:
      et, ev, etb = sys.exc_info()

      1. try again, using default module, perhaps this is a
      2. /directory/function (as opposed to /directory/module/function)
        func_path = module_name
        module_name = "index"
        try:
        module = apache.import_module(module_name,
        autoreload=autoreload,
        log=log,
        path=[path])
        except ImportError:
      3. raise the original exception
        raise et, ev, etb

      Note how it resets the value of func_path. After that the code goes on
      to reolve the object, but the new func_path has skipped the check.

      I believe the fix would be for the "_" check to be after the import and
      not before.

      The only workaround you would have in the short term is not to use
      an "index.py" file and always name it something different.

      This is actually a security hole because any _auth_ stuff would
      be visible and thus people could work out login/passwd. This may
      require another security fix release of mod_python.

      Graham

      Jan Huelsbergen wrote ..
      > Hi,
      >
      > The mod_python.publisher documentation states at
      > http://modpython.org/live/current/doc-html/hand-pub-alg-trav.html that
      > if
      > "Any of the traversed object's names begin with an underscore ("_")."
      > they are not accsessable through the web, yet, when I put a
      > _foo = 'bar'
      > in my index.py, http://my.site/_foo returns 'bar'.
      >
      > Am I missinterpreting the documentation?
      > How to protect a variable from outside access?
      >
      > TIA

      Attachments

        Activity

          People

            nlehuen Nicolas Lehuen
            grahamd Graham Phillip Dumpleton
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: