Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State creation with reversed 5-tuple causes incorrect behavior with non-terminating rules #223

Open
ol-imorozko opened this issue Jul 5, 2024 · 0 comments

Comments

@ol-imorozko
Copy link
Collaborator

ol-imorozko commented Jul 5, 2024

Now the dynamic rules are created with a reversed 5-tuple, meaning the source and destination addresses and ports are swapped. This behavior deviates from the expected functionality as described in the ipfw specification.

According to the ipfw man page:

Dynamic rules are created when a packet matches a keep-state, record-state, limit or set-limit rule, causing the creation of a dynamic rule which will match all and only packets with a given protocol between a src-ip/src-port dst-ip/dst-port pair of addresses (src and dst are used here only to denote the initial match addresses, but they are completely equivalent afterwards). Rules created by keep-state option also have a :flowname taken from it. This name is used in matching together with addresses, ports and protocol. Dynamic rules will be checked at the first check-state, keep-state or limit occurrence, and the action performed upon a match will be the same as in the parent rule.

This can lead to incorrect behavior when dealing with non-terminating rules.

Example Configuration

:BEGIN
add skipto :IN ip from any to any in

:IN
add check-state
add dump ring1 ip from any to any
add allow udp from 10.0.0.0/24 to any 53 record-state
add deny ip from any to any

Expected Behavior

  • The first direct packet should match the dump rule and create a state.
  • The second packet should be matched on check-state and not trigger the dump rule again.

Current Behavior

  • The first direct packet matches the dump rule and creates a state with the reversed 5-tuple.
  • The second packet, expected to match the check-state, does not find the state due to the reversed 5-tuple and thus matches the dump rule again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant