perl.perl5.porters http://www.nntp.perl.org/group/perl.perl5.porters/ ... Copyright 1998-2008 perl.org Sun, 27 Jul 2008 09:19:48 +0000 ask@perl.org Re: [perl #2783] Security of ARGV using 2-argument open -It'safeature by Abigail On Sat, Jul 26, 2008 at 08:59:59AM +0000, Ed Avis wrote:<br/>&gt; Mark Mielke &lt;mark &lt;at&gt; mark.mielke.cc&gt; writes:<br/>&gt; <br/>&gt; &gt;What legitimate scenarios use files with names &quot;&lt;x&quot;?<br/>&gt; <br/>&gt; Very few. But if such a filename does exist, you&#39;d want the program to handle<br/>&gt; it in a sane way.<br/>&gt; <br/>&gt; Unfortunately the world is not always legitimate. Every program using while<br/>&gt; (&lt;&gt;) has to come with a health warning that it is unsafe to use unless you kno<br/>&gt; that no &gt;&lt;| characters are contained in the filenames.<br/>&gt; <br/>&gt; Remember gets() in the standard C library? What&#39;s the problem with it? No<br/>&gt; legitimate use would ever enter a million characters of text when given a prom<br/>&gt; to enter &#39;yes&#39; or &#39;no&#39;. And if users are so stupid as to enter too much text<br/>&gt; and overflow the fixed buffer, that is a problem with the users and they shoul<br/>&gt; be educated to take more care.<br/>&gt; <br/>&gt; Yet today, gets() is deprecated and nobody uses it - whether writing &#39;security<br/>&gt; code&#39; or not. It is just too dangerous.<br/><br/>I think gets() is an excellent example.<br/><br/>Guess what? gets() in the current C library is still the same as it was long<br/>time ago. The functionality of gets() didn&#39;t change. Additional functionality,<br/>using a different name was used.<br/><br/>Perl went this way as well. 3-arg open already exists.<br/><br/><br/>Abigail<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138790.html Sun, 27 Jul 2008 00:46:20 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by jvromans [Quoting Mark Mielke, on July 26 2008, 21:06, in &quot;Re: [perl #2783] Sec&quot;]<br/>&gt; This hardly constitutes evidence. It is your guess. That you haven&#39;t <br/>&gt; been able to point to a real-life scenario of this issue being a problem <br/>&gt; suggests to me that your guess is wrong.<br/><br/>Sleep well, Mark.<br/><br/>-- Johan<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138789.html Sat, 26 Jul 2008 23:00:38 +0000 Re: [perl #57322] perlbug AutoReply: ungetc() to :scalar might cause problems by Goro Fuji Oh, I forgot to attach the files.<br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138788.html Sat, 26 Jul 2008 22:37:59 +0000 Re: [perl #2783] Security of ARGV using 2-argument open -It'safeature by Aristotle Pagaltzis * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-27 04:00]:<br/>&gt; The assumption that users are using &quot;&gt;&quot;, &quot;&lt;&quot;, or &quot;|&quot; as the<br/>&gt; first or last would seem to be proven false<br/><br/>1. Absence of evidence is not evidence of absence.<br/><br/>2. *I* never assumed that *users* would do this. What I *did*<br/> assume is that malicious attackers might be able to exploit<br/> sloppy code to create such files in places where subsequently<br/> a script using `while (&lt;&gt;)` can pick them up, presumably<br/> running under a different user name, thus allowing escalation<br/> of privilege.<br/><br/> (Unfortunately `while (&lt;&gt;)` encapsulates so much convenient<br/> functionality all at once (opening of multiple files, nice<br/> error reporting, a special case for empty @ARGV, etc) that<br/> when put together with the 2-arg open hazard, it ends up being<br/> an attractive nuisance.)<br/><br/> You&rsquo;ll hopefully understand that I cannot give you any<br/> reliable data about how often attackers do this on my systems;<br/> if I knew of such cases I wouldn&rsquo;t be faffing around on p5p.<br/><br/>Regards,<br/>-- <br/>Aristotle Pagaltzis // &lt;http://plasmasturm.org/&gt;<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138787.html Sat, 26 Jul 2008 20:17:06 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke For the record, though -<br/><br/>Making &lt;&gt; use 3-argument open with &quot;r&quot; will not break any of my programs <br/>that I have ever written, and I don&#39;t think anybody who uses my programs <br/>would rely on the 2-argument open &quot;feature&quot;, as I usually de-emphasize <br/>the Perl nature of my programs, and the programs are not primarily used <br/>by advanced Perl programmers. :-)<br/><br/>The problem I have is the desire to significantly change Perl 5 by new <br/>comers. Perl 5 is a foundation at this point. Even back at Perl 5.004, <br/>compatibility was important. With Perl 5.10 I expect things to be <br/>slowing down, not speeding up. Perl 6 is the major change. Feel free to <br/>ensure that Perl 6 does not include a 2-arg open().<br/><br/>The feature under discussion has existed for as long as I remember using <br/>Perl. This suggests to me 1992 or earlier. I&#39;ve known how it has worked, <br/>and never experienced a problem with it since then. The idea that in <br/>2008 it would suddenly be a huge issue is a bit unbelievable to me.<br/><br/>I totally agree that users should be using 3-arg open wherever possible, <br/>and that programs with security concerns should use taint-mode checking, <br/>and that taint-mode checking should flag &lt;&gt; as a potential problem.<br/><br/>I disagree that existing behaviour needs to be broken to satisfy the <br/>above, or that more than the above is necessary.<br/><br/>This is just one feature of many I&#39;ve seen lately that has raised my <br/>concern. This particular feature on its own doesn&#39;t matter to me. Many <br/>similar changes that will eventually ensure that some program I have <br/>running on Perl 5.004 or Perl 5.6 today, will stop working in Perl 5.10 <br/>tomorrow, concerns me greatly. At present, Perl 5.6 is widely used on <br/>our Solaris machines, Perl 5.8 is widely used on our Linux and Windows <br/>machines, but Perl 5.004 is still used on some of our older HP-UX and <br/>Solaris machines. My programs already have Perl versions checks that <br/>adjust behaviour. I am not keen to add more. Compatibility is very <br/>important. If RHEL 6.x begins providing Perl 5.10, and a user begins <br/>using Perl 5.10 in our application, I don&#39;t want to be screwed. I hope <br/>this concern can be understood by the newcomers. I believe it is already <br/>well understood by the old timers.<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138786.html Sat, 26 Jul 2008 19:25:13 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Aristotle Pagaltzis wrote:<br/>&gt; * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-27 03:10]:<br/>&gt; <br/>&gt;&gt; Again, what is the worst that can really happen? So the user is<br/>&gt;&gt; able to access a resource that they already have permission<br/>&gt;&gt; to. So what? There are so many ways to get a user to screw up<br/>&gt;&gt; <br/>&gt;<br/>&gt; Do you regard symlink attacks as a hole in the respective<br/>&gt; software? If so, please explain to me how your opinion in that<br/>&gt; case is not self-contradictory with the opinion you expressed<br/>&gt; above.<br/>&gt; <br/><br/>I don&#39;t understand the question. If it is a reference to a comparison <br/>between different types of exploits for code that was written by an <br/>amateur or that does not have taint-mode checking enabled, I&#39;m not <br/>convinced that this is a serious problem compared to others, or that <br/>others need to be fixed. In the other poster&#39;s example, I don&#39;t agree <br/>that gets() should be removed from libc, just because it can be <br/>exploited. I&#39;m happy with gcc warnings listing it as a security concern <br/>when requested. Perl&#39;s taint-mode provides this feature and more.<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138785.html Sat, 26 Jul 2008 19:03:34 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Aristotle Pagaltzis wrote:<br/>&gt;&gt; Good. This is interesting. Please report back on the number of<br/>&gt;&gt; actual files in 1988, 1998, and 2008, that use &quot;&gt;&quot;, &quot;&lt;&quot;, or<br/>&gt;&gt; &quot;|&quot; as the first or last character in the file name.<br/>&gt;&gt; <br/>&gt;<br/>&gt; You&rsquo;re being onery on purpose, but I&rsquo;ll humour you: I found none<br/>&gt; of those, but a handful of files with spaces at the beginning of<br/>&gt; their name. Thanks for playing.<br/>&gt; <br/><br/>With real metrics, the conclusion would seem to be that 2-arg open or <br/>implicit 2-arg open via &lt;&gt; should at least deal with filenames that <br/>begin with spaces at the beginning.<br/><br/>The assumption that users are using &quot;&gt;&quot;, &quot;&lt;&quot;, or &quot;|&quot; as the first or <br/>last would seem to be proven false, at least in the one case you are <br/>able to measure. Given that you have the data, can you also check <br/>whether &quot;http:&quot; or &quot;file:&quot; is ever the prefix for a file name?<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138784.html Sat, 26 Jul 2008 18:56:55 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Aristotle Pagaltzis wrote:<br/>&gt; * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-27 03:20]:<br/>&gt; <br/>&gt;&gt; Feel free to educate me by pointing to a situation where open()<br/>&gt;&gt; handling http:// makes a PHP script exploitable, where blocking<br/>&gt;&gt; http:// would have made the PHP script impenetrable.<br/>&gt;&gt; <br/>&gt;<br/>&gt; PHP `require` uses `open`.<br/>&gt; <br/><br/>Be more specific please. You seem to be referencing some sort of <br/>&quot;require $variable;&quot; where $variable is from an external source. None of <br/>the PHP code I have does this. If you mean something else, please be <br/>more specific. If you mean to suggest that &quot;require $variable;&quot; is <br/>common - I would find this surprising.<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138783.html Sat, 26 Jul 2008 18:53:09 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It's afeature by Mark Mielke Aristotle Pagaltzis wrote:<br/>&gt; * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-27 03:10]:<br/>&gt; <br/>&gt;&gt; This logic does not follow. That the shell provides a feature,<br/>&gt;&gt; therefore Perl does not need to provide the feature, is pretty<br/>&gt;&gt; backwards thinking in my opinion. You need to provide<br/>&gt;&gt; something more substantial than this.<br/>&gt;&gt; <br/>&gt; Asserting that I have to doesn&rsquo;t make it so. Please give me a use<br/>&gt; case for 2-arg open magic using implicitly from the command line<br/>&gt; that cannot be implemented with process substitution, or can only<br/>&gt; be implemented with process substitution with significantly more<br/>&gt; difficulty. If you can&rsquo;t, then my assertion is correct.<br/>&gt; <br/><br/>No. Your assertion misses the point. The shell provides an echo command. <br/>Since the shell provides an echo command that maps similar to the perl <br/>print function, and since one can always convert perl -e print to echo, <br/>therefore print is not required in Perl. Right? I don&#39;t think so.<br/><br/>That the shell provides a function is NOT evidence that Perl should not. <br/>You&#39;ve already agreed that &quot;-&quot; provides value. Beyond this, it comes to <br/>opinion as to whether the function provides value in Perl, or whether it <br/>is a waste in Perl. A Windows COMMAND.COM user might like the <br/>flexibility provided by Perl implicit 2-arg open, as COMMAND.COM does <br/>not provide all of the same functions. There are other variations that <br/>are possible, although not necessarily any more real than the problems <br/>claimed, such as the ability to ensure that the next 2-arg open is only <br/>executed once the previous 2-arg open is read successfully. For example:<br/><br/> ( expensive command 1; expensive command 2; ) | perl -ne &#39;if (/bad/) <br/>{ die }&#39;<br/><br/>Vs:<br/><br/> perl -ne &#39;if (/bad/) { die }&#39; &#39;expensive command 1 |&#39; &#39;expensive <br/>command 2 |&#39;<br/><br/>I don&#39;t think the above are legitimate uses, but then, I don&#39;t think &lt;&gt; <br/>is a real operator to be used by a complex program.<br/><br/>&gt;&gt; Specifically, point out a place where the existing behaviour is<br/>&gt;&gt; causing a *real* problem.<br/>&gt;&gt; <br/>&gt;<br/>&gt; If the feature is no longer pulling its weight, then the burden<br/>&gt; of proof is on your side, not mine.<br/>&gt;<br/>&gt; So go ahead: what use case does the feature solve?<br/>&gt; <br/><br/>Incorrect. Compatibility itself is a strong reason to keep a feature. <br/>You need to prove that: a) the feature provides substantial harm (either <br/>in terms of maintenance effort or support issues), b) by removing or <br/>restricting the feature, you will provide a benefit of some sort <br/>(reduced maintenance effort or reduced support issues), and c) that the <br/>feature is not relied on by other people and existing code will not break<br/><br/>I don&#39;t think you&#39;ve succeeded any of these three. I&#39;m not convinced <br/>that this is a real problem. I&#39;m not convinced that &quot;fixing&quot; it will <br/>reduce the maintenance cost or support issues, and I&#39;m not convinced <br/>that the features are no longer in use.<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138782.html Sat, 26 Jul 2008 18:51:03 +0000 Re: [perl #2783] Security of ARGV using 2-argument open -It'safeature by Aristotle Pagaltzis * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-27 03:20]:<br/>&gt; Aristotle Pagaltzis wrote:<br/>&gt;&gt; Yes. The filenames in home directories on servers I<br/>&gt;&gt; administrate today are brimming with spaces, parens and square<br/>&gt;&gt; brackets. And those are from Windows users, who mount their<br/>&gt;&gt; home directories on their Windows machine or use SFTP or such<br/>&gt;&gt; to shuttle files around. No one (in relative terms) uses Unix<br/>&gt;&gt; without a desktop environment anymore either. Now what<br/>&gt;&gt; characters that Windows users cannot type in Save As do you<br/>&gt;&gt; think are a problem in GNOME or KDE? Question marks? Colons?<br/>&gt;&gt; Asterisks?<br/>&gt;<br/>&gt; Good. This is interesting. Please report back on the number of<br/>&gt; actual files in 1988, 1998, and 2008, that use &quot;&gt;&quot;, &quot;&lt;&quot;, or<br/>&gt; &quot;|&quot; as the first or last character in the file name.<br/><br/>You&rsquo;re being onery on purpose, but I&rsquo;ll humour you: I found none<br/>of those, but a handful of files with spaces at the beginning of<br/>their name. Thanks for playing.<br/><br/>Regards,<br/>-- <br/>Aristotle Pagaltzis // &lt;http://plasmasturm.org/&gt;<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138781.html Sat, 26 Jul 2008 18:49:11 +0000 Re: [perl #2783] Security of ARGV using 2-argument open -It'safeature by Aristotle Pagaltzis * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-27 03:20]:<br/>&gt; Feel free to educate me by pointing to a situation where open()<br/>&gt; handling http:// makes a PHP script exploitable, where blocking<br/>&gt; http:// would have made the PHP script impenetrable.<br/><br/>PHP `require` uses `open`.<br/><br/>Regards,<br/>-- <br/>Aristotle Pagaltzis // &lt;http://plasmasturm.org/&gt;<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138780.html Sat, 26 Jul 2008 18:44:26 +0000 Re: [perl #2783] Security of ARGV using 2-argument open -It'safeature by Aristotle Pagaltzis * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-27 03:10]:<br/>&gt; Again, what is the worst that can really happen? So the user is<br/>&gt; able to access a resource that they already have permission<br/>&gt; to. So what? There are so many ways to get a user to screw up<br/><br/>Do you regard symlink attacks as a hole in the respective<br/>software? If so, please explain to me how your opinion in that<br/>case is not self-contradictory with the opinion you expressed<br/>above.<br/><br/>Regards,<br/>-- <br/>Aristotle Pagaltzis // &lt;http://plasmasturm.org/&gt;<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138779.html Sat, 26 Jul 2008 18:41:33 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It's afeature by Aristotle Pagaltzis * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-27 03:10]:<br/>&gt; Aristotle Pagaltzis wrote:<br/>&gt;&gt; Modern shells already have process substitution, which can<br/>&gt;&gt; do anything a user could do with magical filenames and more<br/>&gt;&gt; besides. *That* is a homogenous approach to argument processing,<br/>&gt;&gt; and you are absolutely right: it&rsquo;s a BIG FAT FEATURE. So what is<br/>&gt;&gt; the value of retaining an API that can and does surprise people<br/>&gt;&gt; in nasty ways in exchange for no added functionality whatsoever?<br/>&gt;&gt;<br/>&gt;&gt; The *only* reason to keep that API is backwards compatibility.<br/>&gt;&gt; It&rsquo;s a good reason to be sure, but I would prefer a way forward<br/>&gt;&gt; that satisfies that demand without perpertuating the vestigial<br/>&gt;&gt; pragmatics of yesteryear for all eternity and a day beyond.<br/>&gt;&gt; <br/>&gt;<br/>&gt; This logic does not follow. That the shell provides a feature,<br/>&gt; therefore Perl does not need to provide the feature, is pretty<br/>&gt; backwards thinking in my opinion. You need to provide<br/>&gt; something more substantial than this.<br/><br/>Asserting that I have to doesn&rsquo;t make it so. Please give me a use<br/>case for 2-arg open magic using implicitly from the command line<br/>that cannot be implemented with process substitution, or can only<br/>be implemented with process substitution with significantly more<br/>difficulty. If you can&rsquo;t, then my assertion is correct.<br/><br/>&gt; Specifically, point out a place where the existing behaviour is<br/>&gt; causing a *real* problem.<br/><br/>If the feature is no longer pulling its weight, then the burden<br/>of proof is on your side, not mine.<br/><br/>So go ahead: what use case does the feature solve?<br/><br/>Regards,<br/>-- <br/>Aristotle Pagaltzis // &lt;http://plasmasturm.org/&gt;<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138778.html Sat, 26 Jul 2008 18:36:45 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Aristotle Pagaltzis wrote:<br/>&gt; * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-26 22:30]:<br/>&gt; <br/>&gt;&gt; More people use rich file system identifiers these days than<br/>&gt;&gt; UNIX file system. On Windows, it will happily accept http://<br/>&gt;&gt; vs ftp:// vs file:// vs \\host\share in many of the &quot;open<br/>&gt;&gt; file&quot; dialogs. This is a good thing, and the trend should<br/>&gt;&gt; continue. PHP already supports this in their open functions<br/>&gt;&gt; and this is widely understood to be a major feature.<br/>&gt;&gt; <br/>&gt;<br/>&gt; Yes, it reduces the amount of work necessary to hack sites<br/>&gt; written by PHP neophytes so much. All crackers agree, it&rsquo;s the<br/>&gt; coolest feature ever.<br/>&gt; <br/><br/>No - I don&#39;t think so. The crackers likely agree that eval or <br/>non-escaped literal substitution are the coolest features ever. I&#39;m not <br/>sure why http:// would make the list. Feel free to educate me by <br/>pointing to a situation where open() handling http:// makes a PHP <br/>script exploitable, where blocking http:// would have made the PHP <br/>script impenetrable.<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138777.html Sat, 26 Jul 2008 18:19:36 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Aristotle Pagaltzis wrote:<br/>&gt; * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-26 18:00]:<br/>&gt; <br/>&gt;&gt; Do you have evidence? Perhaps a list of filenames from 1988,<br/>&gt;&gt; 1998, and 2008, to compare against?<br/>&gt;&gt; <br/>&gt;<br/>&gt; Yes. The filenames in home directories on servers I administrate<br/>&gt; today are brimming with spaces, parens and square brackets. And<br/>&gt; those are from Windows users, who mount their home directories on<br/>&gt; their Windows machine or use SFTP or such to shuttle files<br/>&gt; around. No one (in relative terms) uses Unix without a desktop<br/>&gt; environment anymore either. Now what characters that Windows<br/>&gt; users cannot type in Save As do you think are a problem in GNOME<br/>&gt; or KDE? Question marks? Colons? Asterisks?<br/>&gt; <br/><br/>Good. This is interesting. Please report back on the number of actual <br/>files in 1988, 1998, and 2008, that use &quot;&gt;&quot;, &quot;&lt;&quot;, or &quot;|&quot; as the first or <br/>last character in the file name.<br/><br/>Thanks,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138776.html Sat, 26 Jul 2008 18:17:09 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Aristotle Pagaltzis wrote:<br/>&gt; * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-25 23:15]:<br/>&gt; <br/>&gt;&gt; How many people have been &quot;burned&quot; by this &quot;problem&quot;? Is the<br/>&gt;&gt; new class of dimwits exceedingly more dimwitted than the<br/>&gt;&gt; previous? Why was this not a problem 10 years ago?<br/>&gt;&gt; <br/>&gt;<br/>&gt; Just because you didn&rsquo;t hear about it before doesn&rsquo;t mean no one<br/>&gt; else knew of it. I&rsquo;ve been preaching the use of 3-arg open ever<br/>&gt; since it was introduced, and I&rsquo;ve known of the diamond operator&rsquo;s<br/>&gt; problem for just as long.<br/>&gt; <br/><br/>I think you misunderstand. I also agreed with 3-arg open ever since it <br/>was introduced.<br/><br/>What I don&#39;t agree with, is that 2-arg open should be &quot;broken&quot; because <br/>of a fear that somebody somewhere might be burned. As for &lt;&gt;, it&#39;s much <br/>to trivial for any serious program with complex requirements, so I find <br/>it questionable that the subset is as serious of a concern as some <br/>people are making it out to be. eval &quot;&quot; is dangerous as well. Would you <br/>suggest blocking it as well?<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138775.html Sat, 26 Jul 2008 18:15:55 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It's afeature by Mark Mielke Aristotle Pagaltzis wrote:<br/>&gt; Modern shells already have process substitution, which can<br/>&gt; do anything a user could do with magical filenames and more<br/>&gt; besides. *That* is a homogenous approach to argument processing,<br/>&gt; and you are absolutely right: it&rsquo;s a BIG FAT FEATURE. So what is<br/>&gt; the value of retaining an API that can and does surprise people<br/>&gt; in nasty ways in exchange for no added functionality whatsoever?<br/>&gt;<br/>&gt; The *only* reason to keep that API is backwards compatibility.<br/>&gt; It&rsquo;s a good reason to be sure, but I would prefer a way forward<br/>&gt; that satisfies that demand without perpertuating the vestigial<br/>&gt; pragmatics of yesteryear for all eternity and a day beyond.<br/>&gt; <br/><br/>This logic does not follow. That the shell provides a feature, therefore <br/>Perl does not need to provide the feature, is pretty backwards thinking <br/>in my opinion. You need to provide something more substantial than this.<br/><br/>Specifically, point out a place where the existing behaviour is causing <br/>a *real* problem.<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138774.html Sat, 26 Jul 2008 18:09:00 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Johan Vromans wrote:<br/>&gt; Mark Mielke &lt;mark@mark.mielke.cc&gt; writes<br/>&gt;&gt; Do you have evidence? Perhaps a list of filenames from 1988, 1998, and<br/>&gt;&gt; 2008, to compare against?<br/>&gt;&gt; <br/>&gt;<br/>&gt; Ah, come on. There are many more people in 2008 using some Linux with<br/>&gt; Firefox, Thunderbird and OpenOffice than there were in 1998 and 1988.<br/>&gt; There are many more people in 2008 using some Linux totally unaware of<br/>&gt; command line shells and special characters than there were in 1998 and<br/>&gt; 1988. The chances that files with special characters in their names<br/>&gt; are created is therefore bigger in 2008 than they were in 1998 and<br/>&gt; 1988<br/><br/>This hardly constitutes evidence. It is your guess. That you haven&#39;t <br/>been able to point to a real-life scenario of this issue being a problem <br/>suggests to me that your guess is wrong.<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138773.html Sat, 26 Jul 2008 18:06:22 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Andy Armstrong wrote:<br/>&gt; On 26 Jul 2008, at 21:29, Mark Mielke wrote:<br/>&gt;&gt; More people use rich file system identifiers these days than UNIX <br/>&gt;&gt; file system. On Windows, it will happily accept http:// vs ftp:// vs <br/>&gt;&gt; file:// vs \\host\share in many of the &quot;open file&quot; dialogs. This is a <br/>&gt;&gt; good thing, and the trend should continue. PHP already supports this <br/>&gt;&gt; in their open functions and this is widely understood to be a major <br/>&gt;&gt; feature.<br/>&gt;<br/>&gt; s/feature/security hole/ :)<br/><br/>Joking aside - productivity and security are always values at odds with <br/>each other. The most secure solution is the solution that provides no <br/>functions at all. Second best is a locked room with no network access <br/>and restricted physical access. The moment you let a user do _anything_ <br/>you open the door to exploitation. It is not correct to conclude that <br/>flexibility is unacceptable. It depends on the application requirements. <br/>I wouldn&#39;t hire a minimum wage Perl programmer with no experience to <br/>write a security system. It would be ridiculous.<br/><br/>I, and the majority of the traditional Perl users, chose Perl because of <br/>its flexibility. It&#39;s ability to do things that other languages could <br/>not, or could not do well, at the time. Yes, flexibility means effort is <br/>required to secure the solution. This is normal, no matter what language <br/>you choose.<br/><br/>Again, what is the worst that can really happen? So the user is able to <br/>access a resource that they already have permission to. So what? There <br/>are so many ways to get a user to screw up - that &lt;&gt; doesn&#39;t make my <br/>list. Social engineering is probably the easiest method of having a user <br/>screw up. Convince a stupid user to type &quot;rm -fr /&quot; as root as the <br/>solution to their problem with a driver or program that doesn&#39;t work. <br/>I&#39;ve seen it happen. To put &lt;&gt; into this class is silly to me. Why not <br/>put open() in general in this class? Why not remove all the system <br/>calls. That way the user won&#39;t be able to do ANYTHING dangerous. See <br/>where this goes? :-)<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138772.html Sat, 26 Jul 2008 18:05:17 +0000 Re: [perl #2783] Security of ARGV using 2-argument open -It'safeature by Aristotle Pagaltzis * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-26 22:30]:<br/>&gt; More people use rich file system identifiers these days than<br/>&gt; UNIX file system. On Windows, it will happily accept http://<br/>&gt; vs ftp:// vs file:// vs \\host\share in many of the &quot;open<br/>&gt; file&quot; dialogs. This is a good thing, and the trend should<br/>&gt; continue. PHP already supports this in their open functions<br/>&gt; and this is widely understood to be a major feature.<br/><br/>Yes, it reduces the amount of work necessary to hack sites<br/>written by PHP neophytes so much. All crackers agree, it&rsquo;s the<br/>coolest feature ever.<br/><br/>&gt; Users who don&#39;t read the document will always be surprised.<br/><br/>No one, and I mean NO ONE, reads the documentation, *every last<br/>line* of the documentation, before using a program. If *you* do,<br/>you are either a liar or a lawyer. &ldquo;Read the documentation or get<br/>what you deserve&rdquo; is utterly wrong-headed snobbism and completely<br/>counteproductive.<br/><br/>&gt; One could argue that an experienced user might be &quot;surprised&quot;<br/>&gt; that &quot;-&quot; was NOT interpretted as STDIN. This argument is<br/>&gt; entirely relative to the person&#39;s expectations.<br/><br/>The special intepretation of `-` is a completely different beast<br/>from the special interpretation of `rm -rf ~ |`. There is no<br/>reason that getting rid of the latter would have to lose us the<br/>former.<br/><br/>Regards,<br/>-- <br/>Aristotle Pagaltzis // &lt;http://plasmasturm.org/&gt;<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138771.html Sat, 26 Jul 2008 16:43:40 +0000 Re: [perl #2783] Security of ARGV using 2-argument open -It'safeature by Aristotle Pagaltzis * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-26 18:00]:<br/>&gt; Johan Vromans wrote:<br/>&gt;&gt; [Quoting Mark Mielke, on July 26 2008, 11:44, in &quot;Re: [perl #2783] Sec&quot;]<br/>&gt;&gt; <br/>&gt;&gt;&gt; You are mistaken to believe this is a new problem - my<br/>&gt;&gt;&gt; questions is with the urgency. Why does the behaviour need to<br/>&gt;&gt;&gt; change? Why is it a problem today when it was not a problem<br/>&gt;&gt;&gt; 10 years ago?<br/>&gt;&gt;<br/>&gt;&gt; My point was that the problem is bound to get bigger now more<br/>&gt;&gt; people are using not-filename-limiting tools<br/>&gt;<br/>&gt; Do you have evidence? Perhaps a list of filenames from 1988,<br/>&gt; 1998, and 2008, to compare against?<br/><br/>Yes. The filenames in home directories on servers I administrate<br/>today are brimming with spaces, parens and square brackets. And<br/>those are from Windows users, who mount their home directories on<br/>their Windows machine or use SFTP or such to shuttle files<br/>around. No one (in relative terms) uses Unix without a desktop<br/>environment anymore either. Now what characters that Windows<br/>users cannot type in Save As do you think are a problem in GNOME<br/>or KDE? Question marks? Colons? Asterisks?<br/><br/>Regards,<br/>-- <br/>Aristotle Pagaltzis // &lt;http://plasmasturm.org/&gt;<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138770.html Sat, 26 Jul 2008 16:31:39 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Andy Armstrong On 26 Jul 2008, at 21:29, Mark Mielke wrote:<br/>&gt; More people use rich file system identifiers these days than UNIX <br/>&gt; file system. On Windows, it will happily accept http:// vs ftp:// vs <br/>&gt; file:// vs \\host\share in many of the &quot;open file&quot; dialogs. This is <br/>&gt; a good thing, and the trend should continue. PHP already supports <br/>&gt; this in their open functions and this is widely understood to be a <br/>&gt; major feature.<br/><br/><br/>s/feature/security hole/ :)<br/><br/>-- <br/>Andy Armstrong, Hexten<br/><br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138769.html Sat, 26 Jul 2008 16:19:25 +0000 Re: [perl #2783] Security of ARGV using 2-argument open -It'safeature by Aristotle Pagaltzis * Mark Mielke &lt;mark@mark.mielke.cc&gt; [2008-07-25 23:15]:<br/>&gt; How many people have been &quot;burned&quot; by this &quot;problem&quot;? Is the<br/>&gt; new class of dimwits exceedingly more dimwitted than the<br/>&gt; previous? Why was this not a problem 10 years ago?<br/><br/>Just because you didn&rsquo;t hear about it before doesn&rsquo;t mean no one<br/>else knew of it. I&rsquo;ve been preaching the use of 3-arg open ever<br/>since it was introduced, and I&rsquo;ve known of the diamond operator&rsquo;s<br/>problem for just as long.<br/><br/>Regards,<br/>-- <br/>Aristotle Pagaltzis // &lt;http://plasmasturm.org/&gt;<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138768.html Sat, 26 Jul 2008 16:16:29 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It's afeature by Aristotle Pagaltzis * Tom Christiansen &lt;tchrist@perl.com&gt; [2008-07-20 07:30]:<br/>&gt; And the day that I can no longer rely upon the overlying system<br/>&gt; to automatically understand that &quot;-&quot; is STDIN for input or<br/>&gt; STDOUT for output is the day that I will fork a parallel copy<br/>&gt; of Perl that maintains traditional and expected behavior.<br/>&gt; However, I trust that will never need to occur, ofr no pumpking<br/>&gt; has ever been so blindly cavalier--which can probably be read<br/>&gt; as &quot;foolish&quot; if you&#39;re of that bent.<br/><br/>Go ahead. Being able to fork is what free software is all about.<br/><br/>I do agree that treating the filename `-` as special is a very<br/>nice feature. It cannot cause problems of the sort that filenames<br/>with 2-arg-open metacharacters can, either. But then, there is no<br/>reason that this feature would have to be chucked out along with<br/>the intepretation of other special characters.<br/><br/>&gt; What you don&#39;t seem to understand is that taking a homogeneous<br/>&gt; approach to argument processing is not a bug, but a feature--a<br/>&gt; BIG FEATURE. Perhaps you&#39;re too much of a youngster to remember<br/>&gt; the days that shells didn&#39;t glob command-line arguments for<br/>&gt; you, and each program had to parse and process its own command<br/>&gt; line string. But I am not. Those were dark days of<br/>&gt; unpredictability. It&#39;s the wrong way to (not) go about things.<br/><br/>I fail to follow. First you say that a program doing its own<br/>magical interpretation of metacharacters in filenames (like pipes<br/>and angle brackets) is a BIG FEATURE.<br/><br/>Then you say that the days when programs did their own magical<br/>interpretation of metacharacters in filenames (like question<br/>marks and asterisks) were dark and ruled by unpredictability.<br/><br/>Which one is it?<br/><br/>Modern shells already have process substitution, which can<br/>do anything a user could do with magical filenames and more<br/>besides. *That* is a homogenous approach to argument processing,<br/>and you are absolutely right: it&rsquo;s a BIG FAT FEATURE. So what is<br/>the value of retaining an API that can and does surprise people<br/>in nasty ways in exchange for no added functionality whatsoever?<br/><br/>The *only* reason to keep that API is backwards compatibility.<br/>It&rsquo;s a good reason to be sure, but I would prefer a way forward<br/>that satisfies that demand without perpertuating the vestigial<br/>pragmatics of yesteryear for all eternity and a day beyond.<br/><br/>Regards,<br/>-- <br/>Aristotle Pagaltzis // &lt;http://plasmasturm.org/&gt;<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138767.html Sat, 26 Jul 2008 16:09:52 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Zefram Mark Mielke wrote:<br/>&gt;Ah. You didn&#39;t mean /$/ - you meant /...$/.<br/><br/>Yes, I meant the $ regexp operator in general, not a pattern consisting<br/>only of that operator.<br/><br/>&gt; this is ANOTHER case, where I disagree that <br/>&gt;anything should be &quot;fixed&quot;.<br/><br/>Oh, I think /$/ is impossible to fix in perl5. There are a great many<br/>programs that run regexps on newline-terminated input lines and use /$/<br/>intending for it to match before the newline. These would seriously<br/>break if /$/ changed to match only at end of string. I wasn&#39;t arguing<br/>for this to change, but using it as an example of another case where a<br/>very short (and therefore attractive) operator tries to DWIM by complex<br/>magical behaviour and ends up surprising the programmer.<br/><br/>I think &lt;&gt; could be changed, however. I&#39;m OK with it continuing<br/>to process &quot;-&quot; as stdin; you&#39;re right that this is a common Unix<br/>convention. But its handling of &quot;&gt;foo&quot; and &quot;rm -rf / |&quot; are certainly<br/>not conventional. I think (unlike /$/) that the intentional uses of<br/>those features are sufficiently rare that it&#39;s worth breaking them to<br/>make the operator less surprising for everyone else.<br/><br/>&gt; Users who intend to match end-of-string and <br/>&gt;only end-of-string should be using \z.<br/><br/>Yes, indeed they need to. But most of them don&#39;t: they use the shorter<br/>and more familiar operator, and end up with a different program from<br/>the one they intended to write. And I remember the days when /\z/<br/>didn&#39;t exist: for a while I used /(?!.)/s as the only way to be sure.<br/><br/>After writing my earlier message, I had a think about what start/end<br/>anchor operators should logically exist, depending on how your string<br/>is structured into lines, and which ones we actually have in Perl.<br/>I came up with these sets, defining the behaviour explicitly in terms<br/>of the regexp operators with simplest behaviour:<br/><br/>PURPOSE START END<br/>sensible pairs:<br/> single undelimited line \A \z<br/> single line with \n terminator \A (?=\n\z)<br/> zero or more \n-terminated lines (?:\A|(?&lt;=\n))(?!\z) (?=\n)<br/> one or more \n-separated lines (?:\A|(?&lt;=\n)) (?=\n|\z)<br/>actual pairs:<br/> /^...$/, /\A...\Z/ \A (?=\n?\z)<br/> /^...$/m (?:\A|(?&lt;=\n)(?!\z)) (?=\n|\z)<br/><br/>I am mystified as to the circumstances under which one might actually<br/>want the behaviour of /$/ (without /m) or /^/m. Certainly they can be<br/>correctly used, with a bit of care, but as far as I can see they never<br/>completely match the actual semantics of what constitutes a line start<br/>or end.<br/><br/>&gt; just so that somebody who didn&#39;t understand what <br/>&gt;they were doing in the first place, will not break in an obscure use case.<br/><br/>I think these (&lt;&gt; and some of the regexp things) are unreasonably<br/>difficult to understand. /^/m is so difficult to understand that its<br/>own implementors have trouble with it. It was documented incorrectly<br/>in perlre for years, until I discovered the undocumented /(?!\z)/ bit of<br/>its behaviour and pointed it out (bug #27053, resolved by a documentation<br/>change in 5.10).<br/><br/>I understand these operators. I will jump through the necessary hoops to<br/>write the program that I intend, even if the hoop is using a 20-character<br/>regexp (as in the table above) instead of the single character that<br/>I know from grep. Not to put too fine a point on it, I&#39;m unburned<br/>because I know the language inside out and I&#39;m anal about correctness.<br/>I&#39;m in a small minority on all three points.<br/><br/>&gt;Users who don&#39;t read the document will always be surprised.<br/><br/>Users who read the documentation for perl programs that use &lt;&gt; (such as<br/>our hypothetical wc-in-perl) generally don&#39;t get told about the magic<br/>meaning of &quot;rm -rf / |&quot; as an argument. They will be surprised and<br/>burned by the present behaviour.<br/><br/>You have to read quite a long way into the &lt;&gt; documentation (in perlop)<br/>before it mentions pipe magic. It starts off saying it &quot;emulate[s] the<br/>behavior of sed and awk&quot;, which covers &quot;-&quot; and the no-arguments case.<br/>It then speaks about filenames, and gives an example using glob() in<br/>a way that makes it (the example) vulnerable to the very problems we<br/>are discussing. It never mentions the magic interpretation of &quot;&gt;foo&quot;<br/>or that it loses trailing spaces.<br/><br/>Magic behaviour of &quot;-&quot; is less surprising, less dangerous, and more<br/>likely to be documented than any of the others. It also has a well-known<br/>workaround, ./*, which is also good for avoiding interpretation as<br/>switches. The pipe thing can&#39;t be worked around that way: consider the<br/>file &quot;./; rm -rf / |&quot;. Pipe magic here is very nasty.<br/><br/>&gt;In this case, the expectations should be well instilled.<br/><br/>I expect generally unpredictable behaviour if I give a filename<br/>containing unusual characters to a program written by anyone else.<br/>(Not specifically programs written in scripting languages, or programs<br/>written by amateurs, but just programs written by anyone who wasn&#39;t me.<br/>Hell, I once encountered commercial *kernel* code that lost trailing<br/>spaces in filenames.) This expectation has been instilled by years of<br/>experience, and reinforced by the psychological understanding that most<br/>programmers just don&#39;t think about the unusual cases.<br/><br/>-zefram<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138766.html Sat, 26 Jul 2008 15:18:32 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Johan Vromans Mark Mielke &lt;mark@mark.mielke.cc&gt; writes:<br/><br/>&gt; Do you have evidence? Perhaps a list of filenames from 1988, 1998, and<br/>&gt; 2008, to compare against?<br/><br/>Ah, come on. There are many more people in 2008 using some Linux with<br/>Firefox, Thunderbird and OpenOffice than there were in 1998 and 1988.<br/>There are many more people in 2008 using some Linux totally unaware of<br/>command line shells and special characters than there were in 1998 and<br/>1988. The chances that files with special characters in their names<br/>are created is therefore bigger in 2008 than they were in 1998 and<br/>1988.<br/><br/>-- Johan<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138765.html Sat, 26 Jul 2008 14:11:48 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Zefram wrote:<br/>&gt; Mark Mielke wrote:<br/>&gt; <br/>&gt;&gt; I don&#39;t understand. What is /$/ reasonably supposed to do?<br/>&gt;&gt; <br/>&gt;<br/>&gt; It is very frequently used in an attempt to anchor to the end of the<br/>&gt; string. Such as<br/>&gt;<br/>&gt; die &quot;invalid keyword&quot; unless $keyword =~ /^(foo|bar|baz)$/;<br/>&gt;<br/>&gt; In this context the programmer usually doesn&#39;t intend to accept &quot;foo\n&quot;.<br/>&gt; Newline is a shell metacharacter, of course, and often significant in<br/>&gt; file formats, so there&#39;s lots of scope for breakage.<br/>&gt; <br/><br/>Ah. You didn&#39;t mean /$/ - you meant /...$/. Similar to other issues, the <br/>real-life problems with accepting &quot;foo&quot; vs &quot;foo\n&quot; are pretty few. I <br/>expect the /...$/ cases are more than the 2-argument cases in terms of <br/>real-life problems, however, this is ANOTHER case, where I disagree that <br/>anything should be &quot;fixed&quot;. Users who intend to match end-of-string and <br/>only end-of-string should be using \z. It is not the job of Perl to <br/>redefine long-standing operators to become less functional and create <br/>compatibility problems, just so that somebody who didn&#39;t understand what <br/>they were doing in the first place, will not break in an obscure use case.<br/><br/>&gt;&gt; Please point out a real-life <br/>&gt;&gt; program that uses /$/ that isn&#39;t mere theory.<br/>&gt;&gt; <br/>&gt;<br/>&gt; I presume you mean a real-life program that misbehaves due to misuse<br/>&gt; of /$/. On a quick look through /usr/local/share/perl, I found this<br/>&gt; in Carp::Clan:<br/>&gt;<br/>&gt; :unless ( /^-?\d+(?:\.\d+(?:[eE][+-]\d+)?)?$/<br/>&gt; : ) # Looks numeric<br/>&gt; :{<br/>&gt; : s/([\\\&#39;])/\\$1/g; # Escape \ and &#39;<br/>&gt; ...<br/>&gt;<br/>&gt; This is used when displaying function arguments in a stack trace: it&#39;s<br/>&gt; trying to show numeric values as unquoted numbers and any other defined<br/>&gt; value as a quoted string. So these are how it&#39;s meant to work:<br/>&gt;<br/>&gt; $ perl -MCarp::Clan=confess -we &#39;sub foo { confess &quot;a&quot; } foo(&quot;abc&quot;)&#39;<br/>&gt; Carp::Clan::__ANON__(): a at -e line 1<br/>&gt; main::foo(&#39;abc&#39;) called at -e line 1<br/>&gt; $ perl -MCarp::Clan=confess -we &#39;sub foo { confess &quot;a&quot; } foo(&quot;abc\n&quot;)&#39;<br/>&gt; Carp::Clan::__ANON__(): a at -e line 1<br/>&gt; main::foo(&#39;abc\x0A&#39;) called at -e line 1<br/>&gt; $ perl -MCarp::Clan=confess -we &#39;sub foo { confess &quot;a&quot; } foo(&quot;123&quot;)&#39;<br/>&gt; Carp::Clan::__ANON__(): a at -e line 1<br/>&gt; main::foo(123) called at -e line 1<br/>&gt; $<br/>&gt;<br/>&gt; And this one goes wrong:<br/>&gt;<br/>&gt; $ perl -MCarp::Clan=confess -we &#39;sub foo { confess &quot;a&quot; } foo(&quot;123\n&quot;)&#39;<br/>&gt; Carp::Clan::__ANON__(): a at -e line 1<br/>&gt; main::foo(123<br/>&gt; ) called at -e line 1<br/>&gt; $<br/>&gt;<br/>&gt; OK, this one&#39;s not likely to produce a security hole, but it&#39;s just the<br/>&gt; first instance I set eyes on. It&#39;s a very common antipattern.<br/>&gt;<br/>&gt; <br/><br/>It seems like a pretty harmless one.<br/><br/>&gt;&gt; Plain honest-to-Ritchie file access is obsolete.<br/>&gt;&gt; <br/>&gt;<br/>&gt; I respectfully disagree. I find the Unix filesystem is an excellent<br/>&gt; abstraction, and I use it all the time.<br/>&gt; <br/><br/>More people use rich file system identifiers these days than UNIX file <br/>system. On Windows, it will happily accept http:// vs ftp:// vs file:// <br/>vs \\host\share in many of the &quot;open file&quot; dialogs. This is a good <br/>thing, and the trend should continue. PHP already supports this in their <br/>open functions and this is widely understood to be a major feature.<br/><br/>&gt;&gt; I want to see http:// <br/>&gt;&gt; automatically parsed.<br/>&gt;&gt; <br/>&gt;<br/>&gt; It&#39;s possible to map URIs into Unix filename space. (I had a go at<br/>&gt; this myself for Linux a while back, but didn&#39;t develop it very far.)<br/>&gt; It&#39;s also possible to map Unix filenames into URI space. If you want<br/>&gt; access to both HTTP and local files in one context, you can still get this<br/>&gt; with pure file operations or with pure URI operations, at your option.<br/>&gt; If you insist on mixed parsing, then you&#39;re a long way from providing a<br/>&gt; filename context, and you have to document the rules in order for users<br/>&gt; to be able to make intentional use of the features.<br/>&gt;<br/>&gt; <br/><br/>The rules are pretty well recognized, even by the non-technical. The <br/>non-technical would recognize http:// a long time before they would <br/>recognize some non-standard overlay of the UNIX file name space with URI.<br/><br/>&gt;&gt; We&#39;re decades past the requirements you are <br/>&gt;&gt; raising,<br/>&gt;&gt; <br/>&gt;<br/>&gt; The requirement to not surprise the user?<br/>&gt; <br/><br/>Users who don&#39;t read the document will always be surprised. In standard <br/>UNIX, passing a &quot;-&quot; in has traditionally meant STDIN. One could argue <br/>that an experienced user might be &quot;surprised&quot; that &quot;-&quot; was NOT <br/>interpretted as STDIN. This argument is entirely relative to the <br/>person&#39;s expectations.<br/><br/>In this case, the expectations should be well instilled. Perl has done <br/>what it has done for over a decade, and if somebody is truly surprised <br/>today - they should pick up the manual and give it another read.<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138764.html Sat, 26 Jul 2008 13:29:49 +0000 [perl #57302] Unexpected conversion from "/usr/local" to ".../.." by Markus Elfring # New Ticket Created by Markus Elfring <br/># Please include the string: [perl #57302]<br/># in the subject line of all future correspondence about this issue. <br/># &lt;URL: http://rt.perl.org/rt3/Ticket/Display.html?id=57302 &gt;<br/><br/><br/>This is a bug report generated with the help of perlbug 1.36 running <br/>under perl 5.10.0.<br/><br/>-----------------------------------------------------------------<br/>[Please enter your report here]<br/><br/>I downloaded the source file package <br/>&quot;http://www.cpan.org/src/perl-5.10.0.tar.gz&quot;. The included script <br/>&quot;Configure&quot; asked me some questions for program locations and <br/>directories while reasonable default values like &quot;/usr/bin/perl&quot; and <br/>&quot;/usr/local&quot; were provided.<br/><br/>I chose some options and tried a compilation. I decided to adjust a few <br/>options and run the configuration script again.<br/>I was surprised that a couple of dots were presented as new default <br/>values that I did not change before in the previous run. I noticed that <br/>the dots were recorded in the file &quot;config.sh&quot;. So I replaced the dots <br/>in assignments for variables like &quot;binexp&quot; and &quot;prefix&quot; with <br/>understandable text by an editor.<br/>I saw that the unexpected dots notation reappeared after each <br/>reconfiguration try. Are there any open issues for the build script <br/>maintenance?<br/><br/>[Please do not change anything below this line]<br/>-----------------------------------------------------------------<br/>---<br/>Flags:<br/> category=install<br/> severity=medium<br/>---<br/>Site configuration information for perl 5.10.0:<br/><br/>Configured by elfring at Wed Jul 23 10:28:59 CEST 2008.<br/><br/>Summary of my perl5 (revision 5 version 10 subversion 0) configuration:<br/> Platform:<br/> osname=linux, osvers=2.6.25.11-default, <br/>archname=x86_64-linux-thread-multi-ld<br/> uname=&#39;linux sonne 2.6.25.11-default #2 smp preempt mon jul 14 <br/>22:26:03 cest 2008 x86_64 x86_64 x86_64 gnulinux &#39;<br/> config_args=&#39;&#39;<br/> hint=previous, useposix=true, d_sigaction=define<br/> useithreads=define, usemultiplicity=define<br/> useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef<br/> use64bitint=define, use64bitall=define, uselongdouble=define<br/> usemymalloc=n, bincompat5005=undef<br/> Compiler:<br/> cc=&#39;cc&#39;, ccflags =&#39;-D_REENTRANT -D_GNU_SOURCE -DSOCKS <br/>-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE <br/>-D_FILE_OFFSET_BITS=64&#39;,<br/> optimize=&#39;-O3&#39;,<br/> cppflags=&#39;-D_REENTRANT -D_GNU_SOURCE -DSOCKS -fno-strict-aliasing <br/>-pipe -I/usr/local/include -D_REENTRANT -D_GNU_SOURCE -DSOCKS <br/>-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE <br/>-D_FILE_OFFSET_BITS=64&#39;<br/> ccversion=&#39;&#39;, gccversion=&#39;4.3.1 20080507 (prerelease) <br/>[gcc-4_3-branch revision 135036]&#39;, gccosandvers=&#39;&#39;<br/> intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678<br/> d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16<br/> ivtype=&#39;long&#39;, ivsize=8, nvtype=&#39;long double&#39;, nvsize=16, <br/>Off_t=&#39;off_t&#39;, lseeksize=8<br/> alignbytes=16, prototype=define<br/> Linker and Libraries:<br/> ld=&#39;cc&#39;, ldflags =&#39; -L/usr/local/lib&#39;<br/> libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64<br/> libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lpthread -lc<br/> perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc<br/> libc=/lib/libc-2.8.so, so=so, useshrplib=true, libperl=libperl.so<br/> gnulibc_version=&#39;2.8&#39;<br/> Dynamic Linking:<br/> dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=&#39;-Wl,-E <br/>-Wl,-rpath,/usr/local/lib/perl/5.10.0/x86_64-linux-thread-multi-ld/CORE&#39;<br/> cccdlflags=&#39;-fPIC&#39;, lddlflags=&#39;-shared -O3 -L/usr/local/lib&#39;<br/><br/>Locally applied patches:<br/> <br/><br/>---<br/>@INC for perl 5.10.0:<br/> /usr/local/lib/perl/5.10.0/x86_64-linux-thread-multi-ld<br/> /usr/local/lib/perl/5.10.0<br/> /usr/local/lib/perl/site/5.10.0/x86_64-linux-thread-multi-ld<br/> /usr/local/lib/perl/site/5.10.0<br/> .<br/><br/>---<br/>Environment for perl 5.10.0:<br/> HOME=/home/elfring<br/> LANG=de_DE.UTF-8<br/> LANGUAGE (unset)<br/> LD_LIBRARY_PATH (unset)<br/> LOGDIR (unset)<br/> <br/>PATH=/opt/kde3/bin:/usr/lib/mozart/bin:/home/elfring/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/cross/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/opt/gnome/bin:/usr/lib/qt3/bin<br/> PERL_BADLANG (unset)<br/> SHELL=/bin/bash<br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138763.html Sat, 26 Jul 2008 10:22:08 +0000 [perl #57288] PerlIO::via::QuotedPrint not flushing by Kevin Ryde # New Ticket Created by Kevin Ryde <br/># Please include the string: [perl #57288]<br/># in the subject line of all future correspondence about this issue. <br/># &lt;URL: http://rt.perl.org/rt3/Ticket/Display.html?id=57288 &gt;<br/><br/><br/>When a PerlIO::via::QuotedPrint layer is pushed on an opened file,<br/>autoflush or an explicit -&gt;flush() doesn&#39;t send output to the file<br/>immediately.<br/><br/>The program qp.pl below shows the problem. I hoped the OUT-&gt;flush would<br/>make the &quot;hello&quot; appear in /tmp/foo immediately, but that doesn&#39;t<br/>happen, not until after the program exits after the sleep.<br/><br/>I guess QuotedPrint doesn&#39;t supply a FLUSH routine, and the default for<br/>PerlIO::via in that case is to do nothing, so a top-level flush doesn&#39;t<br/>reach the :perlio+:unix full-buffered output layer below.<br/><br/>Several other PerlIO::via output modules on cpan behave the same,<br/>I guess having used QuotedPrint as a model. I wonder if either<br/><br/>- The PerlIO::via docs could advise every output layer to supply a FLUSH<br/> function calling $fh-&gt;flush on the sublayer.<br/><br/>- PerlIO::via could make such a &quot;propagated&quot; flush the default if you<br/> don&#39;t supply a FLUSH routine.<br/><br/>The latter could make life easier for straightforward non-buffering<br/>transformer layers. The only question would be whether anyone has<br/>omitted a FLUSH func deliberately wanting not to call flush on the<br/>sublayer. That&#39;d seem a bit unlikely to me, or only applicable to<br/>something that was designed to be at the bottom of the stack anyway<br/>(an output capture of some sort say) ...<br/><br/><br/><br/>---<br/>Flags:<br/> category=library<br/> severity=wishlist<br/>---<br/>Site configuration information for perl 5.10.0:<br/><br/>Configured by Debian Project at Thu May 8 13:32:42 UTC 2008.<br/><br/>Summary of my perl5 (revision 5 version 10 subversion 0) configuration:<br/> Platform:<br/> osname=linux, osvers=2.6.24.4, archname=i486-linux-gnu-thread-multi<br/> uname=&#39;linux ninsei 2.6.24.4 #1 smp preempt fri apr 18 15:36:09 pdt 2008 i686 gnulinux &#39;<br/> config_args=&#39;-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i486-linux-gnu -Dprefix=/usr -Dprivlib=/usr/share/perl/5.10 -Darchlib=/usr/lib/perl/5.10 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.10.0 -Dsitearch=/usr/local/lib/perl/5.10.0 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Ud_ualarm -Uusesfio -Uusenm -DDEBUGGING=-g -Doptimize=-O2 -Duseshrplib -Dlibperl=libperl.so.5.10.0 -Dd_dosuid -des&#39;<br/> hint=recommended, useposix=true, d_sigaction=define<br/> useithreads=define, usemultiplicity=define<br/> useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef<br/> use64bitint=undef, use64bitall=undef, uselongdouble=undef<br/> usemymalloc=n, bincompat5005=undef<br/> Compiler:<br/> cc=&#39;cc&#39;, ccflags =&#39;-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64&#39;,<br/> optimize=&#39;-O2 -g&#39;,<br/> cppflags=&#39;-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include&#39;<br/> ccversion=&#39;&#39;, gccversion=&#39;4.2.3 (Debian 4.2.3-5)&#39;, gccosandvers=&#39;&#39;<br/> intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234<br/> d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12<br/> ivtype=&#39;long&#39;, ivsize=4, nvtype=&#39;double&#39;, nvsize=8, Off_t=&#39;off_t&#39;, lseeksize=8<br/> alignbytes=4, prototype=define<br/> Linker and Libraries:<br/> ld=&#39;cc&#39;, ldflags =&#39; -L/usr/local/lib&#39;<br/> libpth=/usr/local/lib /lib /usr/lib /usr/lib64<br/> libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt<br/> perllibs=-ldl -lm -lpthread -lc -lcrypt<br/> libc=/lib/libc-2.7.so, so=so, useshrplib=true, libperl=libperl.so.5.10.0<br/> gnulibc_version=&#39;2.7&#39;<br/> Dynamic Linking:<br/> dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=&#39;-Wl,-E&#39;<br/> cccdlflags=&#39;-fPIC&#39;, lddlflags=&#39;-shared -O2 -g -L/usr/local/lib&#39;<br/><br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138762.html Sat, 26 Jul 2008 10:12:03 +0000 B-Generate-1.12_10 stable & uploaded by Reini Urban Hi Josh,<br/><br/>I&#39;ve uploaded the latest series of B-Generate-1.12_x which is becoming<br/>stable now.<br/>These are the current maintainers of B::Generate<br/><br/>B::Generate ABERGMAN Artur Bergman co-maint JJORE<br/>B::Generate CLKAO Chia-liang Kao (&#x9AD8;&#x5609;&#x826F;) co-maint JJORE<br/>B::Generate GRUBER Anton Berezin co-maint JJORE<br/>B::Generate JCROMIE Jim Cromie co-maint JJORE<br/>B::Generate JJORE Joshua ben Jore first-come JJORE<br/>B::Generate MSCHWERN Michael G Schwern co-maint JJORE<br/>B::Generate MSTROUT Matt S Trout co-maint JJORE<br/>B::Generate SWALTERS Scott Walters co-maint JJORE<br/><br/>The list of fixes for the latest releases for 5.10 comes from:<br/> Anton Berezin<br/> Reini Urban<br/> Dmitry Karasik<br/>(See Changes)<br/><br/>The module pm says this:<br/>MAINTAINERS<br/><br/>This is just a list of people who have submitted patches to the<br/>module. To find someone to actually maintain this, please try<br/>contacting perl5-porters.<br/><br/>Josh Jore, Michael Schwern, Jim Cromie, Scott Walters.<br/><br/>This list is incomplete.<br/>I&#39;m asking for permissions for co-maint and release a 1.13 then.<br/>-- <br/>Reini Urban<br/>http://phpwiki.org/ http://murbreak.at/<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138761.html Sat, 26 Jul 2008 09:05:25 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Johan Vromans wrote:<br/>&gt; [Quoting Mark Mielke, on July 26 2008, 11:44, in &quot;Re: [perl #2783] Sec&quot;]<br/>&gt; <br/>&gt;&gt; You are mistaken to believe this is a new problem - my questions is with <br/>&gt;&gt; the urgency. Why does the behaviour need to change? Why is it a problem <br/>&gt;&gt; today when it was not a problem 10 years ago?<br/>&gt;&gt; <br/>&gt;<br/>&gt; My point was that the problem is bound to get bigger now more people<br/>&gt; are using not-filename-limiting tools<br/><br/>Do you have evidence? Perhaps a list of filenames from 1988, 1998, and <br/>2008, to compare against?<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138760.html Sat, 26 Jul 2008 08:58:49 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Ed Avis wrote:<br/>&gt; Mark Mielke &lt;mark &lt;at&gt; mark.mielke.cc&gt; writes:<br/>&gt;<br/>&gt; <br/>&gt;&gt; What legitimate scenarios use files with names &quot;&lt;x&quot;?<br/>&gt;&gt; <br/>&gt;<br/>&gt; Very few. But if such a filename does exist, you&#39;d want the program to handle<br/>&gt; it in a sane way.<br/>&gt;<br/>&gt; Unfortunately the world is not always legitimate. Every program using while<br/>&gt; (&lt;&gt;) has to come with a health warning that it is unsafe to use unless you know<br/>&gt; that no &gt;&lt;| characters are contained in the filenames.<br/>&gt; <br/><br/>No, it doesn&#39;t. At least not until you can prove this is a real issue <br/>hurting people every day.<br/><br/>&gt; Remember gets() in the standard C library? What&#39;s the problem with it? No<br/>&gt; legitimate use would ever enter a million characters of text when given a prompt<br/>&gt; to enter &#39;yes&#39; or &#39;no&#39;. And if users are so stupid as to enter too much text<br/>&gt; and overflow the fixed buffer, that is a problem with the users and they should<br/>&gt; be educated to take more care.<br/>&gt;<br/>&gt; Yet today, gets() is deprecated and nobody uses it - whether writing &#39;security<br/>&gt; code&#39; or not. It is just too dangerous.<br/>&gt; <br/><br/>You are exaggerating. If anybody truly allocated a buffer for gets() <br/>that was a million characters, it wouldn&#39;t be a problem. Allocating a <br/>Mbyte for an input buffer &quot;just in case&quot;, however, is ridiculous. People <br/>didn&#39;t allocate a million characters - they allocated 64, or 512, or <br/>1024. The chance that this is hurt is far, far greater. You are correct <br/>that the interface is wrong for gets() is wrong, but in your analogy you <br/>have ignored the fact that 2-arg open is a FEATURE not a LIMITATION. The <br/>situations are not the same.<br/><br/>In gets(), there is a limitation which can cause the executing program <br/>to see data corruption, arbitrary code execution, or program termination.<br/><br/>In Perl &lt;&gt;, there is a feature that users can pass shell pipes instead <br/>of file names or &quot;-&quot; instead of STDIN. The worst that can happen is that <br/>the user requests a file they have permission to overwrite, be <br/>overwritten. This might happen if the user is naive enough to use &quot;&gt;&quot; as <br/>the first character in their file name. What cases of this problem <br/>exist? What cases prove that the value of the feature is far less than <br/>the cost of allowing the feature? Is this theory, or do you have a <br/>legitimate complaint?<br/><br/><br/>&gt;&gt; I strongly disagree. You are turning an existing feature with existing <br/>&gt;&gt; syntax into a non-feature, because you think there MIGHT be a <br/>&gt;&gt; theoretical somebody incompetent enough to hang themselves with a bit of <br/>&gt;&gt; rope.<br/>&gt;&gt; <br/>&gt;<br/>&gt; First I would like to say that this is best not treated as a moral issue. Those<br/>&gt; bad programmers, deserve what they get, we should teach them a lesson, etc.<br/>&gt; <br/><br/>You are incorrect. Programming languages can do baby sitting duty, or <br/>they can provide plenty of rope. There is a need for both in this world. <br/>Both types of languages exist today. Perl has traditionally been the <br/>&quot;plenty of rope&quot; type, and this is a major reason why Perl adoption was <br/>so high for many years. What other scripting languages allowed users to <br/>run arbitrary system calls? You are suggesting that this Perl tradition <br/>be turned over. Your reason for requesting it is a trivial theoretical <br/>case that has probably happened once in the life time of Perl.<br/><br/>&gt; If the measure of incompetence is using &#39;while (&lt;&gt;)&#39; in a program without<br/>&gt; realizing that it is dangerous, then I have been incompetent many times and so<br/>&gt; have lots of others. Again, have a look at the examples you can find on Google<br/>&gt; Code Search. All of these people have been incompetent and written programs<br/>&gt; that are unsafe to use on arbitrary lists of files. All the programs either<br/>&gt; need to be patched to use a safe form of open, or else need to mention the<br/>&gt; gotcha in their documentation.<br/>&gt; <br/><br/>Your definition of unsafe and mine are different. What is the worst that <br/>can happen with these theoretically unsafe programs?<br/><br/>Somebody has a file called &quot;&gt;fun&quot;. they pass &quot;*&quot; in. Their program <br/>overwrites &quot;fun&quot;. So what? In order for their to be damage, &quot;fun&quot; would <br/>need to exist and contain valuable information. What are the chances <br/>that both &quot;&gt;fun&quot; and &quot;fun&quot; exist?<br/><br/>The only danger is in setuid usage, where one uses special privileges to <br/>overwrite a file they should not have access to. This is precisely what <br/>taint-mode is for, and I fully agree that &lt;&gt; should raise issues in <br/>taint-mode.<br/><br/>I don&#39;t agree at all that non-taint-mode should warn or error or have <br/>alternate behaviour from &lt;&gt; as it is today.<br/><br/>&gt; The bar for incompetence or being a dimwit is set remarkably low IMHO. Surely<br/>&gt; you should not need to be one of the expert 10% (or even the top 90%) to read<br/>&gt; some files and count the number of lines. Yet I bet that if you get a sample of<br/>&gt; perl programmers and ask them to implement a simple &#39;wc -l&#39; in perl, more than<br/>&gt; nine out of ten will write one that breaks if given a filename beginning with &gt;,<br/>&gt; and most of those without even thinking there might be a problem.<br/>&gt; <br/><br/>By &quot;break&quot; you mean - fail to allow the use of &quot;&gt;&quot; in the beginning of a <br/>file, which is a pretty minimal case.<br/><br/>Again - show examples of this problem in the field.<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138759.html Sat, 26 Jul 2008 08:57:26 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by jvromans [Quoting Mark Mielke, on July 26 2008, 11:44, in &quot;Re: [perl #2783] Sec&quot;]<br/>&gt; You are mistaken to believe this is a new problem - my questions is with <br/>&gt; the urgency. Why does the behaviour need to change? Why is it a problem <br/>&gt; today when it was not a problem 10 years ago?<br/><br/>My point was that the problem is bound to get bigger now more people<br/>are using not-filename-limiting tools.<br/><br/>-- Johan<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138758.html Sat, 26 Jul 2008 08:55:31 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Johan Vromans wrote:<br/>&gt; Mark Mielke &lt;mark@mark.mielke.cc&gt; writes:<br/>&gt;<br/>&gt; <br/>&gt;&gt; Why was this not a problem 10 years ago?<br/>&gt;&gt; <br/>&gt;<br/>&gt; Long time ago filenames were meant for shell- and command line apps.<br/>&gt; Modern *ix applications (e.g., word processors) allow people to freely<br/>&gt; supply any filename they want, spaces and whatever included. E.g.,<br/>&gt; when saving a HTML page, using the &lt;title&gt; would be an acceptabe<br/>&gt; default choice for a file name.<br/>&gt;<br/>&gt; So whether it&#39;s wrong, or stupid, or whatever -- the chances of the<br/>&gt; problem happening will grow.<br/>&gt; <br/><br/>My memory tells me that &quot;word processors&quot; and the like have *always* <br/>accepted weird characters. In 1990 or so, I still remember the &#39;ls&#39; <br/>output being messed up because one of the filenames had a BACKSPACE in <br/>it. Nothing has changed in this regard. Perhaps people use GUIs more - <br/>but even this I don&#39;t believe. I&#39;ve used UNIX GUIs on HP-UX and Solaris <br/>since the late 1980s. Frame Maker didn&#39;t have file name restrictions <br/>that I recall?<br/><br/>You are mistaken to believe this is a new problem - my questions is with <br/>the urgency. Why does the behaviour need to change? Why is it a problem <br/>today when it was not a problem 10 years ago?<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138757.html Sat, 26 Jul 2008 08:44:14 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Johan Vromans Mark Mielke &lt;mark@mark.mielke.cc&gt; writes:<br/><br/>&gt; Why was this not a problem 10 years ago?<br/><br/>Long time ago filenames were meant for shell- and command line apps.<br/>Modern *ix applications (e.g., word processors) allow people to freely<br/>supply any filename they want, spaces and whatever included. E.g.,<br/>when saving a HTML page, using the &lt;title&gt; would be an acceptabe<br/>default choice for a file name.<br/><br/>So whether it&#39;s wrong, or stupid, or whatever -- the chances of the<br/>problem happening will grow.<br/><br/>-- Johan<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138756.html Sat, 26 Jul 2008 07:56:35 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Zefram Mark Mielke wrote:<br/>&gt;I don&#39;t understand. What is /$/ reasonably supposed to do?<br/><br/>It is very frequently used in an attempt to anchor to the end of the<br/>string. Such as<br/><br/> die &quot;invalid keyword&quot; unless $keyword =~ /^(foo|bar|baz)$/;<br/><br/>In this context the programmer usually doesn&#39;t intend to accept &quot;foo\n&quot;.<br/>Newline is a shell metacharacter, of course, and often significant in<br/>file formats, so there&#39;s lots of scope for breakage.<br/><br/>&gt; Please point out a real-life <br/>&gt;program that uses /$/ that isn&#39;t mere theory.<br/><br/>I presume you mean a real-life program that misbehaves due to misuse<br/>of /$/. On a quick look through /usr/local/share/perl, I found this<br/>in Carp::Clan:<br/><br/>:unless ( /^-?\d+(?:\.\d+(?:[eE][+-]\d+)?)?$/<br/>: ) # Looks numeric<br/>:{<br/>: s/([\\\&#39;])/\\$1/g; # Escape \ and &#39;<br/>...<br/><br/>This is used when displaying function arguments in a stack trace: it&#39;s<br/>trying to show numeric values as unquoted numbers and any other defined<br/>value as a quoted string. So these are how it&#39;s meant to work:<br/><br/>$ perl -MCarp::Clan=confess -we &#39;sub foo { confess &quot;a&quot; } foo(&quot;abc&quot;)&#39;<br/>Carp::Clan::__ANON__(): a at -e line 1<br/> main::foo(&#39;abc&#39;) called at -e line 1<br/>$ perl -MCarp::Clan=confess -we &#39;sub foo { confess &quot;a&quot; } foo(&quot;abc\n&quot;)&#39;<br/>Carp::Clan::__ANON__(): a at -e line 1<br/> main::foo(&#39;abc\x0A&#39;) called at -e line 1<br/>$ perl -MCarp::Clan=confess -we &#39;sub foo { confess &quot;a&quot; } foo(&quot;123&quot;)&#39;<br/>Carp::Clan::__ANON__(): a at -e line 1<br/> main::foo(123) called at -e line 1<br/>$<br/><br/>And this one goes wrong:<br/><br/>$ perl -MCarp::Clan=confess -we &#39;sub foo { confess &quot;a&quot; } foo(&quot;123\n&quot;)&#39;<br/>Carp::Clan::__ANON__(): a at -e line 1<br/> main::foo(123<br/>) called at -e line 1<br/>$<br/><br/>OK, this one&#39;s not likely to produce a security hole, but it&#39;s just the<br/>first instance I set eyes on. It&#39;s a very common antipattern.<br/><br/>&gt;Plain honest-to-Ritchie file access is obsolete.<br/><br/>I respectfully disagree. I find the Unix filesystem is an excellent<br/>abstraction, and I use it all the time.<br/><br/>&gt; I want to see http:// <br/>&gt;automatically parsed.<br/><br/>It&#39;s possible to map URIs into Unix filename space. (I had a go at<br/>this myself for Linux a while back, but didn&#39;t develop it very far.)<br/>It&#39;s also possible to map Unix filenames into URI space. If you want<br/>access to both HTTP and local files in one context, you can still get this<br/>with pure file operations or with pure URI operations, at your option.<br/>If you insist on mixed parsing, then you&#39;re a long way from providing a<br/>filename context, and you have to document the rules in order for users<br/>to be able to make intentional use of the features.<br/><br/>&gt; We&#39;re decades past the requirements you are <br/>&gt;raising,<br/><br/>The requirement to not surprise the user?<br/><br/>-zefram<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138755.html Sat, 26 Jul 2008 04:03:28 +0000 Re: [perl #57244] crash with recursive regexp by Zefram Eric Brine wrote:<br/>&gt;That should be<br/><br/>No, it does work as written, provided that $datum_rx is in scope where<br/>$array_rx is executed. Your version doesn&#39;t change that: $datum_rx<br/>still needs to be in scope at execution. In the real application<br/>some of the regexps are &quot;our&quot; rather than &quot;my&quot;, and the (??{}) uses<br/>a fully-qualified name: this is the only way to make the recursive<br/>reference work independently of execution context.<br/><br/>&gt;but that&#39;s not related to the bug in Perl.<br/><br/>Indeed.<br/><br/>-zefram<br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138754.html Sat, 26 Jul 2008 03:14:05 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Ed Avis Mark Mielke &lt;mark &lt;at&gt; mark.mielke.cc&gt; writes:<br/><br/>&gt;What legitimate scenarios use files with names &quot;&lt;x&quot;?<br/><br/>Very few. But if such a filename does exist, you&#39;d want the program to handle<br/>it in a sane way.<br/><br/>Unfortunately the world is not always legitimate. Every program using while<br/>(&lt;&gt;) has to come with a health warning that it is unsafe to use unless you know<br/>that no &gt;&lt;| characters are contained in the filenames.<br/><br/>Remember gets() in the standard C library? What&#39;s the problem with it? No<br/>legitimate use would ever enter a million characters of text when given a prompt<br/>to enter &#39;yes&#39; or &#39;no&#39;. And if users are so stupid as to enter too much text<br/>and overflow the fixed buffer, that is a problem with the users and they should<br/>be educated to take more care.<br/><br/>Yet today, gets() is deprecated and nobody uses it - whether writing &#39;security<br/>code&#39; or not. It is just too dangerous.<br/><br/>&gt;I strongly disagree. You are turning an existing feature with existing <br/>&gt;syntax into a non-feature, because you think there MIGHT be a <br/>&gt;theoretical somebody incompetent enough to hang themselves with a bit of <br/>&gt;rope.<br/><br/>First I would like to say that this is best not treated as a moral issue. Those<br/>bad programmers, deserve what they get, we should teach them a lesson, etc.<br/><br/>If the measure of incompetence is using &#39;while (&lt;&gt;)&#39; in a program without<br/>realizing that it is dangerous, then I have been incompetent many times and so<br/>have lots of others. Again, have a look at the examples you can find on Google<br/>Code Search. All of these people have been incompetent and written programs<br/>that are unsafe to use on arbitrary lists of files. All the programs either<br/>need to be patched to use a safe form of open, or else need to mention the<br/>gotcha in their documentation.<br/><br/>The bar for incompetence or being a dimwit is set remarkably low IMHO. Surely<br/>you should not need to be one of the expert 10% (or even the top 90%) to read<br/>some files and count the number of lines. Yet I bet that if you get a sample of<br/>perl programmers and ask them to implement a simple &#39;wc -l&#39; in perl, more than<br/>nine out of ten will write one that breaks if given a filename beginning with &gt;,<br/>and most of those without even thinking there might be a problem.<br/><br/>-- <br/>Ed Avis &lt;eda@waniasset.com&gt;<br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138753.html Sat, 26 Jul 2008 02:00:20 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Glenn Linderman wrote:<br/>&gt; On approximately 7/25/2008 2:13 PM, came the following characters from <br/>&gt; the keyboard of Mark Mielke:<br/>&gt;&gt; Glenn Linderman wrote:<br/>&gt;&gt;&gt; One could speculate about &quot;while(&lt;&gt;)&quot; using 2-arg open if -T is set <br/>&gt;&gt;&gt; and 3-arg open otherwise, with &quot;while(&lt;&lt;&gt;&gt;)&quot; or &quot;use magical while;&quot; <br/>&gt;&gt;&gt; causing 2-arg open to be used even without -T.<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; How else can we encourage the dimwits to continue using perl, after <br/>&gt;&gt;&gt; they get burned by stuff like this, if we don&#39;t improve the language?<br/>&gt;&gt;<br/>&gt;&gt; Responding to Glenn&#39;s although not specifically to him, but to all <br/>&gt;&gt; with this opinion:<br/>&gt;&gt;<br/>&gt;&gt; How many people have been &quot;burned&quot; by this &quot;problem&quot;? Is the new <br/>&gt;&gt; class of dimwits exceedingly more dimwitted than the previous? Why <br/>&gt;&gt; was this not a problem 10 years ago?<br/>&gt;<br/>&gt; I probably shouldn&#39;t have used the word &quot;dimwit&quot;, but... it seemed <br/>&gt; like the argument for not breaking while(&lt;&gt;) is very much &quot;elitist&quot;... <br/>&gt; the &quot;I&#39;m smart enough not to get trapped, so why aren&#39;t you?&quot;. So to <br/>&gt; try to talk to that class of people, I used the term.<br/><br/>Forget what term you used. Do you have an ACTUAL CASE of failure, or is <br/>this only theory?<br/><br/>&gt; But yes, the new class of dimwits (I might as well keep using the <br/>&gt; term, since I&#39;ve started) are more dimwitted than the previous class, <br/>&gt; because they were raised on Windows, instead of Unix. In Unix class, <br/>&gt; shell script handling of special characters, and the &quot;rm *&quot; with the <br/>&gt; file named -f to kill you, and the file name -i to protect you, were <br/>&gt; regularly taught to newbies. In Windows, no one teaches you anything, <br/>&gt; you get to learn by the seat of your pants. If you take classes, <br/>&gt; someone might think to mention stuff like that, but if you read <br/>&gt; documentation, particularly our Perl documentation, it is easy to <br/>&gt; overlook such an &quot;esoteric&quot; topic, even if it is noticed, because <br/>&gt; really, they are looking for how to open files, not how to learn <br/>&gt; defensive programming.<br/><br/>I disagree. Windows and UNIX have been around for about as long as Perl <br/>5. Again, do you have an ACTUAL CASE of failure, or is this only theory?<br/><br/>&gt;&gt; I don&#39;t see the point. There is no value in restricting Perl&#39;s <br/>&gt;&gt; functionailty, so that some theoretical dimwit will have one less <br/>&gt;&gt; theoretical security hole in one theoretical scenario. Where is the <br/>&gt;&gt; proof that this &quot;security problem&quot; is causing problems, and why <br/>&gt;&gt; aren&#39;t these dimwits having their hands cut off to prevent them from <br/>&gt;&gt; programming?<br/>&gt;<br/>&gt; Nope, not suggesting restricting it, just making easy things safer, <br/>&gt; and unsafe things harder.<br/><br/>Things could be made &quot;safe&quot; by chmod ugo-x /usr/bin/perl. You are not <br/>answering the question. What is the proof that this &quot;security problem&quot; <br/>is causing problems? Where is this outbreak you are trying to prevent?<br/><br/><br/>&gt;<br/>&gt; Fortunately, a large majority of dimwits put spaces in their <br/>&gt; filenames, and have enough problems with that, that they never think <br/>&gt; to put in &gt; &lt; | and other line noise. I think it is purely that that <br/>&gt; has kept the problem from getting out of hand.<br/><br/>More guessing. Do you have any evidence?<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138752.html Sat, 26 Jul 2008 01:10:54 +0000 Re: [perl #2783] Security of ARGV using 2-argument open - It'safeature by Mark Mielke Zefram wrote:<br/>&gt; Mark Mielke wrote:<br/>&gt; <br/>&gt;&gt; How many people have been &quot;burned&quot; by this &quot;problem&quot;?<br/>&gt;&gt; <br/>&gt;<br/>&gt; I don&#39;t get burned by it: this kind of issue is why I avoid using such<br/>&gt; DWIMish heuristic features. I only use &lt;&gt; in throwaway programs that<br/>&gt; I&#39;m using on known inputs, and if I want to read arbitrary files then<br/>&gt; I use three-argument open or equivalent. It&#39;s a pity that such a short<br/>&gt; operator isn&#39;t available to do something of wider utility.<br/>&gt;<br/>&gt; Same issues apply with several regexp features, such as /$/ (funny<br/>&gt; treatment of newline at end of string) and /\s/ (utf8 flag dependence).<br/>&gt; I see people get burned by the unexpectedly complex behaviour of<br/>&gt; these operators all the time. I use the more verbose, more explicit,<br/>&gt; non-obvious constructions that actually do what I mean. I don&#39;t hugely<br/>&gt; object to the extra typing, but I wish that the operators with plainer<br/>&gt; semantics were shorter and more accessible so that less nitpicky<br/>&gt; programmers would use them by default.<br/>&gt; <br/><br/>I don&#39;t understand. What is /$/ reasonably supposed to do? Do these <br/>theoretical people really get burned? Please point out a real-life <br/>program that uses /$/ that isn&#39;t mere theory.<br/><br/>&gt;&gt; I don&#39;t see the point. There is no value in restricting Perl&#39;s <br/>&gt;&gt; functionailty,<br/>&gt;&gt; <br/>&gt;<br/>&gt; I don&#39;t think anyone&#39;s arguing for the functionality to not be there.<br/>&gt; Just give it a longer name, that indicates that there&#39;s more going<br/>&gt; on than meets the eye. If we were starting from scratch, I&#39;d say<br/>&gt; that a plain honest-to-Ritchie file access should be called &quot;open&quot;,<br/>&gt; and the one that can run commands, expand shell variables, hack root,<br/>&gt; and whatnot should be called &quot;magic_open&quot;. See, nice descriptive names,<br/>&gt; with added Huffman value<br/><br/>Plain honest-to-Ritchie file access is obsolete. I want to see http:// <br/>automatically parsed. We&#39;re decades past the requirements you are <br/>raising, and in the last decade that open(2 args) has existed, I don&#39;t <br/>recall a single problem such as you describe.<br/><br/>Cheers,<br/>mark<br/><br/>-- <br/>Mark Mielke &lt;mark@mielke.cc&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl5.porters/2008/07/msg138751.html Sat, 26 Jul 2008 01:08:04 +0000