Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b2eb05755bf1fd7518216cfcf908a696a0ba445487eb2980a616f77ac0165de8
Ticket: 2917673fffffffffffffffffffffffffffffffff
Behavior of Safe Base
User & Date: kjnash on 2020-07-20 23:53:36
Changes

  1. closer changed to: "nobody"
  2. comment changed to:
    According to the documentation, Safe Base should not allow subdirectory access.
    > The only valid file names arguments for the source and load aliases provided to the slave are path in the form of [file join token filename] (i.e. when using the native file path formats: token/filename on Unix and token\filename on Windows), where token is representing one of the directories of the accessPath list and filename is one file in that directory (no sub directories access are allowed).
    
    But this breaks the loading of Tcl modules (tm) with a ::, (the :: is translated to the directory separator).
    
    So nested directories have been allowed for source, load, and glob.
    
    But for the normal auto_path, witch search also in subdirectories, we add each subdirectory into the accessPath and forbid the search for pkgIndex.tcl, so we don't have the same package 2 times.
    
    I think this is not a good approach.
    
    I think, we should general allow that subdirectories can be searched
    
  3. icomment:
    I believe this problem was solved a while ago (by dkf's safe::AliasGlob).  The de-fanged glob used in Safe Base interpreters can see files in a subdirectory of an access-path directory, but only if the subdirectory is itself a part of the access path.
    
    The report is correct that
    <verbatim>
       1) The same file can be accessed by different paths, like $p(:0:)/foo/bar.tcl and $p(:1:)/bar.tcl
    This means that the directory structure is not protected.
    </verbatim>
    
    There is a little leakage of information - in this example the safe interpreter can figure out that directory {$p(:0:)/foo} is tokenized as {$p(:1:)}; but this information does not appear to pose a security risk, and is inevitable if Safe Base interpreters are to have access to modules.
    
    <verbatim>
       2) If I want to allow a safe interp to access a given directory, I usually need [file] (no problem, the new have to be compatible with the normal safe [file] command), [open] (not exposed) and [glob]. Writing a compatible [glob] is only possible with introspection ([interp alias $slave glob]) or other complex techniques.
    </verbatim>
    
    The safe::AliasGlob command now does most of its analysis in the master interpreter, and is careful to ensure that both the arguments supplied by the safe interpreter, and the result returned to it, belong to the interpreter's access path.
    
    <verbatim>
        Currently a problem is that you could load a tm module called tcl::chan::fifo as chan::fifo.
    </verbatim>
    
    This problem is fixed in [951cd4cdfa7e1].
    
    Does this resolve the bug report?
    
  4. login: "kjnash"
  5. mimetype: "text/x-fossil-wiki"
  6. severity changed to: "Minor"