Skip to content

Suricata rules not working as anticipated

0

Hi, In order to satisfy our internal requirements we need to provide firewall whitelisting of the specific web sites. Stateful domain lists are not sufficient for this purpose so we decided to use suricata rules. The current rule set looks like this:

Allow connection establishment

pass tcp $HOME_NET any -> any [80,443] (msg:"Allow TCP SYN to web ports"; flow:to_server,not_established; flags:S,12; sid:1; rev:1;) pass tcp $HOME_NET any -> any 80 (msg:"Allow HTTP to www.stuff.co.nz"; flow:established,to_server; http.host; content:"www.stuff.co.nz"; sid:1000001; rev:1;) pass tcp $HOME_NET any -> any 443 (msg:"Allow HTTPS to www.stuff.co.nz"; flow:established,to_server; tls.sni; content:"www.stuff.co.nz"; sid:1000002; rev:1;) pass http any 80 -> $HOME_NET any (msg:"Allow HTTP responses from www.stuff.co.nz"; flow:established,to_client; sid:1000003; rev:1;) pass tls any 443 -> $HOME_NET any (msg:"Allow HTTPS responses from www.stuff.co.nz"; flow:established,to_client; sid:1000004; rev:1;) #Drop anything else drop tcp any any -> any any (msg:"Drop all other TCP"; sid:2000001; rev:1;)

The first problem I discovered, which makes AWS different from Suricata is the necessity to specify connection establishment pass (SYN packets) - without it none of the established-based rules work. The next problem is even stranger - once a rule triggers (for example, rule 3), none of other rules are matched anymore - that is, I can observe a request being sent from the client to the server and then the entire traffic is simply sent to the default Stateful action - if it is Drop, then the rest of the connection is simply blocked.

Is there anything i can do to make it work?

Regards, Gene

asked a year ago600 views

1 Answer
0

The issue you are facing is due to the misconfiguration in the suricata rule(Sid:1), you have configured it to only allow TCP SYN packet from client to server. However, there is no rule to allow the SYN-ACK from the server causing the traffic to drop immediately after the SYN packet by the drop rule with sid 2000001. Therefore, you will have to allow the complete TCP handshake by adding a SYN-ACK rule or else you can create a single bidirectional rule to allow the complete TCP handshake needed to establish the connection.

Additionally, you have configured rule to allow response traffic. Suricata rules in AWS Network firewall are stateful in nature. Therefore, there is no need to explicitly create separate rules to allow the response traffic.

To resolve this connection issue, you can follow either of the following options.

  1. Keep the default action as drop established, Drop established action drops only the packets that are in established connections from client to server. This allows the layer 3 and 4 connection establishment packets that are needed for the upper-layer connections to be established, while dropping the packets for connections that are already established. This allows application-layer pass rules to be written in a default-deny setup without the need to write additional rules to allow the lower-layer handshaking parts of the underlying protocols. Packets from established connections from the server to the client are passed to allow return traffic from established connections back to the client.
  2. If you want to keep the default action as drop all then you can create a rule in the suricata rule group to allow bidirectional traffic of TCP handshake. You can follow the sample rules which I have shared below.
# Allow complete TCP handshake for web ports (bidirectional)
pass tcp $HOME_NET any <> any [80,443] (flow:not_established; msg:"Allow TCP handshake to web ports"; sid:1; rev:1;)

# Allow HTTP traffic to specific domain (stateful - return traffic automatic)
pass http $HOME_NET any -> $EXTERNAL_NET 80 (http.host; dotprefix; content:"www.stuff.co.nz"; endswith; msg:"Allow HTTP to www.stuff.co.nz"; sid:2; rev:1;)

# Allow HTTPS traffic to specific domain (stateful - return traffic automatic)
pass tls $HOME_NET any -> $EXTERNAL_NET 443 (tls.sni; dotprefix; content:"www.stuff.co.nz"; nocase; endswith; msg:"Allow HTTPS to www.stuff.co.nz"; flow:to_server,established; sid:3; rev:1;)

# Drop all other TCP traffic
drop tcp any any -> any any (msg:"Drop all other TCP"; sid:4; rev:1;)

Note : As per the AWS best practices, it is recommended to keep the default action as drop established instead of adding an additional bidirectional rule to the rule group.

References :

answered a year ago

AWS
SUPPORT ENGINEER

revised a year ago

AWS
SUPPORT ENGINEER

revised a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.