{"id":2168,"date":"2023-02-22T13:57:46","date_gmt":"2023-02-22T18:57:46","guid":{"rendered":"https:\/\/brianrthomas.com\/wp\/?p=2168"},"modified":"2023-02-22T13:58:23","modified_gmt":"2023-02-22T18:58:23","slug":"large-rule-sets-in-snort-on-pfsense-cause-php-memory-crash","status":"publish","type":"post","link":"https:\/\/brianrthomas.com\/wp\/2023\/02\/22\/large-rule-sets-in-snort-on-pfsense-cause-php-memory-crash\/","title":{"rendered":"Large rule sets in Snort on pfSense cause PHP memory crash"},"content":{"rendered":"<p>Ran into an issue in Snort on pfSense where the memory limit specified in \/usr\/local\/pkg\/snort\/snort.inc is insufficient and the service will crash shortly after launch.<\/p>\n<p>The part that needs to be increased is bolded.<\/p>\n<blockquote><p>&lt;?php<br \/>\n\/*<br \/>\n* snort.inc<br \/>\n*<br \/>\n* part of pfSense (https:\/\/www.pfsense.org)<br \/>\n* Copyright (c) 2006-2023 Rubicon Communications, LLC (Netgate)<br \/>\n* Copyright (c) 2009-2010 Robert Zelaya<br \/>\n* Copyright (c) 2013-2022 Bill Meeks<br \/>\n* All rights reserved.<br \/>\n*<br \/>\n* Licensed under the Apache License, Version 2.0 (the &#8220;License&#8221;);<br \/>\n* you may not use this file except in compliance with the License.<br \/>\n* You may obtain a copy of the License at<br \/>\n*<br \/>\n* http:\/\/www.apache.org\/licenses\/LICENSE-2.0<br \/>\n*<br \/>\n* Unless required by applicable law or agreed to in writing, software<br \/>\n* distributed under the License is distributed on an &#8220;AS IS&#8221; BASIS,<br \/>\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br \/>\n* See the License for the specific language governing permissions and<br \/>\n* limitations under the License.<br \/>\n*\/<\/p>\n<p>require_once(&#8220;pfsense-utils.inc&#8221;);<br \/>\nrequire_once(&#8220;config.inc&#8221;);<br \/>\nrequire_once(&#8220;functions.inc&#8221;);<br \/>\nrequire_once(&#8220;service-utils.inc&#8221;); \/\/ Need this to get RCFILEPREFIX definition<br \/>\nrequire_once(&#8220;pkg-utils.inc&#8221;);<br \/>\nrequire_once(&#8220;filter.inc&#8221;);<br \/>\nrequire_once(&#8220;xmlrpc_client.inc&#8221;);<br \/>\nrequire(&#8220;\/usr\/local\/pkg\/snort\/snort_defs.inc&#8221;);<\/p>\n<p>\/\/ Snort GUI needs some extra PHP memory space to manipulate large rules arrays<br \/>\n<strong>ini_set(&#8220;memory_limit&#8221;, &#8220;4096M&#8221;);<\/strong><\/p>\n<p>\/\/ Explicitly declare this as global so it works through function call includes<br \/>\nglobal $g, $rebuild_rules;<\/p>\n<p>\/* Rebuild Rules Flag &#8212; if &#8220;true&#8221;, rebuild enforcing rules and flowbit-rules files *\/<br \/>\n$rebuild_rules = false;<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>If that limit is too low, Snort will produce this error when it&#8217;s loading:<\/p>\n<blockquote><p>[25-Jan-2023 20:25:20 America\/New_York] PHP Fatal error: Allowed memory size of 402653184 bytes exhausted (tried to allocate 12288 bytes) in \/usr\/local\/pkg\/snort\/snort.inc on line 1093<\/p><\/blockquote>\n<p>The file is overwritten each time the pkg is updated so you have to make this change each time.<\/p>\n<p>N.B. The install doesn&#8217;t complete due to memory exhaustion, you can prevent this by going into Snort and removing a character from your oinkcode. This will prevent the rule set from being downloaded and allow the install to complete since it&#8217;s the enumeration of rules that fills the memory.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ran into an issue in Snort on pfSense where the memory limit specified in \/usr\/local\/pkg\/snort\/snort.inc is insufficient and the service will crash shortly after launch. The part that needs to be increased is bolded. &lt;?php \/* * snort.inc * * part of pfSense (https:\/\/www.pfsense.org) * Copyright (c) 2006-2023 Rubicon Communications, LLC (Netgate) * Copyright (c) &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"https:\/\/brianrthomas.com\/wp\/2023\/02\/22\/large-rule-sets-in-snort-on-pfsense-cause-php-memory-crash\/\">Continue reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2168","post","type-post","status-publish","format-standard","hentry","category-uncategorized","item-wrap"],"_links":{"self":[{"href":"https:\/\/brianrthomas.com\/wp\/wp-json\/wp\/v2\/posts\/2168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/brianrthomas.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brianrthomas.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brianrthomas.com\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/brianrthomas.com\/wp\/wp-json\/wp\/v2\/comments?post=2168"}],"version-history":[{"count":2,"href":"https:\/\/brianrthomas.com\/wp\/wp-json\/wp\/v2\/posts\/2168\/revisions"}],"predecessor-version":[{"id":2170,"href":"https:\/\/brianrthomas.com\/wp\/wp-json\/wp\/v2\/posts\/2168\/revisions\/2170"}],"wp:attachment":[{"href":"https:\/\/brianrthomas.com\/wp\/wp-json\/wp\/v2\/media?parent=2168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brianrthomas.com\/wp\/wp-json\/wp\/v2\/categories?post=2168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brianrthomas.com\/wp\/wp-json\/wp\/v2\/tags?post=2168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}