<?xml version="1.0" encoding="windows-1252"?>
<node id="127370" title="Trojan Horse? (taint mode)" created="2001-11-25 05:44:46" updated="2005-07-21 01:28:47">
<type id="115">
perlquestion</type>
<author id="81630">
IraTarball</author>
<data>
<field name="doctext">
I was reading &lt;a href='http://www.oreilly.com/catalog/advperl/'&gt;Advanced Perl Programming&lt;/a&gt; and came across this little warning about 
double quote interpolation.  
&lt;a href='http://www.oreilly.com/catalog/advperl/author.html'&gt;The author&lt;/a&gt; warns that a string like &lt;code&gt;"$a"&lt;/code&gt; does variable interpolation.  No surprise there.  Then he say's &lt;i&gt;"But you now know that "a" can be replaced ba a block as long as it returns a reference to a scalar..."&lt;/i&gt; and so we should be worried about someone filling a variable with &lt;code&gt;{system('/bin/rm -rf /*')}&lt;/code&gt; and maybe doing 'bad things' to us.  
&lt;p&gt;
Now for the question. &lt;p&gt;
Isn't a variable only interpolated once?  I mean, when I try the following...
&lt;code&gt;
perl -swe 'while (&lt;STDIN&gt;) {print "$_"}'
&lt;/code&gt;
and I type in &lt;code&gt;{system('rm -rf *')}&lt;/code&gt; it just prints &lt;code&gt;{system('rm -rf *')}&lt;/code&gt; without executing the system call. This is just what I would have expected before reading the quoted material.  Am I missing something though?
&lt;p&gt;
Along these lines, I'm under the impression that tainted data is mainly a concern if you're going to &lt;code&gt;eval&lt;/code&gt; it, or pass it to &lt;code&gt;system&lt;/code&gt; or backticks, are there any really sneaky situations that I'm missing?  
&lt;p&gt;
The reason the above caught my attention was that it implied that every program where I echo user input would need to be run in [taint] mode.  I think that would suck. 

&lt;p&gt;
What do &lt;i&gt;you&lt;/i&gt; think?
&lt;p&gt;
&lt;A HREF="/index.pl?node=IraTarball&amp;amp;amp;amp;amp;amp;lastnode_id=479"&gt;Ira&lt;/a&gt;,
&lt;p&gt;&lt;i&gt;
"So... What do all these little arrows mean?"&lt;br&gt;
~unknown&lt;/i&gt;</field>
</data>
</node>
