{"issue":{"state":"open","pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"milestone":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/d1588981e0248aaa0174906c99df180e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"d1588981e0248aaa0174906c99df180e","url":"https://api.github.com/users/petdance","login":"petdance","id":41100},"assignee":null,"updated_at":"2011-11-01T05:35:27Z","labels":[{"name":"bug","color":"AF3AC4","url":"https://api.github.com/repos/petdance/scratch/labels/bug"},{"name":"core","color":"683FB1","url":"https://api.github.com/repos/petdance/scratch/labels/core"},{"name":"Pri-critical","color":"572A2B","url":"https://api.github.com/repos/petdance/scratch/labels/Pri-critical"},{"name":"Sev-high","color":"6215BD","url":"https://api.github.com/repos/petdance/scratch/labels/Sev-high"}],"comments":0,"closed_at":null,"url":"https://api.github.com/repos/petdance/scratch/issues/621","body":"Here's a snippet of strace output after I accidentally ran parrot-nqp in a directory with a Regex.pbc file:\r\n\r\n{{{\r\nstat64(\"./Regex.pbc\", {st_mode=S_IFREG|0644, st_size=100432, ...}) = 0\r\nopen(\"./Regex.pbc\", O_RDONLY|O_LARGEFILE) = 3\r\nstat64(\"./P6object.pbc\", 0xbf9ee9bc)    = -1 ENOENT (No such file or directory)\r\nstat64(\"./P6object.pir\", 0xbf9ee9bc)    = -1 ENOENT (No such file or directory)\r\nstat64(\"./P6object.pasm\", 0xbf9ee9bc)   = -1 ENOENT (No such file or directory)\r\nstat64(\"./P6object.pbc\", 0xbf9ee9bc)    = -1 ENOENT (No such file or directory)\r\nstat64(\"/usr/local/./P6object.pbc\", 0xbf9ee9bc) = -1 ENOENT (No such file or directory)\r\nstat64(\"/usr/local/./P6object.pir\", 0xbf9ee9bc) = -1 ENOENT (No such file or directory)\r\nstat64(\"/usr/local/./P6object.pasm\", 0xbf9ee9bc) = -1 ENOENT (No such file or directory)\r\nstat64(\"/usr/local/./P6object.pbc\", 0xbf9ee9bc) = -1 ENOENT (No such file or directory)\r\nstat64(\"/usr/local/lib/parrot/2.3.0-devel/library/P6object.pbc\", {st_mode=S_IFREG|0644, st_size=18448, ...}) = 0\r\nstat64(\"/usr/local/lib/parrot/2.3.0-devel/library/P6object.pbc\", {st_mode=S_IFREG|0644, st_size=18448, ...}) = 0\r\nstat64(\"/usr/local/lib/parrot/2.3.0-devel/library/P6object.pbc\", {st_mode=S_IFREG|0644, st_size=18448, ...}) = 0\r\nstat64(\"/usr/local/lib/parrot/2.3.0-devel/library/P6object.pbc\", {st_mode=S_IFREG|0644, st_size=18448, ...}) = 0\r\nopen(\"/usr/local/lib/parrot/2.3.0-devel/library/P6object.pbc\", O_RDONLY|O_LARGEFILE) = 3\r\n}}}\r\n\r\nParrot has taken Regex.pbc in the current directory before even checking for it in the standard libraries.  The same behavior occurs with all other Parrot-based programs which use installed libraries.  This provides an attack vector against Parrot users:\r\n\r\n 1. Wait for Perl6-on-Parrot to hit the big time.\r\n 1. Distribute a shady tarball containing a malicious P6Regex.pbc inside it.\r\n 1. The victim unpacks the tarball and attempts to analyze the contents.\r\n 1. The user runs his Perl 6 based editor.\r\n 1. Rakudo loads Perl6.pbc from the current directory.  My code is now running.\r\n\r\nIt's probably best to follow Perl 5's example here:\r\n\r\n{{{\r\n$ perl -V\r\n...\r\n  @INC:\r\n    /usr/local/lib/perl5/site_perl/5.12.0/i686-linux-thread-multi\r\n    /usr/local/lib/perl5/site_perl/5.12.0\r\n    /usr/local/lib/perl5/5.12.0/i686-linux-thread-multi\r\n    /usr/local/lib/perl5/5.12.0\r\n    .\r\n}}}\r\n\r\nWith the current directory at the end, installed programs which use only installed libraries will never be tricked into running code in the current directory.  Hopefully it is not too common for installed programs to reference nonexistant libraries.\r\n\r\nTrac ID #1589","html_url":"https://github.com/petdance/scratch/issues/621","title":"Move . to the end of the library search path","number":621,"id":2106308,"created_at":"2011-11-01T05:35:27Z"},"action":"opened"}