Giter Site home page Giter Site logo

Comments (4)

mlawren avatar mlawren commented on August 28, 2024

Appears to have been introduced by 025d72a (defend iterator against symlink attack). Possibly the following patch implements what was intended correctly:

diff --git a/lib/Path/Tiny.pm b/lib/Path/Tiny.pm
index 6ae2e32..85d8633 100644
--- a/lib/Path/Tiny.pm
+++ b/lib/Path/Tiny.pm
@@ -512,7 +512,7 @@ sub iterator {
                 opendir( $dh, $current->[PATH] )
                     or _throw( 'opendir', [$dh, $current->[PATH]] );
                 $dirs[0] = $dh;
-                if ( -l $dirs[0] && ! $args->{follow_symlinks} ) {
+                if ( -l $current->[PATH] && ! $args->{follow_symlinks} ) {
                     # Symlink attack! It was a real dir, but is now a symlink!
                     # N.B. we check *after* opendir so we don't have a race
                     shift @dirs and next;

from path-tiny.

 avatar commented on August 28, 2024

Thanks for the bug report. I didn't see anything in the docs that
suggested it wouldn't work (and I didn't get any warnings in testing, which
is odd).

Your "fix" might be the best alternative. There is still a race condition
in there, but harder to attack, since it would require someone to swap a
symlink for a dir (before the opendir) and then swap it back (before the
path check).

And if there's no way for the OS to know if an open handle came from a
symlink at all, then the point is moot, I guess.

David

David Golden [email protected]
Take back your inbox!http://www.bunchmail.com/
Twitter/IRC: @xdg

from path-tiny.

 avatar commented on August 28, 2024

Strange. That warning disappeared in 5.16.

I've fixed it per your suggestion and shipped 0.019.

from path-tiny.

mlawren avatar mlawren commented on August 28, 2024

Thanks for the quick response.

from path-tiny.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.