Commit graph

502 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
3853d412b4 audit: better rules deletion
if the daemon does not exit cleanly, the rules were not cleaned
correctly.
2020-07-03 08:28:33 +02:00
Gustavo Iñiguez Goia
714aa311a0 Bump version to v1.0.0rc11 2020-06-24 00:41:36 +02:00
Gustavo Iñiguez Goia
2522b8ef02 fixed CWD parsing when using audit proc monitor method 2020-06-22 14:26:07 +02:00
Gustavo Iñiguez Goia
6d24c5464c fixed race conditions when manipulating rules 2020-06-20 18:58:59 +02:00
Gustavo Iñiguez Goia
fc2212f073 return better errors if a regexp rule fails to compile
If a regexp rule fails to compile, return the reason instead of a
generic error. It'll help to debug problems.
2020-06-19 18:02:09 +02:00
Gustavo Iñiguez Goia
cfc32cbd1c fixed race condition when deleting a rule 2020-06-14 20:30:19 +02:00
Gustavo Iñiguez Goia
b03bbf0506 fixed race conditions setting log level and monitor methods 2020-06-14 20:14:24 +02:00
Gustavo Iñiguez Goia
edfbfbdcb4 Bump version to 1.0.0rc10 2020-06-14 12:34:20 +02:00
Gustavo Iñiguez Goia
506b9b6d87 fixed daemon running with old libnetfilter_queue libs
In old libnetfilter_queue libs, we can't know the UID of the packet
because the function nfq_get_uid is not present.

We check it dynamically on run time, but we were doing it wrong, so the
daemon didn't run with old libs.

Thaks to Pain-Patate for reporting it in #18.
2020-06-14 12:01:34 +02:00
Gustavo Iñiguez Goia
034a95918e removed useless firewall log 2020-06-12 01:21:36 +02:00
Gustavo Iñiguez Goia
a1bba4da3f send on new connection CWD and envrionment vars of the process
CWD allow us to know from where was a process executed.
The environment variables allows to know more about a process execution.
2020-06-04 01:14:25 +02:00
Gustavo Iñiguez Goia
78c0da83c0 increase default timeout to ask for a rule
Explained here: https://github.com/gustavo-iniguez-goya/opensnitch/issues/28#issuecomment-637484501
2020-06-04 00:38:11 +02:00
Gustavo Iñiguez Goia
36a11b4102 don't configure log level if the item does not exist in the config
Reported here:
https://github.com/gustavo-iniguez-goya/opensnitch/issues/31#issuecomment-633759613

The LogLevel conf item should always exist, but just in case.
2020-06-01 01:54:08 +02:00
Gustavo Iñiguez Goia
6c9d9b28f6 added default log level to default conf 2020-05-30 23:03:59 +02:00
Gustavo Iñiguez Goia
558e511718 delete rules by its name without deserializing 2020-05-30 01:44:22 +02:00
Gustavo Iñiguez Goia
6bbf3b33be misc: sources formatting 2020-05-30 01:36:43 +02:00
Gustavo Iñiguez Goia
cb4b62f36a Improved process path parsing (with spaces)
Processes paths with spaces were not handled correctly.
If the /proc/<pid>/exe link contained the word "(deleted)",
we deleted that part from the process path. But the way we
did it caused to not handle paths with spaces correctly.

Should fix #24
2020-05-23 12:16:35 +02:00
Gustavo Iñiguez Goia
1331bcb91f Reload config after changing it from the UI.
closes #20
2020-05-18 01:07:09 +02:00
Gustavo Iñiguez Goia
c36b09db55 Bump version to v1.0.0rc9 2020-05-17 19:55:07 +02:00
Gustavo Iñiguez Goia
061d7a2ecd ignore malformed rules
Don't exist if a rule is malformed.

Reported by @jonau01 here #17
2020-05-11 10:39:56 +02:00
Gustavo Iñiguez Goia
ca1cbe3084 added functions to retrieve system information 2020-05-10 17:52:08 +02:00
Gustavo Iñiguez Goia
85699622f6 Added logic to handle changes/notifications from the GUI.
- Allow to perform the following actions from the GUI:
  * Load/unload firewall (i.e.: interception)
  * Change daemon default configuration.
  * Enable/disable rules.
  * Delete rules.
  * Change/Add rules.
  * Change log level.
2020-05-10 17:44:56 +02:00
Gustavo Iñiguez Goia
c44fdf4342 added delete, getall, replace to the rules loader 2020-05-10 17:33:39 +02:00
Gustavo Iñiguez Goia
a39a2000fd return error if the daemon configuration can not be saved 2020-05-10 17:20:27 +02:00
Gustavo Iñiguez Goia
43898bc4c9 Allow to configure if a rule is enabled or not. 2020-05-10 17:17:05 +02:00
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