Skip to content
Tcl Source Code History Of Ticket a63f5a4fed
Login

History Of Ticket a63f5a4fed

Artifacts Associated With Ticket a63f5a4fed

  1. Ticket change [0dc48976a1] (rid 258526) by serhiy.storchaka on 2026-10-17 10:51:11:

    1. cmimetype initialized to: "text/x-fossil-wiki"
    2. comment initialized to:
      When a command in a safe interpreter is an alias to a proc in a trusted parent and that proc
      fails, the full <tt>-errorinfo</tt> and <tt>-errorstack</tt> of the parent are copied into the
      safe interpreter. The safe interpreter then sees the parent's proc names, the text of their
      bodies, file names of sourced scripts and, through <tt>-errorstack</tt>, the actual argument
      values of every parent proc on the call stack.
      
      <verbatim>
      proc GetPassword {user} {return hunter2}
      proc VerifyPassword {user pw} {error "access denied"}
      proc LoginAlias {user} {VerifyPassword $user [GetPassword $user]}
      set s [interp create -safe]
      interp alias $s login {} LoginAlias
      puts [interp eval $s {
          catch {login alice} msg opts
          list $::errorInfo [dict get $opts -errorstack]
      }]
      </verbatim>
      
      Actual output (9.1, 9.0, 8.6):
      
      <verbatim>
      {access denied
          while executing
      "error "access denied""
          (procedure "VerifyPassword" line 1)
          invoked from within
      "VerifyPassword $user [GetPassword $user]"
          (procedure "LoginAlias" line 1)
          invoked from within
      "login alice"} {INNER {returnImm {access denied} {}} CALL {VerifyPassword alice hunter2} CALL {LoginAlias alice}}
      </verbatim>
      
      Expected: the safe interpreter sees only the error message and its own part of the traceback,
      as if <tt>login</tt> were a C command failing with that message:
      
      <verbatim>
      {access denied
          invoked from within
      "login alice"} {}
      </verbatim>
      If the alias target does <nowiki>[source]</nowiki> a file and the script fails, the traceback
      also contains <tt>(file "/full/path/of/the/parent/script.tcl" line N)</tt>.
      
      Cause: <tt>AliasObjCmd</tt> in generic/tclInterp.c calls <tt>Tcl_TransferResult</tt>, which
      copies the whole return options dictionary (<tt>Tcl_GetReturnOptions</tt>) of the parent into
      the child, whether the child is safe or not. The Safe Base avoids this only because its alias
      procs rethrow with <nowiki>[return -code error $msg]</nowiki>; user-defined aliases get no such
      protection. A possible fix is to drop <tt>-errorinfo</tt> and <tt>-errorstack</tt> (keeping the
      message, <tt>-errorcode</tt> and the return code) when the target interpreter is safe and the
      source is not.
      
      This is the knownBug test interp-26.8, one of the tests collected in [219164ffff] (bug 1637,
      1999). The errorInfo part has been there at least since 8.4; <tt>-errorstack</tt> (8.6) made it
      worse, since it carries argument values. Related: [77f0dbc0f8] (a stale <tt>-errorstack</tt>
      from an earlier, already caught error in the parent is also passed through an alias, because
      <tt>Tcl_GetReturnOptions</tt> ignores <tt>resetErrorStack</tt>), [1669424fff] (file names leak
      into safe interps via <nowiki>[info frame]</nowiki>).
      
    3. foundin initialized to: "8.6.18, 9.0.5, 9.1.0"
    4. login: "serhiy.storchaka"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. severity initialized to: "Important"
    8. status initialized to: "Open"
    9. subsystem initialized to: "20. [interp]"
    10. title initialized to:
      Safe interp gets the parent's -errorinfo and -errorstack through a failing alias
      
    11. type initialized to: "Bug"
  2. Ticket change [8157db24a5] (rid 258564) by serhiy.storchaka on 2026-10-17 11:50:46:

    1. icomment:
      Proposed fix in branch [/timeline?r=safe-interp-no-parent-traceback|safe-interp-no-parent-traceback]: <tt>Tcl_TransferResult()</tt> no longer transfers <tt>-errorinfo</tt>, <tt>-errorstack</tt> and <tt>-errorline</tt> from a trusted interp to a safe one; the message, <tt>-errorcode</tt> and the return code still pass. The safe interp starts its own traceback at the alias call. knownBug test interp-26.8 now passes, new test interp-26.10; four safe.test tests that expected part of the parent's traceback are updated.
      
      This also fixes the safe interp part of [77f0dbc0f8]. It is a behaviour change of a public function, so it is proposed for 9.1 only.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
  3. Ticket change [6cbb22bb5c] (rid 259531) by serhiy.storchaka on 2026-10-20 18:11:28:

    1. submitter changed to: "serhiy.storchaka"
  4. Ticket change [60b4c1556c] (rid 259593) by jan.nijtmans on 2026-10-20 21:11:13:

    1. assignee changed to: "jan.nijtmans"
    2. closer changed to: "nobody"
    3. comment changed to:
      When a command in a safe interpreter is an alias to a proc in a trusted parent and that proc
      fails, the full <tt>-errorinfo</tt> and <tt>-errorstack</tt> of the parent are copied into the
      safe interpreter. The safe interpreter then sees the parent's proc names, the text of their
      bodies, file names of sourced scripts and, through <tt>-errorstack</tt>, the actual argument
      values of every parent proc on the call stack.
      
      <verbatim>
      proc GetPassword {user} {return hunter2}
      proc VerifyPassword {user pw} {error "access denied"}
      proc LoginAlias {user} {VerifyPassword $user [GetPassword $user]}
      set s [interp create -safe]
      interp alias $s login {} LoginAlias
      puts [interp eval $s {
          catch {login alice} msg opts
          list $::errorInfo [dict get $opts -errorstack]
      }]
      </verbatim>
      
      Actual output (9.1, 9.0, 8.6):
      
      <verbatim>
      {access denied
          while executing
      "error "access denied""
          (procedure "VerifyPassword" line 1)
          invoked from within
      "VerifyPassword $user [GetPassword $user]"
          (procedure "LoginAlias" line 1)
          invoked from within
      "login alice"} {INNER {returnImm {access denied} {}} CALL {VerifyPassword alice hunter2} CALL {LoginAlias alice}}
      </verbatim>
      
      Expected: the safe interpreter sees only the error message and its own part of the traceback,
      as if <tt>login</tt> were a C command failing with that message:
      
      <verbatim>
      {access denied
          invoked from within
      "login alice"} {}
      </verbatim>
      If the alias target does <nowiki>[source]</nowiki> a file and the script fails, the traceback
      also contains <tt>(file "/full/path/of/the/parent/script.tcl" line N)</tt>.
      
      Cause: <tt>AliasObjCmd</tt> in generic/tclInterp.c calls <tt>Tcl_TransferResult</tt>, which
      copies the whole return options dictionary (<tt>Tcl_GetReturnOptions</tt>) of the parent into
      the child, whether the child is safe or not. The Safe Base avoids this only because its alias
      procs rethrow with <nowiki>[return -code error $msg]</nowiki>; user-defined aliases get no such
      protection. A possible fix is to drop <tt>-errorinfo</tt> and <tt>-errorstack</tt> (keeping the
      message, <tt>-errorcode</tt> and the return code) when the target interpreter is safe and the
      source is not.
      
      This is the knownBug test interp-26.8, one of the tests collected in [219164ffff] (bug 1637,
      1999). The errorInfo part has been there at least since 8.4; <tt>-errorstack</tt> (8.6) made it
      worse, since it carries argument values. Related: [77f0dbc0f8] (a stale <tt>-errorstack</tt>
      from an earlier, already caught error in the parent is also passed through an alias, because
      <tt>Tcl_GetReturnOptions</tt> ignores <tt>resetErrorStack</tt>), [1669424fff] (file names leak
      into safe interps via <nowiki>[info frame]</nowiki>).
      
    4. icomment:
      > It is a behaviour change of a public function, so it is proposed for 9.1 only.
      
      Since it's a potential security risk, I'm inclined to accept it for 9.0.
      
      Just go ahead!
      
    5. login: "jan.nijtmans"
    6. mimetype: "text/x-fossil-wiki"
  5. Ticket change [1f2341b7f9] (rid 259594) by jan.nijtmans on 2026-10-20 21:12:08:

    1. icomment:
      > It is a behaviour change of a public function, so it is proposed for 9.1 only.
      
      Since it's a potential security risk, I'm inclined to accept it for 9.0 and 8.6 too.
      
      Just go ahead!
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  6. Ticket change [0317a9f699] (rid 259612) by serhiy.storchaka on 2026-10-20 21:22:39:

    1. icomment:
      Merged to [24b65a6fb6|trunk], [19a0f244cb|core-9-0-branch] and [cc7f58c2fd|core-8-6-branch]. On 9.0 and 8.6 the expected results of interp-26.10 (<code>invokeStk1</code>) and, on 8.6, safe-11.7.1 (no parent frame any more) were adjusted.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  7. Ticket change [de17c90707] (rid 259614) by jan.nijtmans on 2026-10-20 21:24:41:

    1. closedate changed to: "2461334.3921422223"
    2. closer changed to: "jan.nijtmans"
    3. icomment: "Please don't forget the changes.md/changes entries"
    4. login: "jan.nijtmans"
    5. mimetype: "text/x-fossil-wiki"