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

premjith's avatar

Laravel | Malware issue

Hi,

i am facing malware attack on my server. Hackers uploading malicious files on my laravel folders . i changed vendor folder write permissions in file manager. But issue not solved yet. i am facing issue only in my laravel folder.

Current version : 5.3.31

How to solve this issue ? Can anyone Help me Please?

0 likes
25 replies
bobbybouwmann's avatar

Are you using shared hosting? How do you have your files on the server?

grubi's avatar

Already changed passwords for ftp and ssh?

AntLusher's avatar

Dedicated or VPS? Close your ssh ports to the world, and add your ip. You will probably have a file deep in dir that's sporning more files. Could be your frontend too. Some dodgy JS that's been written via php.

I would check your db too.

Snapey's avatar

hopefully public folder is your document root and your .env is not accessible?

jlrdw's avatar

What company is hosting your server, and has others been attacked as well or is it isolated to you.

And I hope you have some good backups, if that's the case I would use one well before the attack.

I would also check all the database records from a day or two before the attack all the way to the end. But hopefully you were using blade and validating your data. Blade automatically uses htmlspecialchars.

Just a suggestion.

Snapey's avatar

don't try fixing it, blow it all away and redeploy

premjith's avatar

@antlusher Dedicated server. We are using laravel framework for admin panel.we have no frontend. Hackers uploading malicious files in public_html and sub folders.

premjith's avatar

@snapey Yes and .env file is hidden in server. After attack, we removed all files in server and uploaded backup files. But every morning hackers uploading malicious files ( malicious index.php, wp_admin worpdress folders to my server ).

[ Sorry for my bad english ]

Snapey's avatar

how have you deployed laravel? why do you mention public_html folder? Laravel has no such folder

premjith's avatar

@snapey public_html -> server root folder. Under this folder, we uploaded all laravel files.

premjith's avatar

@bobbybouwmann we already discussed this issue with server team. Server team saying that they looking on this issue. But issue not solved yet.

Hackers daily uploading malicious files in all sub folders. We need to block uploading these files. ( In our code , we are not using file upload feature or any other upload feature )

bobbybouwmann's avatar

The fact that they have access to the server is the biggest problem here. You need to block this on server level. You can't block this on application level.

Anyway, the support team should be able to protect the server with SSH access only for the time being to solve this right?

mgdev's avatar

@premjith Have you solved the issue?, we faced the same issue, wp-admin, wp-include, and some unknown PHP files being uploaded, Laravel version is 7

empty the public_html folder the files are generated again.

Snapey's avatar

@mgdev why do you even have a public_html folder? I don't see that as part of the framework....

premjith's avatar

@mgdev I had the same problem on my dedicated server. It had Laravel along with WordPress.

What I did was set all file permissions to 0555 inside the server's public_html folder. ( Disabled file write permission ) Then my problem was solved.

1 like
Snapey's avatar

Sounds like you put all your project files on the web server document root. This is not what you should do and being hacked is what every post on the subject will tell you will happen.

Only the public folder should be published by your Web server

3 likes

Please or to participate in this conversation.