Commit graph

23 commits

Author SHA1 Message Date
themighty1
41172b65e5 minor fixes to prevent go vet from complaining 2021-02-13 19:18:38 +03:00
Gustavo Iñiguez Goia
f2c4b37d6e deleted output rule to drop marked packets
We had an OUTPUT rule to drop marked packets. Packets are marked with a
mark when a user defined rule denies a connection.

The thing is that we only intercept NEW connections, and when we deny a
connnection using NF_DROP, the packets doesn't flow to the next iptables
rule or chain. So it'd be rare to see a packet on the OUTPUT chain marked
with the DropMark.

Besides, nfq_set_verdict2() doesn't seem to place the mark on the
packets (libnetfilter-queue 1.0.5).

This OUTPUT rule had 0 hits on different systems and users.
2021-01-10 23:20:50 +01:00
Gustavo Iñiguez Goia
1384db6a1b fw: clean system rules before insert new ones
If the daemon exits unexpectedly, fw rules are not deleted.
So on every start/reload, clean any possible rule before adding new
ones.
2020-12-22 22:06:37 +01:00
Gustavo Iñiguez Goia
db31e5b71a fw: fixed 100% CPU spike, fixed cleaning rules
- Fixed 100% CPU spike when pausing interception from the GUI
gustavo-iniguez-goya/opensnitch/issues/104
- Fixed monitoring fw rules after re-enabling interception.
- Fixed cleaning up interception and system rules.
2020-12-12 18:16:59 +01:00
Gustavo Iñiguez Goia
e13015ce67 updated import paths 2020-12-09 18:18:42 +01:00
Gustavo Iñiguez Goia
df952d974e fixed errors when IPv6 is not enabled in the system
If IPv6 was not enabled we failed to add IPv6 rules.

closes #96
2020-11-26 16:25:48 +01:00
Gustavo Iñiguez Goia
a3a7becbc8 fixed exception if system-fw.json doesn't exist
closes #88
2020-11-15 00:53:13 +01:00
Gustavo Iñiguez Goia
831ab347e3 Merge branch 'priority-rules' into main
Added option to let the users define iptables rules.

The system rules are added in the file /etc/opensnitchd/system-fw.json
with this format:
```
{
    "SystemRules": [
        {
            "Rule": {
                "Description": "Allow pptp VPN",
                "Table": "mangle",
                "Chain": "OUTPUT",
                "Parameters": "-p gre",
                "Target": "ACCEPT",
                "TargetParameters": ""
            }
        }
    ]
}
```
On the mangle table, OUTPUT chain, these rules are added before
the NFQUEUE interception rule, so any rule you add there bypasses the
interception. Useful to allow traffic you don't want to intercept.

This feature solves in some way the issue some users have connecting to
VPNs when the Default Action configured in the daemon is Deny.

For example:
- OpenVPN when keepalive is configured and ICMP is used.
- PPTP because the GRE routing protocol is blocked.
- probably others like IPSEC.

(regarding WireGuard, as far as I can tell it works just fine, see #61).

closes #47
2020-11-13 00:14:39 +01:00
Gustavo Iñiguez Goia
df9e781051 Do not panic if we can't insert fw rules
Some systems has the IPV6 protocol disabled, so we failed starting up
with the error "Address family not supported by protocol" (#52).

Now we don't exist even if we can't insert the needed rules, we'll just
log the error.
2020-07-30 01:10:53 +02:00
Gustavo Iñiguez Goia
08245a075e intercept RELATED packets
We must intercept RELATED packets, not only for intercept protocols like
ftp-data, but also to handle connection errors (ICMP errors), like the
ones originated when dis/connecting from a wifi network.
2020-07-25 21:48:16 +02:00
Gustavo Iñiguez Goia
214e1b3c49 added priority rules to bypass/extend interception
In some scenarios (#47) may be useful to have a set of rules handled from
OpenSnitch, although you can accomplish it with other software (ufw,...).

This rules will sit just above default intercetion, so if you want to
allow or deny something, just place it here.

These priority rules are defined in /etc/opensnitchd/fw.json, with the
following format (example):

{
    "PriorityRules": {
        "out": {
            "allow": [
            ],
            "deny": [
                "-m conntrack --ctstate INVALID",
                "-p tcp ! --syn -m conntrack --ctstate NEW"
            ]
        }
    }
}

The structure must exist even if you haven't defined any rule, for
example:
{
    "PriorityRules": {
        "out": {
            "allow": [
            ],
            "deny": [
            ]
        }
    }
}
2020-07-25 21:23:53 +02:00
Gustavo Iñiguez Goia
034a95918e removed useless firewall log 2020-06-12 01:21:36 +02:00
Gustavo Iñiguez Goia
6ee80b1640 Allow to change settings from the UI
(1/2)
We start receiving notifications from the UI, which allow us to change
configurations and perform actions on the daemon.

The concept of Node has also been introduced, which identifies every
daemon (client) connected to the UI (server).

These options has been added:
- Enable/Disable firewall interception (for all nodes)
- Change daemons (clients) configuration. globally or per node.
- Change prompt dialog options.

We have fixed some bugs along the way:
- Close audit client connection gracefully.
- Exclude our own connections from being intercepted.
- Better handling of client connection status with the UI.

We probably has also introduced some other bugs (not listed here).
2020-04-19 20:13:31 +02:00
Gustavo Iñiguez Goia
6e3336258c firewall/rules.go formatted and documented. 2020-03-06 21:28:22 +01:00
Gustavo Iñiguez Goia
de956b1bf4 Fixed DNS responses firewall rule not deleted on exit
Sometimes the INPUT rule for to queue DNS responses was not deleted.
The code has also been reorganized.

And a minor tweak to make an if{} more idiomatic.
2020-02-25 01:30:24 +01:00
Gustavo Iñiguez Goia
2c7472f06d firewall: check rules every 5s
Every 5s check if our rules are loaded, and if they aren't, add them
again.
2020-02-22 00:27:35 +01:00
Gustavo Iñiguez Goia
a7e9b5072f project import paths changed 2019-10-20 21:51:35 +02:00
Northern-Lights
ba00f91bde
Fix QueueDNSResponses to include ip6tables 2019-01-26 20:56:12 -08:00
Armen Boursalian
cc3786b919 Fix ignored err check in RunRule 2018-12-30 19:07:05 -08:00
Jerzy Kozera
22c4aca5d0 IPv6 support 2018-11-21 22:57:43 +01:00
Armen Boursalian
bb2ca3887c Put DNS rule higher up in chain 2018-08-23 22:44:48 -07:00
evilsocket
01e5134139
misc: small fix or general refactoring i did not bother commenting 2018-04-10 13:11:39 +02:00
evilsocket
534ec8cd73
misc: small fix or general refactoring i did not bother commenting 2018-04-02 05:25:32 +02:00