Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

silverreve23's avatar

Symlinks in project

Hi guys. Let's consider the topic of allowing a server to create symbolic links. What do you think about security?

0 likes
8 replies
bobbybouwmann's avatar

You need to make sure only the same user has access to your symlinked directory. This way there is no difference for security. Also, make sure you don't put this symlink directory just in a directory that is exposed to the web like the public directory. You can do it with images that are publicly available, but with uploaded files, you really don't want this!

1 like
silverreve23's avatar

Yes, but it does allow the attacker access to the entire system!

Sinnbeck's avatar

Well that totally depends on what you do. If you allow the user to specify what should be symlinked to what, then yes they can get access to the whole system.

If you only symlink things in storage to things in public that would be safer. If you only symlink things that aren't public, you are even safer.

If you tell us exactly what you plan to symlink, we can hel you better

silverreve23's avatar

I am a site developer and have allowed the server to route through symbolic links. For example: In the public/ directory I created a symbolic link to the storage/ folder. At the time: A hacker somehow found a hole in the site and created a symbolic link on /etc/sudoers!

Sinnbeck's avatar

There can be alot of reasons why it happened. Perhaps the hacker was able to upload a php file or some other form of infected file due to missing validation. Perhaps the server was not updated with security patches. Some unsafe package was used that gave access to the file system.

silverreve23's avatar

Yes, so i think that permission to a symbolic link is quite dangerous! I believe that one of the solutions it to configure a server with access only to a specific symbolic link!

Sinnbeck's avatar

Can you explain your reasoning?

Also curious. Did the www user have permission to anything else than the laravel folder (it shouldn't)? Making a symlink to the sudoers file should not be possible for a user with no rights.

silverreve23's avatar

Making a symlink to the sudoers file to example in the public directory

Please or to participate in this conversation.