{"id":2445,"date":"2015-07-26T16:53:01","date_gmt":"2015-07-26T16:53:01","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=2445"},"modified":"2015-07-26T16:53:01","modified_gmt":"2015-07-26T16:53:01","slug":"find-and-disable-specific-modsecurity-rules","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2015\/07\/26\/find-and-disable-specific-modsecurity-rules\/","title":{"rendered":"Find and disable specific ModSecurity rules"},"content":{"rendered":"<p>ModSecurity uses can help block potential attack attempts from malicious users, but sometimes it can also block legitimate requests. <\/p>\n<p>Note: Using SecRuleEngine Off in your modsecurity configuration, you won&#8217;t want to put that in your ModSecurity configuration file. As that completely turns off ModSecurity. The SecRuleRemoveById setting is used instead to only disable one specific rule.<\/p>\n<p>If you are seeing errors in you apache log files for a domain such as:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n&#x5B;Sat Jul 25 16:34:57 2015] &#x5B;error] &#x5B;client ??.7.??.??] ModSecurity: Access denied with code 406 (phase 2). Pattern match &quot;(?:\\\\\\\\b(?:(?:type\\\\\\\\b\\\\\\\\W*?\\\\\\\\b(?:text\\\\\\\\b\\\\\\\\W*?\\\\\\\\b(?:j(?:ava)?|ecma|vb)|application\\\\\\\\b\\\\\\\\W*?\\\\\\\\bx-(?:java|vb))script|c(?:opyparentfolder|reatetextrange)|get(?:special|parent)folder|iframe\\\\\\\\b.{0,100}?\\\\\\\\bsrc)\\\\\\\\b|on(?:(?:mo(?:use(?:o(?:ver|ut)|down|move|up)|ve)| ...&quot; at REQUEST_FILENAME. &#x5B;file &quot;\/usr\/local\/apache\/conf\/modsec2.user.conf&quot;] &#x5B;line &quot;111&quot;] &#x5B;id &quot;1234123404&quot;] &#x5B;msg &quot;Cross-site Scripting (XSS) Attack&quot;] &#x5B;data &quot;.cookie&quot;]&#x5B;severity &quot;CRITICAL&quot;] &#x5B;tag &quot;WEB_ATTACK\/XSS&quot;] &#x5B;hostname &quot;domain.com&quot;] &#x5B;uri &quot;\/skin\/frontend\/base\/default\/js\/cadence\/lib\/jquery.cookie.js&quot;] &#x5B;unique_id &quot;VbQdIdg3u9IAAB9DPQkAAAAH&quot;]\n\n<\/pre>\n<p>Mod _security is doing its job. If this is a valid script, you can make a change and allow it.<br \/>\nRun the following from ssh:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# grep ModSecurity \/usr\/local\/apache\/logs\/error_log | sed -e &#039;s#^.*\\&#x5B;id &quot;\\(&#x5B;0-9]*\\).*hostname &quot;\\(&#x5B;a-z0-9\\-\\_\\.]*\\)&quot;\\].*uri &quot;#\\1 \\2 #&#039; | cut -d\\&quot; -f1 | sort -n | uniq -c | sort -n\n<\/pre>\n<p>The results will look like this:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n # 100 1234123404 www.domain.com \/skin\/frontend\/base\/default\/js\/cadence\/lib\/jquery.cookie.js\n\n<\/pre>\n<p>ModSecurity rule ID 1234123404 has been triggered at least 100 times when accessing \/skin\/frontend\/base\/default\/js\/cadence\/lib\/jquery.cookie.js file.<\/p>\n<p>In order to disable just the specific ModSecurity rule for the 1234123404 rule, run the following command: <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# echo &quot;SecRuleRemoveById 1234123404&quot; &gt;&gt; \/usr\/local\/apache\/conf\/userdata\/std\/2\/userna5\/domain.com\/modsec.conf\n\n<\/pre>\n<p>You can also search for the rule in WHM\/cPanel at Home \u00bbSecurity Center \u00bbModSecurity&#x2122; Tools  \u00bb Rules List<\/p>\n<p>Note the error in the log file &#8211; the ID:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# &#x5B;id &quot;1234123404&quot;]\n<\/pre>\n<p>This is the rule. Search for this at Home \u00bbSecurity Center \u00bbModSecurity&#x2122; Tools  \u00bb Rules List. <\/p>\n<p><a href=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2015\/07\/rules.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2015\/07\/rules.png\" alt=\"rules\" width=\"1039\" height=\"422\" class=\"alignnone size-full wp-image-2453\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2015\/07\/rules.png 1039w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2015\/07\/rules-300x122.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2015\/07\/rules-1024x416.png 1024w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2015\/07\/rules-768x312.png 768w\" sizes=\"auto, (max-width: 1039px) 100vw, 1039px\" \/><\/a><\/p>\n<p>You can click disable to allow the script.<\/p>\n<p><a href=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2015\/07\/disable.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2015\/07\/disable.png\" alt=\"disable\" width=\"1033\" height=\"812\" class=\"alignnone size-full wp-image-2454\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2015\/07\/disable.png 1033w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2015\/07\/disable-300x236.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2015\/07\/disable-1024x805.png 1024w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2015\/07\/disable-768x604.png 768w\" sizes=\"auto, (max-width: 1033px) 100vw, 1033px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ModSecurity uses can help block potential attack attempts from malicious users, but sometimes it can also block legitimate requests. Note: Using SecRuleEngine Off in your modsecurity configuration, you won&#8217;t want to put that in your ModSecurity configuration file. As that completely turns off ModSecurity. The SecRuleRemoveById setting is used instead to only disable one specific &#8230; <a title=\"Find and disable specific ModSecurity rules\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2015\/07\/26\/find-and-disable-specific-modsecurity-rules\/\" aria-label=\"Read more about Find and disable specific ModSecurity rules\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,20,67,123],"tags":[],"class_list":["post-2445","post","type-post","status-publish","format-standard","hentry","category-apache","category-cpanel","category-mod_security","category-whm"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=2445"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2445\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=2445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=2445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=2445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}