|
| 1 | +IPS Concept |
| 2 | +=========== |
| 3 | + |
| 4 | +Intrusion Prevention System mode, or IPS mode, is the Suricata mode that makes it act as a |
| 5 | +traffic filter. |
| 6 | + |
| 7 | +By default it will allow all traffic, and will use ``drop`` or ``reject`` rules to block |
| 8 | +unwanted traffic. |
| 9 | + |
| 10 | +It is generally used ``inline``, where threat detection rules are used to drop known bad traffic. |
| 11 | + |
| 12 | +The ``inline`` operations are either on layer 2 (bridge, for example using AF_PACKET or DPDK) |
| 13 | +or on layer 3 (routing, for example in NFQueue or IPFW). |
| 14 | + |
| 15 | + |
| 16 | +Differences from the passive IDS mode |
| 17 | +------------------------------------- |
| 18 | + |
| 19 | +TCP stream engine |
| 20 | +^^^^^^^^^^^^^^^^^ |
| 21 | + |
| 22 | +Where in IDS mode TCP traffic is only inspected after the acknowledgement (ACK) for it has |
| 23 | +been received, in IPS mode the default behavior is different: new data is inspected |
| 24 | +immediately, together with previous data where possible. |
| 25 | +The inspection happens in a sliding window. This behavior is controlled by the |
| 26 | +``stream.inline`` setting. |
| 27 | + |
| 28 | +In case of overlapping data, the first data Suricata receives is accepted. Follow-up data |
| 29 | +that overlaps with this is then checked against the first data. If it is different, the |
| 30 | +traffic on the wire is rewritten to match the first data. |
| 31 | + |
| 32 | +The sliding window inspection can be visualized as such:: |
| 33 | + |
| 34 | + Packet 1: [hdr][segment data 1 ] |
| 35 | + Segments: [segment data 1 ] |
| 36 | + Window: [ inspection window ] |
| 37 | + |
| 38 | + Packet 2: [hdr][segment data 2] |
| 39 | + Segments: [segment data 1 ][segment data 2] |
| 40 | + Window: [ inspection window ] |
| 41 | + |
| 42 | + Packet 3: [hdr][segment data 3] |
| 43 | + Segments: [segment data 1 ][segment data 2][segment data 3] |
| 44 | + Window: [ inspection window ] |
| 45 | + |
| 46 | + Packet 4: [hdr][segment data 4] |
| 47 | + Segments: [segment data 2][segment data 3][segment data 4] |
| 48 | + Window: [ inspection window ] |
| 49 | + |
| 50 | +Each segment's data is inspected together with the other available data. One consequence |
| 51 | +of this is that there can be significant rescanning of data, which has a performance impact. |
| 52 | + |
| 53 | +http body inspection |
| 54 | +^^^^^^^^^^^^^^^^^^^^ |
| 55 | + |
| 56 | +Similar to the sliding window approach in the TCP stream engine, the HTTP body |
| 57 | +inspection will happen in a sliding manner by default. In IDS mode body data is |
| 58 | +buffered to the configured settings before inspection. |
| 59 | + |
| 60 | +:: |
| 61 | + |
| 62 | + app-layer: |
| 63 | + protocols: |
| 64 | + http: |
| 65 | + libhtp: |
| 66 | + default-config: |
| 67 | + # auto will use http-body-inline mode in IPS mode, yes or no set it statically |
| 68 | + http-body-inline: auto |
| 69 | + |
| 70 | + |
| 71 | +file.data |
| 72 | +^^^^^^^^^ |
| 73 | + |
| 74 | +For HTTP, the ``file.data`` logic is the same as the body inspection above. |
| 75 | + |
| 76 | +Exception Policies |
| 77 | +------------------ |
| 78 | + |
| 79 | +By default, when IPS mode is enabled, the exception policies are set to block (``drop``). |
| 80 | +This is to make sure rules cannot be bypassed due to Suricata reaching an error state in |
| 81 | +parsing, reaching internal resource limits and other exception conditions. |
| 82 | + |
| 83 | +See :ref:`Exception Policies documentation <exception policies>`. |
| 84 | + |
| 85 | +Differences from Firewall Mode |
| 86 | +------------------------------ |
| 87 | + |
| 88 | +The main difference is that unlike IPS mode, Firewall Mode has a default ``drop`` policy. |
| 89 | +This means that a ruleset must be created to allow traffic to be accepted, instead of |
| 90 | +accepting traffic by default and filtering out unwanted traffic. |
| 91 | + |
| 92 | +See :ref:`Firewall Mode Design <firewall mode design>`. |
0 commit comments