Skip to content

Instantly share code, notes, and snippets.

@jonpugh
Last active April 13, 2018 20:40
Show Gist options
  • Save jonpugh/88cfb0aad1ef18c0016486557fcb28fe to your computer and use it in GitHub Desktop.
Save jonpugh/88cfb0aad1ef18c0016486557fcb28fe to your computer and use it in GitHub Desktop.
Web server configuration to mitigate Drupal SA-CORE-2018-002. Written by trusted sources. Patch your sites!!
# Apache configuration to block attempts to exploit the SA
# If using Aegir, you can put this file in /var/aegir/config/server_master/apache/post.d/SA-CORE-2018-002.conf
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} (.*)(23value|23default_value|element_parents=%23)(.*) [NC]
RewriteCond %{REQUEST_METHOD} POST [NC]
RewriteRule ^.*$ - [R=403,L]
</IfModule>
# NGINX configuration to block attempts to exploit the SA
# If using Aegir, you can put this file in /var/aegir/config/server_master/nginx/post.d/SA-CORE-2018-002.conf
set $rce "ZZ";
if ( $query_string ~* (23value|23default_value|element_parents=%23) ) {
set $rce "A";
}
if ( $request_method = POST ) {
set $rce "${rce}B";
}
if ( $rce = "AB" ) {
return 403;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment