Skip to content
Tcl Source Code History Of Ticket 3027815
Login

History Of Ticket 3027815

Artifacts Associated With Ticket 3027815

  1. Ticket change [92df7d6db7] (rid 105719) by kjnash on 2010-07-10 15:26:41:

    1. assignee initialized to: "vasiljevic"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      A safe interpreter can load all the commands of the Thread package.  This is a security issue, because it means that a safe interpreter can create a new thread and send commands to that thread's unsafe master interpreter:
      
      % ::safe::interpCreate iSafe
      iSafe
      % iSafe eval pwd
      invalid command name "pwd"
      % iSafe eval {
          package require Thread
          set tid [thread::create]
          ::thread::send $tid {pwd}
      }
      /home/user
      %
      
      At present the safe entry point Thread_SafeInit gives a safe interpreter access to all the commands of the Thread extension.  For security reasons, at least some of these commands should be removed.
      
      Perhaps safe interpreters should not be allowed any access to Thread commands.  I am not familiar with the whole of the Thread package, but it appears that the natural scope of a thread operation is the master interpreter of the thread.  If a safe interpreter needs limited access to Thread commands, it might be best provided by wrapper commands aliased into the safe slave from its unsafe master - not by loading the Thread package itself.
      
      I suggest removing the safe entry point Thread_SafeInit completely.
      
      
    4. foundin initialized to: "obsolete: 8.5.8"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "kjnash"
    10. subsystem initialized to: "80. Thread Package"
    11. title initialized to:
      Safe interpreters can use Thread to execute unsafe commands
      
    12. type initialized to: "Bug"
  2. Ticket change [ee2828d809] (rid 104034) by vasiljevic on 2010-07-10 23:13:08:

    1. icomment:
      Interesting point. Actually I could ask Tcl_IsSafe(interp) of the
      interp that creates the thread (the one that calls thread::create)
      and inherit that state in the new thread so its interp is also safe.
      Would that make sense?
      
      
      
      
    2. login: "vasiljevic"
    3. mimetype: "text/plain"
    4. username: "vasiljevic"
  3. Ticket change [c8c3f330c7] (rid 122160) by dkf on 2010-07-12 04:41:02:

    1. icomment:
      I suggest making thread creation a restricted operation and that a safe interpreter should only be able to communicate with other interpreters that it's master has permitted it to do so to (which would require a new operation; sorry!)
      
      But really, it would be better if there was some way for the (non-safe) master to control messages sent (and what variables are shared, what mutexes are available, etc.) more thoroughly. I've tended to assume that it would be best if the thread extension simply wasn't marked as safe at all; let the master expose (safe) aliases to operations as necessary.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  4. Ticket change [aa05f67165] (rid 99251) by dkf on 2010-07-12 04:45:38:

    1. icomment:
      BTW, one safe context isn't the same as another because of the ability to grant exceptions to the rules via aliases. It's possible for there to be two sets of exceptions, each of which is safe on its own, but which are not safe in combination. (Child interpreters of safe interpreters are a special case; they start without any restricted operations at all and the parent safe interpreter can't change that.) It's not ever going to be safe to communicate between safe interps in different threads by default.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  5. Ticket change [d000413b6b] (rid 113090) by kjnash on 2010-07-13 23:35:26:

    1. icomment:
      > Interesting point. Actually I could ask Tcl_IsSafe(interp) of the
      > interp that creates the thread (the one that calls thread::create)
      > and inherit that state in the new thread so its interp is also safe.
      > Would that make sense?
      
      That's an interesting suggestion!  However, file/network interaction is normally added to a safe interpreter either by [interp alias] or by sharing sockets: in both cases the slave is configured by its master (or higher ancestor) in the same thread.  If there is no unsafe master, the slave would be of limited value, except for computation.
      
      If the Thread package were to add new mechanisms for using safe interpreters, I think it would create a lot of work for the developers of the Thread package, in particular the need to always be thinking about whether Thread facilities will allow a safe interpreter to execute commands in an unsafe interpreter (or, as Donal mentioned, a different kind of safe interpreter).
      
      However, such new mechanisms in Thread would not add much benefit, because safe interpreters are not widely used, and users will tend to use the safe-interpreter commands that they know, and will probably avoid using the new capabilities in Thread because any extra capabilities will introduce additional complications and security risks.
      
      Also, as far as I know, it is unprecedented to have a safe interpreter as the the root interpreter of a thread or process.  I don't know if it would break anything.  It would impact on development of the core, because the core developers would always have to consider the possibility that the root interpreter may be safe.
      
      I think the best solution is to remove the safe entry point Thread_SafeInit completely.  As Donal said, let the master expose (safe) aliases to operations as necessary.
      
      Keith.
      
      
      
    2. login: "kjnash"
    3. mimetype: "text/plain"
    4. username: "kjnash"
  6. Ticket change [8e464f6e60] (rid 120084) by vasiljevic on 2010-09-29 01:55:02:

    1. closedate changed to: "2010-09-28T18:55:02"
    2. closer changed to: "vasiljevic"
    3. icomment:
      
      
      allow_comments - 1
      
      This will now appoear in 2.6.7 patch release.
      
      
    4. login: "vasiljevic"
    5. mimetype: "text/plain"
    6. resolution changed to: "Accepted"
    7. status changed to: "Closed"
    8. username: "vasiljevic"