Commit graph

177 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
d8b2f41e08 Apply default action if a rule is disabled. 2020-05-10 17:08:08 +02:00
Gustavo Iñiguez Goia
1d1d9f4456 Bump version to v1.0.0rc8 2020-04-29 22:02:30 +02:00
Gustavo Iñiguez Goia
83ffaaad44 decrease log level of denied connections
Denied connections were logged with Warning level.
However if you had a rule that denied a particular noisy connection, it
generated too much logs that didn't add value.

In the future it would be nice to log as warning, denied connections
that do not have a rule created by a user.

Discussion: https://github.com/gustavo-iniguez-goya/opensnitch/issues/10#issuecomment-615854975
2020-04-20 01:00:16 +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
09121ba74b Bump rpm package version to v1.0.0rc7 2020-04-13 01:16:01 +02:00
Gustavo Iñiguez Goia
32e527e503 Bump version to v1.0.0rc7 2020-04-13 00:23:38 +02:00
Gustavo Iñiguez Goia
d6af47813e netlink: exclude connections with invalid inode 2020-04-12 12:33:59 +02:00
Gustavo Iñiguez Goia
c51d9542ae audit: avoid to overwrite cmdline of new events
when an audit msg of type !SYSCALL is added, the cmdline field may be
empty, and thus cause to loose the original proc cmdline.
2020-04-12 12:31:59 +02:00
Gustavo Iñiguez Goia
99ad5e531f fixed getting process uid under certain situations 2020-04-12 01:38:39 +02:00
Gustavo Iñiguez Goia
b9af7c2837 fixed compiling for arm and i386 2020-04-11 00:23:27 +02:00
Gustavo Iñiguez Goia
24ede1c92b netlink: get active connections by source port + protocol
- Dump connections from kernel querying by source port + protocol.
- Prioritize responses which match the outgoing connection.
- If we don't get any response, apply the default action configured in
/etc/opensnitchd/default-config.json

--

A connection can be considered unique if:
protocol + source port + source ip + destination ip + destination port

We can be quite sure that only one process has created the connection.

However, many times, querying the kernel for the connection details by
all these parameters results in no response.

A regular query and normal response would be:
query: TCP:47344:192.168.1.106 -> 151.101.65.140:443
response: 47344:192.168.1.106 -> 151.101.65.140:443, inode: 1234567, ...

But in another cases, the details of the outgoing connection differs
from the kernel response, or it even doesn't exist.

However, if we query by protocol+source port, we can get more entries, and
somewhat guess what program opened the outgoing connection.

Some examples of querying by outgoing connection and response from
kernel:

query: 8612:192.168.1.5 -> 192.168.1.255:8612
response: 8612:192.168.1.105 -> 0.0.0.0:0

query: 123:192.168.1.5  -> 217.144.138.234:123
response: 123:0.0.0.0 -> 0.0.0.0:0

query: 45015:127.0.0.1 -> 239.255.255.250:1900
response: 45015:127.0.0.1 -> 0.0.0.0:0

query: 50416:fe80::9fc2:ddcf:df22:aa50 -> fe80::1:53
response: 50416:254.128.0.0 -> 254.128.0.0:53

query: 51413:192.168.1.106 -> 103.224.182.250:1337
response: 51413:0.0.0.0 -> 0.0.0.0:0
2020-04-05 19:14:51 +02:00
Gustavo Iñiguez Goia
315cf9e628 Merge branch 'main' of github.com:gustavo-iniguez-goya/opensnitch into main 2020-04-05 19:07:45 +02:00
Gustavo Iñiguez Goia
bf90229a1f procmon cache: removed redundant inodes cache deletion 2020-04-05 18:49:26 +02:00
deathtrip
b359bfd754
update upstream url 2020-04-05 11:35:30 +02:00
Gustavo Iñiguez Goia
528ce81c04 exclude localhost resolved dns from being cached
it led to resolve some domains to 127.0.0.1 and show the user a
dialog with that misleading domain.
2020-04-04 10:53:30 +02:00
Gustavo Iñiguez Goia
bfee1f014b Revert "search for the PID in the inodes cache before discard it"
This reverts commit 4466d1dfbc.

This change was not intended for this branch.
2020-04-03 11:56:45 +02:00
Gustavo Iñiguez Goia
4466d1dfbc search for the PID in the inodes cache before discard it
Even if we don't have the inode, the connection might be cached.
2020-04-03 00:43:49 +02:00
Gustavo Iñiguez Goia
f7114d95c4 delete inodes cache when a process exits 2020-04-03 00:42:46 +02:00
Gustavo Iñiguez Goia
4a7607a323 removed useless debug log 2020-04-01 01:51:53 +02:00
Gustavo Iñiguez Goia
e85a41ca0f allow to configure process monitor method in daemon config
Added ProcMonitorMethod, which can be "proc", "ftrace" or "audit".

Parameters passed by command line take prevalence over default
configuration.

breaking changes: config options changed from xx_yy to XxYy.

Config example:
{
    "DefaultAction": "allow",
    "DefaultDuration": "once",
    "InterceptUnknown": true,
    "ProcMonitorMethod": "audit"
}
2020-03-16 01:37:33 +01:00
Gustavo Iñiguez Goia
bc4c7387a9 Added .spec file for build rpm packages
Only for the daemon for now.
2020-03-15 01:57:44 +01:00
Gustavo Iñiguez Goia
dbb86d7df8 avoid to crash if opensnitchd is already running 2020-03-13 12:47:04 +01:00
Gustavo Iñiguez Goia
0c6836539e audit: code reformatted, ALL_CAPS to mixedCaps
Also do not filter sockets by code, nor by pid/ppid (for now at least).
2020-03-10 10:16:32 +01:00
Gustavo Iñiguez Goia
06d146b619 netstat/ sources commented and reformatted. 2020-03-09 20:08:14 +01:00
Gustavo Iñiguez Goia
eb52af72e5 audit: exclude events from our pid at rule level
Do not exclude them by code, just don't receive them.
2020-03-09 19:51:06 +01:00
Gustavo Iñiguez Goia
27778c1fd6 Bump version to v1.0.0rc6 2020-03-08 20:59:57 +01:00
Gustavo Iñiguez Goia
6ebd6cca99 added a default configuration file
Some people has asked where they can change the daemon configuration.

As we can't change it from the GUI yet, and we're providing deb
packages, we need to distribute a default config.

That way the users will see it and will be able to customize it.
2020-03-08 20:25:05 +01:00
Gustavo Iñiguez Goia
0fb23bb588 audit: avoid to alloc unused map, reformatted code 2020-03-08 01:09:47 +01:00
Gustavo Iñiguez Goia
99b024e0de dns sources formatted and documented 2020-03-07 10:23:53 +01:00
Gustavo Iñiguez Goia
a3422e493b audit: sort events after update the cache 2020-03-07 00:57:43 +01:00
Gustavo Iñiguez Goia
ba770fdf0d audit: insert new processes at the top of the list.
And avoid to sort the list of known processes every time we add a new
one.

Code formatted and documented.
2020-03-07 00:23:33 +01:00
Gustavo Iñiguez Goia
ef04667cdb cache of pids: insert new processes at the top of the list
code formatted and documented a little bit.
2020-03-06 23:23:16 +01:00
Gustavo Iñiguez Goia
1c04e95fdc audit: search for a process using the ppid
auditd events provides the parent pid of a process which has created
a connection. If we don't find the socket inode under the pid of the
process, use the ppid.

This is normally the case when systemd-* spawns a new process which
creates a new connection.
2020-03-06 23:21:24 +01:00
Gustavo Iñiguez Goia
9e6860fe63 formatted connman/ 2020-03-06 21:44:47 +01:00
Gustavo Iñiguez Goia
6e3336258c firewall/rules.go formatted and documented. 2020-03-06 21:28:22 +01:00
Gustavo Iñiguez Goia
7cbcc4d736 reformatted netlink/ sources, fixed typo 2020-03-06 21:02:34 +01:00
Gustavo Iñiguez Goia
63b6ba6f94 added description for netlink/GetSocketInfo 2020-03-06 20:32:19 +01:00
Gustavo Iñiguez Goia
2137a395d1 audit: Fixed 32bits socket monitoring. 2020-03-05 20:57:37 +01:00
Gustavo Iñiguez Goia
461118e321 replace ReplaceAll() by Replace() to compile with go <= 11 2020-03-05 19:39:35 +01:00
Gustavo Iñiguez Goia
010a657f64 audit: get rid of mozilla/libaudit-go
mozilla/libaudit-go does not support i386/arm/etc, and we were using it
only for parsing audit messages.

So do not use it and parse raw messages directly. WIP.
2020-03-05 01:54:27 +01:00
Gustavo Iñiguez Goia
db22e83de1 pids cache: delete from cache non existent PIDs 2020-03-04 01:56:48 +01:00
Gustavo Iñiguez Goia
7ef15faf62 cache of known pids: update lastSeen field when we have a match 2020-03-04 01:31:36 +01:00
Gustavo Iñiguez Goia
3d6beb5ec3 Added new processes monitor method: audit
Use auditd events to keep a list of PIDs which open sockets, reading
them from the audisp af_unix plugin.

- Install auditd and audisp-plugins
- Enable the af_unix plugin (/etc/audisp-plugin/af_unix, active = yes)
- Start opensnitch with -process-monitor-method audit.

If the choosen method is audit but it's not active or not installed,
it'll fallback to /proc anyway.

If it's properly configured, a debug trace will be written to the logs:
"PID found via audit events ..."
2020-03-03 23:51:25 +01:00
Gustavo Iñiguez Goia
6a82cdbac1 Allow to select which log level to use
Let the user choose which level log to use. For now it must be set
manually and when starting the daemon.
2020-02-28 10:24:08 +01:00
Gustavo Iñiguez Goia
c5a3fb5132 Allow to select what process search method to use
Until now OpenSnitch used ftrace(debugfs) to search for running
processes (PIDs) and obtain the process path.

On some systems, this filesystem is not mounted or available, so we have
to rely on /proc.

After several weeks of use, I think that it's faster and more accurate
the 2nd method, search pids/cmdlines in /proc. So we offer the user to
choose which one to use.
2020-02-26 19:13:42 +01:00
Gustavo Iñiguez Goia
fe8789526a Apply default action in case of communication failure with the server
If we can't communicate with the server (UI), apply the default
configured action. For example, if the UI is doing too much work and it
reaches the timeout, or if there's a programming error (python exception
for instance).
2020-02-26 09:53:48 +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
7cb0a25119 Bump version to v1.0.0rc5 2020-02-24 20:07:22 +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
8b579ece28 procmon: split cache functionality to a new file 2020-02-20 09:58:19 +01:00