Skip to content

Commit d9faaa7

Browse files
Update Rules.md
1 parent 2b4be09 commit d9faaa7

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

wiki/Rules.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ Rules are stored as JSON files inside the `-rule-path` directory (by default `/e
3434
| update | UTC date and time of the last update. |
3535
| name | The name of the rule. |
3636
| 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. |
3939
| 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. |
4040
| operator.type | `simple`, `regexp`, `network`, `lists`, `list`, `range`.|
4141
|| `simple` is a simple `==` comparison.|
4242
|| `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) |
4444
|| `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)|
4545
|| `range` (v1.9.0) will check if an Operand (`dest.port` or `source.port`) is within the given range.|
4646
|| `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
5050
| | `process.path` - the absolute path of the executable |
5151
| | `process.id` PID of the process|
5252
| | `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. |
5454
| | `provess.env.ENV_VAR_NAME` (use the value of an environment variable of the process given its name). |
5555
| | `process.hash.md5` (v1.7.0) - verify the checksum of an executable |
5656
| | `user.id` - UID |
5757
| | `user.name` user name (v1.7.0). Check against a regular system username (no namespaces, containers or virtual user names).|
58-
| | `protocol` - TCP, UDP, UDPLITE, ...|
58+
| | `protocol` - TCP, UDP, UDPLITE, SCTP, DCCP, ICMP (append "6" for IPv6 protocols: TCP6)|
5959
| | `source.port` |
6060
| | `source.ip` |
6161
| | `source.network` |
6262
| | `dest.ip` |
6363
| | `dest.host` |
6464
| | `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 |
6565
| | `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|
6868
| | `lists.domains` (v1.4.0) lists of domains in hosts format [read more](https://github.com/evilsocket/opensnitch/wiki/block-lists)|
6969
| | `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. |
7070
| | `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:
127127
"type": "regexp",
128128
"sensitive": false,
129129
"operand": "dest.host",
130-
"data": "(?i)
130+
"data": "(?i)"
131131
}
132132
}
133133
```
@@ -247,6 +247,8 @@ If you want to restrict it further, under the `Addresses` tab you can review wha
247247

248248
You can narrow it further, by allowing `from this command line` + `from this User ID` + `to this IP` + `to this port`
249249

250+
Or just let it prompt you to allow/deny it if you don't these commands usually, and allow it for `30s`.
251+
250252
- Don't allow `python3`, `perl` or `ruby` binaries system-wide:
251253
* As explained above, filter by executable + command line + (... more parameters ...)
252254
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
255257

256258
- Disable unprivileged namespaces to prevent rules bypass
257259

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+
259264

260265
### For servers
261266

@@ -338,7 +343,7 @@ There're two approaches to secure a server with OpenSnitch:
338343

339344
- When the `DefaultAction` is `allow`, don't allow connections opened by binaries located under certain directories: `/dev/shm`, `/tmp`, `/var/tmp` or `/memfd`:
340345

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):
342347

343348
[Collection of Linux malware payloads](https://github.com/evilsocket/opensnitch/discussions/1119)
344349

@@ -373,5 +378,9 @@ There're two approaches to secure a server with OpenSnitch:
373378

374379
One of the common reason to compromise servers is to mine cryptos. Denying connections to the mining pools, disrupts the operation.
375380

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+
376385
**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.
377386

0 commit comments

Comments
 (0)