Skip to content

Security: Path::Tiny::tempdir does not check for symlinks in DIR, leading to potential symlink attack #306

@phongguyen1

Description

@phongguyen1

The Path::Tiny::tempdir method does not verify if the DIR parameter is a symbolic link (symlink).

This allows the creation of temporary directories in unintended locations pointed to by symlinks, potentially exposing the application to symlink attacks.

This behavior poses a security risk, especially in multi-user environments where directories like /tmp are writable by all users.

I created a symlink: ln -s /tmp/phongexploit /tmp/phongdir

Image

I think we should check if the DIR parameter is a symlink and either:

  • Throw an error if a symlink is detected, or
  • Resolve the symlink to its real path and create the temporary directory there, ensuring the operation is safe and predictable.

I used Perl v5.40.1, Path::Tiny v0.146

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions