{"id":24117,"date":"2022-02-02T14:21:03","date_gmt":"2022-02-02T14:21:03","guid":{"rendered":"https:\/\/1-grid.com\/knowledge\/mod_security-protecting-your-site-from-code-injection\/"},"modified":"2023-10-19T12:58:57","modified_gmt":"2023-10-19T12:58:57","slug":"mod_security-protecting-your-site-from-code-injection","status":"publish","type":"ht_kb","link":"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/","title":{"rendered":"Mod_security: Protecting your site from code injection"},"content":{"rendered":"<blockquote><p>This article provides you with information regarding why Mod_security application firewall is so important in both shared and VPS environments.<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2><strong>What is mod_security?<\/strong><\/h2>\n<p>Apache (Your web server software) comes with a module called &#8220;mod_security&#8221; that protects your website from attackers that compromise your site through the web URL&#8217;s. Code can be added to the end of your web URL that can contains SQL statements. This SQL statement can delete, insert data, or do other damages to your website when mod_security is disabled. A common URL injection looks like the following:<\/p>\n<pre style=\"padding: 2px; font: 400 12px \/ 1.5 'Courier New', Courier, monospace; color: #000000; border-radius: 4px; display: block; word-break: break-all; overflow-wrap: break-word; background: #f2f2f2; margin: 1.5em 0px 1.5em 20px; border: 1px solid #696969; vertical-align: baseline; white-space: pre; max-width: 575px; overflow: auto; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;\">http:\/\/www.domain.com\/index.php?username=admin'\"&gt;DROP%20TABLE%20wp-users--<\/pre>\n<p>In this case, the database table called users will be deleted from the database with the DROP statement. Servers running mod_security will flag that URL as a Hack attempt and result in a 406 error.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2><strong>How do I work around mod_security?<\/strong><\/h2>\n<p>&nbsp;<\/p>\n<p>If you are getting 406 errors on your site due to mod_security you can do one of the following:<\/p>\n<p>&nbsp;<\/p>\n<ul style=\"margin-bottom: 1.5em; margin-left: 0px; padding: 0px 0px 0px 3.333em; border: 0px; font-weight: 400; font-size: 13px; font-family: lato, Arial, sans-serif; list-style-type: square; color: #222222; text-align: start; text-indent: 0px;\">\n<li>Remove the plugin \/ php code causing it and use a different plugin or php code.<\/li>\n<li>Disable mod_security<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><strong>How do I disable mod_security?<\/strong><\/h2>\n<p>&nbsp;<\/p>\n<p>**Note: The Mod Security Manager in cPanel is not working currently. Please contact \u00a0our <a href=\"https:\/\/1-grid.com\/web-hosting\/#livechat\" target=\"_blank\" rel=\"noreferrer noopener\">Support Center<\/a>\u00a0 if you need assistance disabling a mod security rule. We apologize for any inconvenience this may cause.<\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<p><span style=\"box-sizing: border-box; font-size: 14px;\"><strong>TIP:<\/strong><\/span><span style=\"box-sizing: border-box; color: #333333; font-family: Helvetica, sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; background-color: #fefefe; font-size: 14px;\"><strong>\u00a0<\/strong>For more articles on cPanel please see our <a style=\"box-sizing: border-box; background-color: transparent; color: #2753d7; text-decoration: none; font-family: Tahoma, Verdana, Segoe, sans-serif !important;\" href=\"https:\/\/1-grid.com\/knowledge\/category\/web-hosting\/\" target=\"_blank\" rel=\"noreferrer noopener\">cPanel category<\/a>. Alternatively should you wish to c<a style=\"box-sizing: border-box; background-color: transparent; color: #2753d7; text-decoration: none; font-family: Tahoma, Verdana, Segoe, sans-serif !important;\" href=\"https:\/\/1-grid.com\/web-hosting\/#livechat\" target=\"_blank\" rel=\"noreferrer noopener\">ontact our Support Center please click here.<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article provides you with information regarding why Mod_security application firewall is so important in both shared and VPS environments. &nbsp; &nbsp; What is mod_security? Apache (Your web server software) comes with a module called &#8220;mod_security&#8221; that protects your website from attackers that compromise your site through the web URL&#8217;s&#8230;.<\/p>\n","protected":false},"author":21,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"ht-kb-category":[1190],"ht-kb-tag":[200,431,470,516,1278,782,919,1112,1161],"class_list":["post-24117","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-web-security","ht_kb_tag-code","ht_kb_tag-from","ht_kb_tag-hosting","ht_kb_tag-infection","ht_kb_tag-mod_security","ht_kb_tag-protect","ht_kb_tag-site","ht_kb_tag-website","ht_kb_tag-your"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Mod_security: Protecting Your Site From Code Injection<\/title>\n<meta name=\"description\" content=\"Protect your site from code injection securely with our step-by-step guide: 1-grid Knowledge Base\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mod_security: Protecting Your Site From Code Injection\" \/>\n<meta property=\"og:description\" content=\"Protect your site from code injection securely with our step-by-step guide: 1-grid Knowledge Base\" \/>\n<meta property=\"og:url\" content=\"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/\" \/>\n<meta property=\"og:site_name\" content=\"1-grid Knowledge Base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/1grid.co.za\/\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-19T12:58:57+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@1grid_hosting\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/\",\"url\":\"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/\",\"name\":\"Mod_security: Protecting Your Site From Code Injection\",\"isPartOf\":{\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#website\"},\"datePublished\":\"2022-02-02T14:21:03+00:00\",\"dateModified\":\"2023-10-19T12:58:57+00:00\",\"description\":\"Protect your site from code injection securely with our step-by-step guide: 1-grid Knowledge Base\",\"breadcrumb\":{\"@id\":\"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/1grid.co.za\/knowledge\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Mod_security: Protecting your site from code injection\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#website\",\"url\":\"https:\/\/1grid.co.za\/knowledge\/\",\"name\":\"1-Grid Domain Hosting Knowledge Base\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/1grid.co.za\/knowledge\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#organization\",\"name\":\"1-Grid Domain Hosting Knowledge Base\",\"url\":\"https:\/\/1grid.co.za\/knowledge\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/1grid.co.za\/knowledge\/wp-content\/uploads\/2023\/01\/1-grid-logo-color.svg\",\"contentUrl\":\"https:\/\/1grid.co.za\/knowledge\/wp-content\/uploads\/2023\/01\/1-grid-logo-color.svg\",\"width\":100,\"height\":100,\"caption\":\"1-Grid Domain Hosting Knowledge Base\"},\"image\":{\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/1grid.co.za\/\",\"https:\/\/twitter.com\/1grid_hosting\",\"https:\/\/www.instagram.com\/1grid_hosting\/\",\"https:\/\/za.linkedin.com\/company\/1-grid\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mod_security: Protecting Your Site From Code Injection","description":"Protect your site from code injection securely with our step-by-step guide: 1-grid Knowledge Base","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/","og_locale":"en_US","og_type":"article","og_title":"Mod_security: Protecting Your Site From Code Injection","og_description":"Protect your site from code injection securely with our step-by-step guide: 1-grid Knowledge Base","og_url":"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/","og_site_name":"1-grid Knowledge Base","article_publisher":"https:\/\/www.facebook.com\/1grid.co.za\/","article_modified_time":"2023-10-19T12:58:57+00:00","twitter_card":"summary_large_image","twitter_site":"@1grid_hosting","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/","url":"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/","name":"Mod_security: Protecting Your Site From Code Injection","isPartOf":{"@id":"https:\/\/1grid.co.za\/knowledge\/#website"},"datePublished":"2022-02-02T14:21:03+00:00","dateModified":"2023-10-19T12:58:57+00:00","description":"Protect your site from code injection securely with our step-by-step guide: 1-grid Knowledge Base","breadcrumb":{"@id":"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/1grid.co.za\/knowledge\/mod_security-protecting-your-site-from-code-injection\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/1grid.co.za\/knowledge\/"},{"@type":"ListItem","position":2,"name":"Mod_security: Protecting your site from code injection"}]},{"@type":"WebSite","@id":"https:\/\/1grid.co.za\/knowledge\/#website","url":"https:\/\/1grid.co.za\/knowledge\/","name":"1-Grid Domain Hosting Knowledge Base","description":"","publisher":{"@id":"https:\/\/1grid.co.za\/knowledge\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/1grid.co.za\/knowledge\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/1grid.co.za\/knowledge\/#organization","name":"1-Grid Domain Hosting Knowledge Base","url":"https:\/\/1grid.co.za\/knowledge\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/1grid.co.za\/knowledge\/#\/schema\/logo\/image\/","url":"https:\/\/1grid.co.za\/knowledge\/wp-content\/uploads\/2023\/01\/1-grid-logo-color.svg","contentUrl":"https:\/\/1grid.co.za\/knowledge\/wp-content\/uploads\/2023\/01\/1-grid-logo-color.svg","width":100,"height":100,"caption":"1-Grid Domain Hosting Knowledge Base"},"image":{"@id":"https:\/\/1grid.co.za\/knowledge\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/1grid.co.za\/","https:\/\/twitter.com\/1grid_hosting","https:\/\/www.instagram.com\/1grid_hosting\/","https:\/\/za.linkedin.com\/company\/1-grid"]}]}},"_links":{"self":[{"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb\/24117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/comments?post=24117"}],"version-history":[{"count":1,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb\/24117\/revisions"}],"predecessor-version":[{"id":29659,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb\/24117\/revisions\/29659"}],"wp:attachment":[{"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/media?parent=24117"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb-category?post=24117"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb-tag?post=24117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}