当前,当查询字符串参数值看起来像SQL命令时(例如,如果它包含\'
和and
):
domain.com/path/to/page?foo=a%27%20or%20%27a
相反,这应该是打开页面的有效url。我认为这个问题应该在
.htaccess
文件目前
.htaccess
如下所示:
# BEGIN s2Member GZIP exclusions
<IfModule rewrite_module>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (^|\\?|&)s2member_file_download\\=.+ [OR]
RewriteCond %{QUERY_STRING} (^|\\?|&)no-gzip\\=1
RewriteRule .* - [E=no-gzip:1]
# Force Trailing Slash
RewriteCond %{REQUEST_URI} /+[^\\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
# Force Download Rule
<FilesMatch "\\.(mp4|mp3|jpg|jpeg|pdf|png|tif|mobi|epub|azk)">
<If "%{QUERY_STRING} =~ /dl/">
ForceType application/octet-stream
Header set Content-disposition "attachment"
</If>
</FilesMatch>
</IfModule>
# END s2Member GZIP exclusions
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
我们应该在某个地方将这些特殊字符列入白名单,例如
%27
和特殊SQL关键字(如
and
). 在第一行之前添加此行
RewriteCond
行,未进行任何更改:
RewriteCond %{QUERY_STRING} (;|<|>|\'|"|\\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\\*|union|select|insert|drop|delete|update|cast|create|char|convert|alter|declare|order|script|set|md5|benchmark|encode) [NC,OR]
(摘自
this page)
如何解决这个问题?