return -level not caught at safe interp boundary
Closed / Invalid2000565fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-06-23 08:06:51
It seems the -level option of [return] has the power to cross interpreter boundaries, even that from a safe interpreter to its master:
% info patchlevel
8.5.2
% interp create -safe test
test
% catch {test eval {return -level 3 foo}} res info
2
% set res
foo
% set info
-code 0 -level 2
Doesn't this constitute a security hole? If we have a proc like
proc eval_and_check {script} {
set res [interp slave eval $script]
validate_res_allowed $res
return $res
}
then the $script can fool the caller of [eval_and_check] to accept anything by [return]ing it at the level of [eval_and_check].
dkf Ticket [2000565fff]: 2 changes
[History diff]2008-06-23 15:12:25
dgpplain2008-06-23 21:34:13
Logged In: YES
user_id=80530
Originator: NO
Adding [return -level] did not add
any new security concerns. Tcl 8.4
already had [return -code return]:
% info patch
8.4.19
% interp create slave
slave
% catch {slave eval {return -code return}} m
2
If you permit a slave interp to evaluate
an unknown, untrusted script, you must
[catch] the evaluation, and be prepared to
handle any return code it might throw back
at you. That's been true as long as there
have been slave interps.
Log in (anonymous is fine) to add a comment.