Currently Polyshell is mass hitting many servers.
- Install Sansec Shield to protect your shop this and future attacks
- Install the backport of the Magento 2.4.9 patch build by Mark Shust
- Apply the NGINX contents below to your configuration to not be affected by conflicting
location ... {}rules
To not hit Magento at all, apply the files below to your NGINX configuration.
Currently some sites have rules to forward *.php to the PHP backend, uploading a file to /media/custom_options/a/b/index.php
can still be forwarded to the backend despite having the rule:
location *.php {
# send to php
fastcgi_...;
}
location /media/custom_options {
deny all;
return 403;
}The first location rule will send the file to the backend.
By applying both patches below, you are not affected by the location rules and will return proper 403's.
- Copy the contents of http.polyshell_blocked.conf to
/etc/nginx/conf.d/http.polyshell_blocked.conf - Open your server section and add theh contents of server.polyshell_blocked.conf in the server section.
If you rely on services that still need to access the rest endpoint, add them to the $polyshell_blocked_addr map.
Allowing is simple as
map $remote_addr $polyshell_blocked_addr {
127.0.0.1 0; # allow localhost
10.10.0.0/16 0; # allow the 10.10.*.* subnet
default 1;
}If urls should change, you can use the $polyshell_blocked_method_uri map.
It combines METHOD (POST|GET|DELETE|PATCH|PUT) /path/to/server for matching.
On Hypernode you can apply this patch as easy as one two three.
Blocking is done before it reaches the backend.
- copy
http.polyshell_blocked.confto~/nginx/http.polyshell_blocked.conf - list your active domains
hypernode-manage-vhosts --list --format json | jq -r '. | keys | .[]' - Copy
server.polyshell_blocked.confto each~/nginx/{DOMAIN}/pub.polyshell_blocked.conf - Nginx will reload automatically
From the web interface.
- Login and navigate to your server
- Edit the
NGINX.CONF(button) configuration, add contents ofhttp.polyshell_blocked.confto thenginx.confin thehttp{...}section. - Select your site from list, edit the rules, add contents of
server.polyshell_blocked.confto the/etc/nginx/sites-available/maxcluster.hyva.io/userdefined.conf.initsection.
Thanks to Sansec, publishing their excelent research https://sansec.io/research/magento-polyshell
Sansec tracks active attacks around the Globe.