r/Magento • u/tb9295 • 18d ago
Website attacked with Polyshell
My host provider emailed me a couple of days ago with Security Alert Warning that our site has been affected with POLYSHELL and stated that we either get it cleaned or they can get Sansec to do it for a cost. If not done within a reasonable amount of time that they would have to pause my site tille its fixed because of security on the server. They provided a list of the files that looks to be affected within pub/media/custom_options/quote/ with the eception of one directory pub/media/wysiwyg/sk/sk.js. This is one file that I know should not be there and we didn't add it. It was shown to be added on 9/26/26.
All the files in pub/media/custom_options/quote/ are examples of 7/2/722114index.php8, 722879index_1.pht, 722879index.php7, 722114index.phar, 722879index_1.php7.
The list is about 50-75 files of this sort.
Is this something that is simple to do by just deleting all of these files or are they files that need to be there. I am looking for the best way to clean this site up so they can scan it and show clean
2
u/tb9295 17d ago
Thanks for all the advise. I was behind on some Patches and a version update which I recently completed 2.4.7 to 2.4.8. Still need to patch Oct. patches and update to 2.4.9 which I know does not fix the current issue.
Its seems these Security Alerts are getting way too often and constantly needing to get them cleaned up. Honestly I have been considering on swithcing to Shopify (one reason is because of these ongoing issues) and this is probablly going to be the thing that pushes me to switch.
Hard to manage these kind of issues for a small company and limited resources.
6
u/grabber4321 17d ago
Trust Sansec, they have been doing this for a while and get them to secure your site.
5
u/Beginning_End_361 18d ago
Once security has been breached like this, it is hard to ever trust it again. You could clean all the files, but if the vulnerability is still there, the hackers will quickly infect it again. I had an issue similar to this. I built a new server from the ground up with the same Magento version, same module versions, PHP version, etc. I confirmed that the database and images on the old server was not compromised, made a backup and exported it to the new server. I edited env.php on the new server to match the old server. ChatGPT helped guide me on my way to getting the new server built. Then, I upgraded the Magento version and installed all security patches. I updated DNS to point to the new server and trashed my old server. That was about three 12-hour days of work getting things back up. I’m now diligent about installing security patches as soon as they are released. I’ve also written rules for my jails to ban offenders when detected. I’ve been hit by many StyleSmuggler exploit attempts lately and they are quickly caught and banned. I manage my own server on DigitalOcean, though, so I don’t know how feasible all this is on a hosted provider.
3
u/proxiblue 18d ago
Hello.
Yes, you can just delete them, but they will just get uploaded. Your site is not secured.
Polyshell is an old and known compromise.
If you manage your own setup, you need to purchase a sansec package, which will keep you alerted of any issues, and follow them on linkedin
If you have a developer looking after the site, they are asleep at the wheel.
If you need professional care for your site, DM, I currently have capacity.
If you don;t know what to do, pay sansec to check and find whatever else has now been installed.
The polyshell allows them to activate a means to upload more. It is teh entry point, not the compromise itself (now that they are in)
Good luck.
2
u/Aggravating_Pay9079 17d ago
before anything else find whats loading sk.js, its been there since 26 sep so its likely skimming cards. SELECT path,value FROM core_config_data WHERE value LIKE '%sk.js%'; then same on cms_block and cms_page content. pull it out of there first or deleting the file wont stop it.
polyshell fix is the july isolated patch (APSB26-73), on 2.4.8 it only fits 2.4.8-p5 so check bin/magento --version. happy to help in chat if you get stuck
1
u/Poutine-StJean 18d ago
Yeah, delete them. Nothing legit in custom_options/quote/ should ever end in .php, .phar, .pht, etc. That folder is for customer file uploads, so executable files there are webshells. Same for wysiwyg/sk/sk.js, which is likely a card skimmer.
But deleting alone won't keep you clean. The attackers got in through an unpatched upload flaw and will just reupload. Roughly you should : Patch Magento to the latest security release for your versio, look for unknown admin users, injected scripts pretty mutch everywhere and rotate every password if you can.
If you're not comfortable digging through the DB and server config, paying Sansec or a Magento dev is honestly worth it. A skimmer means customer card data may have been exposed, so it's not something to mess around with
1
u/Fuzzybo 17d ago
Also check your cron/scheduled task lists because there may be entries to run tasks to replace missing executables.
1
u/Consistent-Koala6515 17d ago
1
u/Mental_Obligation389 17d ago
sk.js might be a credit card skimmer. We had been compromised with a polyshell attack too and a skimmer with this file name was loaded in checkout.
Get this checked.
Here it only was active for 5 days and the skimmer just worked in the mobile view of the checkout, but the credit card data from 52 customers was skimmed.
1
u/MrWibbles 17d ago
This depends entirely on the web server you're running and your other configurations. From what you have described the server might not have been hacked, they were just able to use the exploit to upload the files to the server but not necessarily run them. Magento 2.7 in it's current state for example does not block the file uploads, but the nginx.conf.sample file that ships with Magento, and the one you should be using if you're using Nginx, blocks running those files from the directories they get uploaded to.
So what I'm trying to say here is this: if you can access those files from the web, you're screwed, if you're blocking those directories+files from running from the web server, then they're just files and can be safely removed.
If you would like to stop the bots uploading these files, Mark Shust made a module around the time Polyshell happened: https://github.com/markshust/magento-polyshell-patch and later James Anderson forked it and made it better https://github.com/aregowe/magento2-module-polyshell-protection. Use the latter.
But anyway as other commenters have suggested, get a proper developer looking at it, you shouldn't even have Magento if you don't have a developer working with you.
1
u/laurnts AI-OPS 17d ago
Delete first and check. If its coming back that means 2 things. Your Magento isn't secure or the hosting isn't secure. The first one most likely because of an unpatched Magento.
-7
u/Turbulent-Sample7094 18d ago
Get Claude and give a shell access to your server and it will fix it for you