Skip to content

Instantly share code, notes, and snippets.

@iAugur
Last active March 30, 2021 13:02
Show Gist options
  • Save iAugur/4233bb9e251a51d661994471db176110 to your computer and use it in GitHub Desktop.
Save iAugur/4233bb9e251a51d661994471db176110 to your computer and use it in GitHub Desktop.
# block if request has header HTTP_USER_AGENTT
# e.g. Useful to protect against the PHP "zerodium" backdoor
# https://thehackernews.com/2021/03/phps-git-server-hacked-to-insert-secret.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:HTTP_USER_AGENTT} !^$
RewriteRule ^ - [F]
</IfModule>
# Another approach would be to always unset the header from the request
# before PHP receives it
<IfModule mod_headers.c>
RequestHeader unset HTTP_USER_AGENTT early
</IfModule>
# Test: curl -v -I 'https://yourwebsite.com/' -H 'HTTP_USER_AGENTT:anyvalue but could start with zerodium'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment