You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: wiki/Rules.md
+19-10Lines changed: 19 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,13 +34,13 @@ Rules are stored as JSON files inside the `-rule-path` directory (by default `/e
34
34
| update | UTC date and time of the last update. |
35
35
| name | The name of the rule. |
36
36
| enabled | Enable or disable the rule. |
37
-
| precedence | true or false. Sets if a rule take precedence over the rest (>= v1.2.0)|
38
-
| action | Can be `deny`, `reject` or `allow`. `reject` kills the socket. |
37
+
| precedence | true or false. Sets if a rule take precedence over the rest (>= v1.2.0). If a connection matches this rule, no other rules will be evaluated.|
38
+
| action | Can be `deny`, `reject` or `allow`. `reject` kills the socket, terminating the connection immediately. `deny` drops/ignores the packet. |
39
39
| duration | The duration of the rule in [Duration format](https://pkg.go.dev/time#ParseDuration). `always` is always used when the rule is written to disk. The rest of the options are temporary, until they reach the deadline: `12h`, `5h`, `1h`, `30s`, or `once` to only run the rule one time. |
||`regexp` matches the regexp from the `data` field against the connection |
43
-
||`network` checks if the IP of a connection is contained within the specified network range (127.0.0.1/8) |
43
+
||`network` checks if the IP of a connection is contained within the specified network range (127.0.0.1/8, 192.168.1.0/24, etc) |
44
44
||`lists` will look for matches on lists of something (domains, IPs, etc). Typically used to create [blocklists](https://github.com/evilsocket/opensnitch/wiki/block-lists)|
45
45
||`range` (v1.9.0) will check if an Operand (`dest.port` or `source.port`) is within the given range.|
46
46
||`list`, a combination of all of the previous types.|
@@ -50,21 +50,21 @@ Rules are stored as JSON files inside the `-rule-path` directory (by default `/e
50
50
||`process.path` - the absolute path of the executable |
51
51
||`process.id` PID of the process|
52
52
||`process.command` (full command line, including path and arguments). Note that cmdlines can contain or not the process name, and the path can be absolute or relative (`./cmd -x a`).|
53
-
||`process.parent.path` (v1.7.0) check against ONE of the parent path. Include more parent paths to match the tree of a process. |
53
+
||`process.parent.path` (v1.7.0) check against ONE of the parent path. You can add multiple parent paths with the `list` type, to match the tree of a process. |
54
54
||`provess.env.ENV_VAR_NAME` (use the value of an environment variable of the process given its name). |
55
55
||`process.hash.md5` (v1.7.0) - verify the checksum of an executable |
56
56
||`user.id` - UID |
57
57
||`user.name` user name (v1.7.0). Check against a regular system username (no namespaces, containers or virtual user names).|
||`dest.network` (v1.3.0) - you can use a network range, or the constants predefined in the file https://github.com/evilsocket/opensnitch/blob/master/daemon/data/network_aliases.json|
65
65
||`dest.port`|
66
-
||`iface.in` (v1.6.0) |
67
-
||`iface.out` (v1.6.0) |
66
+
||`iface.in` (v1.6.0) - name of a network interface|
67
+
||`iface.out` (v1.6.0) - name of a network interface|
68
68
||`lists.domains` (v1.4.0) lists of domains in hosts format [read more](https://github.com/evilsocket/opensnitch/wiki/block-lists)|
69
69
||`lists.domains_regexp` (v1.5.0) list of domains with regular expressions (`.*\.example\.com`) [read more](https://github.com/evilsocket/opensnitch/wiki/block-lists) ⚠️! Don't use more than 300 regexps, it'll eat all the memory. |
70
70
||`lists.ips` (v1.5.0) list of IPs [read more](https://github.com/evilsocket/opensnitch/wiki/block-lists)|
@@ -127,7 +127,7 @@ An example with a regular expression:
127
127
"type": "regexp",
128
128
"sensitive": false,
129
129
"operand": "dest.host",
130
-
"data": "(?i)
130
+
"data": "(?i)"
131
131
}
132
132
}
133
133
```
@@ -247,6 +247,8 @@ If you want to restrict it further, under the `Addresses` tab you can review wha
247
247
248
248
You can narrow it further, by allowing `from this command line` + `from this User ID` + `to this IP` + `to this port`
249
249
250
+
Or just let it prompt you to allow/deny it if you don't these commands usually, and allow it for `30s`.
251
+
250
252
- Don't allow `python3`, `perl` or `ruby` binaries system-wide:
251
253
* As explained above, filter by executable + command line + (... more parameters ...)
252
254
If you allow `python3`for example, you'll allow ANY `python3` script, so be careful.
@@ -255,7 +257,10 @@ If you want to restrict it further, under the `Addresses` tab you can review wha
255
257
256
258
- Disable unprivileged namespaces to prevent rules bypass
257
259
258
-
If `/proc/sys/kernel/unprivileged_userns_clone` is set to 1, change it to 0. Until we obtain the checksum of a binary, it's better to set it to 0.
260
+
If `/proc/sys/kernel/unprivileged_userns_clone` is set to 1, change it to 0.
261
+
262
+
Or enable checksums verifying from the Preferences -> Nodes -> Rules.
263
+
259
264
260
265
### For servers
261
266
@@ -338,7 +343,7 @@ There're two approaches to secure a server with OpenSnitch:
338
343
339
344
- When the `DefaultAction` is `allow`, don't allow connections opened by binaries located under certain directories: `/dev/shm`, `/tmp`, `/var/tmp` or `/memfd`:
340
345
341
-
There're ton of examples (more common on servers than on the desktop):
346
+
There're ton of malware examples that drop malicious files to temporary directories (more common on servers than on the desktop):
342
347
343
348
[Collection of Linux malware payloads](https://github.com/evilsocket/opensnitch/discussions/1119)
344
349
@@ -373,5 +378,9 @@ There're two approaches to secure a server with OpenSnitch:
373
378
374
379
One of the common reason to compromise servers is to mine cryptos. Denying connections to the mining pools, disrupts the operation.
375
380
381
+
- Think also if your web server, database server, etc, needs to establish connections to remote IPs.
382
+
383
+
In some cases, the download of malicious files is executed from common applications: [pg_mem campaign](https://www.aquasec.com/blog/pg_mem-a-malware-hidden-in-the-postgres-processes/)
384
+
376
385
**Note** that the default policy should be deny everything unless explicitely allowed. But by creating a rule to deny specifically these directories, you can have a place where to monitor these executions.
0 commit comments