Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Delete state, Reject & Block rules work perfectly fine

    Scheduled Pinned Locked Moved General pfSense Questions
    58 Posts 12 Posters 15.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      Supermule Banned
      last edited by

      Confirmed issue in OPNSense latest version as well.

      1 Reply Last reply Reply Quote 0
      • H Offline
        Harvy66
        last edited by

        @firewalluser:

        2.2.2 AMD 64 (Latest release version)

        Set up a pinger to ping something continuously, in my case I was using the wan IP address assigned by the ISP to my bridged modem.

        Initially the default block rule is in effect and will block the pinger.

        #1
        Add rule:
        Action: pass
        TCP/IP Version IPv4
        Protocol Any (havent tried anything more restrictive}
        Source Any
        Destination WAN net
        Log: Ticked

        Save rule & click Apply Changes button.

        Pinger starts getting TTL's back and logs show ping is passing through in the fw logs

        Now repeat #1 but change the rule from pass to block, save and click Apply Changes Button.
        Pinger still getting TTL's back and still shows ping passing through in the fw logs.

        What was running a "pinger"? Which interface was it connecting through? Which interface is the rule added to?

        I assume the rules on your LAN interface and pinging from a network device and attempting to ping your WAN IP.

        So the issue seems to be adding a block rule for ICMP then manually clearing the individual states doesn't seem to  stop the ping from still getting through?

        I wonder if it has to do with how ICMP "states" are being handled. ICMP is stateless protocol with no ports. The network stack may be misrepresenting what a state really is for ICMP just to keep the format the same.

        Try setting your ping to only ping once every 10 seconds, giving you enough time to delete all of the related states. It could be that as long as ANY ICMP state for the target rule exists, the firewall can't tell the difference. The default ping rate of once per seconds may not be enough time to let you delete all relevant states.

        Summary is my guess is this is something specific to ICMP and as long as any related ICMP state still exists, it'll continue to let "new States" to be created.

        1 Reply Last reply Reply Quote 0
        • S Offline
          Supermule Banned
          last edited by

          Even if you delete the rule, it keeps responding to ICMP.

          1 Reply Last reply Reply Quote 0
          • M Offline
            mer
            last edited by

            Is ICMP handled in the networking stack before handing packets off to PF or anything that has hooks in?

            1 Reply Last reply Reply Quote 0
            • S Offline
              Supermule Banned
              last edited by

              Its a network layer protocol so IMHO it should be.

              1 Reply Last reply Reply Quote 0
              • DerelictD Offline
                Derelict LAYER 8 Netgate
                last edited by

                Everyone knows deleting/changing rules doesn't kill existing states.  Not a bug.

                Chattanooga, Tennessee, USA
                A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                Do Not Chat For Help! NO_WAN_EGRESS(TM)

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Harvy66
                  last edited by

                  @mer:

                  Is ICMP handled in the networking stack before handing packets off to PF or anything that has hooks in?

                  ICMP can be blocked, so it has to go through PF.

                  @Supermule:

                  Even if you delete the rule, it keeps responding to ICMP.

                  This is a guess, but this is what I was getting after.

                  With TCP or UDP, it's not an issue because all states are a combination of IP and port and destroying a state actually destroys the flow. ICMP may internally map multiple flows through the same state and make it look like there are multiple states when there is really only one. You might be destroying pseudo-states, but not actually destroying the underlying state, which means new flows can be created. Resetting the state table forces all states to be destroyed, so it's not an issue.

                  My guess is if you do a "ping -t 8.8.8.8", then create a rule to block pings to 8.8.0.0/16, then attempt to ping 8.8.4.4, you won't be able to ping 8.8.4.4, but will be able to continue pinging 8.8.8.8 because a state already exists. But making "new" pings to 8.8.8.8 will work because of the magic happening that makes ICMP look like it actually has ports.

                  PF represents ICMP states in a strange way that looks like they have ports. My guess is it has something to do with how ICMP does not have a real layer4 and ICMP states are misrepresented to make you think you're destroying the underlying state.

                  LAN icmp 8.8.8.8:11309 <- 192.168.1.2:11309 0:0
                  LAN icmp 8.8.8.8:1 <- 192.168.1.2:1 0:0

                  Since ping defaults to every one second, if you destroy one of those states, but not both, with in one second, a new ping will go out and create a new pseudo state. Try setting ping to every 10 seconds, giving you enough time to destroy all of the ICMP states before another ping goes out.

                  I'd test it out myself, but I once made changes to the firewall that I forgot to apply, and a long while later created some other rules, applied them and broke the Internet for a few moments. Wife was furious because she was in the middle of something. Well, she's been in the middle of something non-stop, so I can't risk testing myself.

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    Supermule Banned
                    last edited by

                    But wouldnt it be great if the script actually took all states with either DST or SRC and killed every last one of them when you pressed apply when you change the rule?

                    I think thats what we actually want to happen when doing so.

                    @Derelict:

                    Everyone knows deleting/changing rules doesn't kill existing states.  Not a bug.

                    1 Reply Last reply Reply Quote 0
                    • DerelictD Offline
                      Derelict LAYER 8 Netgate
                      last edited by

                      It doesn't do that.  That would be a new feature request, not a bug.

                      Chattanooga, Tennessee, USA
                      A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                      DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                      Do Not Chat For Help! NO_WAN_EGRESS(TM)

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        heper
                        last edited by

                        i don't think i would want it to kill related states when creating a new rule …. this "feature' has saved me a couple of times when i did something stupid. (not locking myself out when i made a typo)

                        anyhow, i prefer to clear the states myself

                        1 Reply Last reply Reply Quote 0
                        • F Offline
                          firewalluser
                          last edited by

                          @Harvy66:

                          Summary is my guess is this is something specific to ICMP and as long as any related ICMP state still exists, it'll continue to let "new States" to be created.

                          Its not just ICMP, HTTPS which I have tested with the long youtube film that ran for over 2hrs 20mins despite various rules was also affected.  As its WAN states that need to be deleted the recent change to unbound/ DNS resolver ie the change to the DNS service also means lots of WAN states kept open which means lots of firewall rules wont be updated. I've got over 2000 wan states open to various name servers since I started this thread all of a sudden and my CPU load has gone up to just under 50% load which will further prevent any rule changes from working properly unless I reset all states.

                          @Derelict:

                          Everyone knows deleting/changing rules doesn't kill existing states.  Not a bug.

                          I didnt and I dont see any mention of deleting states in numerous online blogs detailing how to do XYZ, nor is it in the pfsense book and I dont see it mentioned often in the forums either. So whether "everyone" knows is a matter of opinion.

                          With ISA server we used to just restart the service which had the same effect of deleting the states, but if anything the Apply Changes button in the pfsense gui is a little misleading imo.

                          I will say that in the Reset States webpage in the gui, there is some text which says it may be neccessary to reset the states so if anything that text could also be reiterated on the rules webpage for safety sake although not my preferred option which is below.

                          @heper:

                          i don't think i would want it to kill related states when creating a new rule …. this "feature' has saved me a couple of times when i did something stupid. (not locking myself out when i made a typo)

                          anyhow, i prefer to clear the states myself

                          A new rule perhaps, but if you change an existing rule or even simply disable/enable an existing rule what then? Jump through some more hoops just to get the change to work, not everyone gets to charge by the hour.

                          And what if you have hundreds or thousands of states to delete one by one, it could be a never ending process because as you delete one state another could pop up from another device when a network and various devices have all been compromised with malware, ergo you never get to delete ALL the states so the new rules can never take effect.

                          So this leads you to one course of action, resetting all states in one go, which then renders the argument for a new rule perhaps mute point.

                          I've done similar but with multiple windows programs that check for the existence of each other, if one is not running, one of the running apps fires it up, if its been deleted it restores it, so not only can you not stop the various apps from running you cant even delete them, a similar technique is used with malware & viruses which you may or may not have had the pleasure of trying to fix for customers.

                          Besides there is also the point of inconsistent behaviour, why does deleting outward bound states not work, but deleting inbound states does work?

                          Inconsistent behaviour and misleading wording is the undoing of any good system.

                          @Supermule:

                          But wouldnt it be great if the script actually took all states with either DST or SRC and killed every last one of them when you pressed apply when you change the rule?

                          I think thats what we actually want to happen when doing so.

                          @Derelict:

                          It doesn't do that.  That would be a new feature request, not a bug.

                          How about this for a feature request. Two or three buttons that pop up when a rule change has occurred which can be:
                          1. Apply Changes - No State changes
                          2. Apply Changes - reset only affected states
                          3. Apply Changes - reset all states.

                          I would suggest it would be easiest and quickest to do buttons  1 & 3 for now because the code already exists in the existing Apply Changes button and the same for Reset Button in Diagnostics:Show States, Reset States tab so I doubt it would be too time consuming or difficult to merge the code together.

                          At least this way the gui becomes a reminder for breaking old habits and improves the experience for novice users who want to use pfsense in anger. I know CLI's have their fans, but Apple havent got to where they are to day by ignoring the gui experience.

                          I still havent got to the bottom of where this problem stems from though, as its been confirmed in OPNsense we still dont know if this is restricted to freebsd or a package used by freebsd which means other firewalls in other OS which use the package have this "backdoor" weakness, but might explain why the NSA were recommending opensource firewalls a while back if they have had their grubby mits over some code in advance.

                          Edit.

                          One other thought, is if the rules are only reset when the inward bound wan state is deleted, what if you are using an OPTx for an additional internet connection?
                          Do deleting the states not work for those interfaces as this appears to be the case currently when deleting outward bound states on OPTx interfaces. This could potentially be a bigger headache still unless all states are reset after every rule change.

                          Capitalism, currently The World's best Entertainment Control System and YOU cant buy it! But you can buy this, or some of this or some of these

                          Asch Conformity, mainly the blind leading the blind.

                          1 Reply Last reply Reply Quote 0
                          • H Offline
                            Harvy66
                            last edited by

                            @firewalluser:

                            @Harvy66:

                            Summary is my guess is this is something specific to ICMP and as long as any related ICMP state still exists, it'll continue to let "new States" to be created.

                            Its not just ICMP, HTTPS which I have tested with the long youtube film that ran for over 2hrs 20mins despite various rules was also affected.  As its WAN states that need to be deleted the recent change to unbound/ DNS resolver ie the change to the DNS service also means lots of WAN states kept open which means lots of firewall rules wont be updated. I've got over 2000 wan states open to various name servers since I started this thread all of a sudden and my CPU load has gone up to just under 50% load which will further prevent any rule changes from working properly unless I reset all states.

                            The original discussion was about how the block rule was not taking effect and allowing new ICMP states. Now that the discussion is changing into "how to kill existing states for a block rule", the topic has changed.

                            I think they already have a script for this and use it for scheduled rules. Maybe we just need a "kill all states" button under the edit window screen, allowing you to kill existing states for the current rule.

                            1 Reply Last reply Reply Quote 0
                            • S Offline
                              Supermule Banned
                              last edited by

                              Its simple. When changing one specific rule, all states for that rule should be killed. On all interfaces.

                              Only way the integrity of the firewall is kept.

                              1 Reply Last reply Reply Quote 0
                              • DerelictD Offline
                                Derelict LAYER 8 Netgate
                                last edited by

                                I didnt and I dont see any mention of deleting states in numerous online blogs detailing how to do XYZ, nor is it in the pfsense book and I dont see it mentioned often in the forums either. So whether "everyone" knows is a matter of opinion.

                                https://doc.pfsense.org/index.php/Firewall_Rule_Troubleshooting#Dangling_States

                                "Did you clear your states?" is asked like 5000 times a week here.

                                Chattanooga, Tennessee, USA
                                A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                                DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                                Do Not Chat For Help! NO_WAN_EGRESS(TM)

                                1 Reply Last reply Reply Quote 0
                                • S Offline
                                  Supermule Banned
                                  last edited by

                                  Thats really nice if you run a production scenario and altering 1 rule blows the connection to the rest….

                                  Including one self in a remote datacenter....!  :-[

                                  1 Reply Last reply Reply Quote 0
                                  • DerelictD Offline
                                    Derelict LAYER 8 Netgate
                                    last edited by

                                    Exactly why states should not be automatically cleared.

                                    Chattanooga, Tennessee, USA
                                    A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                                    DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                                    Do Not Chat For Help! NO_WAN_EGRESS(TM)

                                    1 Reply Last reply Reply Quote 0
                                    • DerelictD Offline
                                      Derelict LAYER 8 Netgate
                                      last edited by

                                      I still havent got to the bottom of where this problem stems from though

                                      what problem?

                                      Chattanooga, Tennessee, USA
                                      A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                                      DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                                      Do Not Chat For Help! NO_WAN_EGRESS(TM)

                                      1 Reply Last reply Reply Quote 0
                                      • S Offline
                                        Supermule Banned
                                        last edited by

                                        They should….for that specific rule and not the entire state tale ;)

                                        @Derelict:

                                        Exactly why states should not be automatically cleared.

                                        1 Reply Last reply Reply Quote 0
                                        • DerelictD Offline
                                          Derelict LAYER 8 Netgate
                                          last edited by

                                          Submit a feature request.  It's not a bug.

                                          Chattanooga, Tennessee, USA
                                          A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                                          DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                                          Do Not Chat For Help! NO_WAN_EGRESS(TM)

                                          1 Reply Last reply Reply Quote 0
                                          • F Offline
                                            firewalluser
                                            last edited by

                                            @Derelict:

                                            I didnt and I dont see any mention of deleting states in numerous online blogs detailing how to do XYZ, nor is it in the pfsense book and I dont see it mentioned often in the forums either. So whether "everyone" knows is a matter of opinion.

                                            https://doc.pfsense.org/index.php/Firewall_Rule_Troubleshooting#Dangling_States

                                            "Did you clear your states?" is asked like 5000 times a week here.

                                            That appears to be the only reference, besides do you know how many references there are to the phrase "Dangling State" in the forums?

                                            Answer is here. http://bfy.tw/6mC

                                            The quick answer is 0 (thats zero) reference to Dangling States in the forums and its certainly not mentioned in many many online how to's in websites & blogs. Thats alot of pfsense firewalls and others out there which can easily be compromised when combined with other methods to gain control of systems & networks.

                                            Its also interesting there is only one link to this page which is here, 
                                            https://doc.pfsense.org/index.php/Special:WhatLinksHere/Firewall_Rule_Troubleshooting

                                            Quite why you feel the need to exaggerate the fact its refered to 5000 times, I can only go and consult the handbook here: http://pastebin.com/irj4Fyd5

                                            It seems to me the significance of a Dangling State is not recognised or being played down.

                                            The first mention of it captured by the Wayback Machine was on Sun May 17 2009
                                            http://web.archive.org/web/20090501000000*/https://doc.pfsense.org/index.php/Firewall_Rule_Troubleshooting

                                            It seems this problem exists in all versions of pfsense going back to 1.x which explains alot regarding how many times I have been hacked since I started using pfsense 1.2

                                            @Harvy66:

                                            I think they already have a script for this and use it for scheduled rules. Maybe we just need a "kill all states" button under the edit window screen, allowing you to kill existing states for the current rule.

                                            Heres a test scenario you can do where the scheduled rules dont work which is probably best explained now as a "dangling state" as mentioned by Derelict, but is where the Inward bound wan states are not killed off.

                                            Create your normal rules, in my example I have a Pass everything out rule.
                                            FIrewall:Schedules webpage, Create a schedule that will take place in the future. For now I used 1st June (today), and set the time window for 15mins so if the time was 7am, the schedule would be 07:15 to 07:30.
                                            Firewall:Rules web page select the right interface if you have more than Wan & Lan, and just above your Pass everything out rule create a new rule which Blocks everything out, scroll to the bottom of the edit rule webpage & click the Schedule button and select your time schedule from the drop down.
                                            Save and apply changes.

                                            Now go watch a long free youtube video that will run for a few hours.
                                            By now it should be getting closer to 07:15 the time at which the Block Everything rule will kick in.

                                            Find out what the ip address is from the interface with the Pass Everything and find out what IP address the youtube stream is coming from, once you have that go to the Diagnostic:States window and look up the youtube IP address, you should see two entries for both directions and they should both say Established : Established, if you have the traffic graphs for the interfaces on your dashboard you should also see the youtube traffic coming In on the Wan and Out on the interface where the device playing the youtube video is playing.

                                            At 07:15am you will see in Firewall:Rules the Block Everything rule has become active as the icon in the Schedule column goes from a greyed out icon to a bold coloured icon indicating its gone from disabled to active. Likewise you can also visit the Firewall:Schedules webpage and see a clock icon next to the 07:15am to 07:30 time span. If you visit the Status: System Log: Firewall webpage, select Firewall tab and then Normal tab and filter on the interface by typing in Lan or whatever your interface is called before clicking the Filter button, any newly established traffic going out will be blocked by your now inforce Block Everything rule, whilst the already established youtube stream carries on unhindered.

                                            You can verify the youtube stream is still active by continuing to watch the film or visit the Diagnostics: States webpage and look up the IP address of the youtube server streaming the film to you that you previously found and see the two states are still present, they maybe in a different location in the list but as long as they both have Established : Established in the state column then the "Dangling State" is letting the traffic through as it will for any malware or virus that is currently in your system and has established a connection with the outside world.

                                            @Derelict:

                                            Exactly why states should not be automatically cleared.

                                            @Derelict:

                                            Submit a feature request.  It's not a bug.

                                            IMO  "Dangling States" are a bug as it makes it easy for bad actors & bad programs to get in and out of your system. Another way to look at this is, by asking this question, when is a firewall not a firewall? When it cant clear states down according the rules and/or by the schedules set up.

                                            The fact its mentioned in the docs does not legitimise the problem, it simply acknowledges the problem exists.

                                            The question is, can the dangling states be fixed?

                                            However considering this goes back to pfsense 1.x I can no longer consider pfsense a firewall due to this Dangling State bug, so how many users have been duped and forked out money for something that it isnt?

                                            Capitalism, currently The World's best Entertainment Control System and YOU cant buy it! But you can buy this, or some of this or some of these

                                            Asch Conformity, mainly the blind leading the blind.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.