- New: if Server.Address is not set, stop the routine that attempts
to connect with the remote server.
- Spawn only one polling routine.
- When changing the configuration:
- if the new server.address changed and is not empty -> reconnect.
- if the new server.address changed and is empty -> disconnect.
- if previous server.address was empty and the new one is not -> connect.
- if the authentication settings changed -> reconnect.
If the server.address is not available, we'll try to connect
indefinitely.
- Fixed configuration loading, when the Process Monitor Method
selected failed to work (e.g.: when ebpf modules are missing,
auditd is not configured, etc).
In this scenario, on the first run, the daemon was not loading the
configuration from disk, and was instead using the default values, which
led to some glitches (unexpected reconnections to the GUI, checksums
option ignored, etc).
- added more tests.
Discard events from the queue if we can't send events to the channel.
It can happen if the case of a deadlock such as in ac3053af327e38acad4ff4024ed688ed68d6ae30
In this situation, reading from the ring buffer is blocked, which
eventually causes it to fill up.
When the ring buffer is full, bpf_ringbuf_output() fails with error -11.
Under very high load of kernel events, combined with a
non-zero value for the ebpf.QueueEventsSize config option,
the cache could end up blocking the events workers if the option to
compute process checksums was enabled.
When receiving the paths of a binary from kernel, the path can be a
symlink to the real binary on disk, and we were not obtaining the real
path to the binary.
Now we'll try to obtain it. If we fail, we'll use the path received from
the kernel. And if it's empty, we'll fallback to read it from proc.
Closes#1357
- Added MaxConnectAttempts configuration option:
If not specified, it defaults to 0, which means that we'll try to connect
indefinitely to the remote server.
- Improved connection retry behaviour:
We were not reconnecting to the server if we failed to connect on the
first attempt. Now we'll try to connect until MaxConnectAttempts, or
indefinitely if not specified (default value 0).
- If the logger is not connected to the remote server, don't send
messages to the queue.
Closes#1350.
netlink.AddrSubscribeWithOptions() was causing systemd-resolved not to
obtain DNS servers, and therefore the system was unable to resolve
domain names.
This ssue started happening on Fedora 42, with systemd-resolved 257 and
kernels 6.14.x.
Using netlink.AddrSubscribe() solves this issue for now.
Closes#1343
Changed Error to Warning log level when failing to load hooks.
Except for udp_tunnel6_xmit_skb, which depends on the module
ip6_udp_tunnel to be loaded, which by default is not the case.
In order not to flood the logs with this error, log level changed to
Debug.
In order to intercept UDP tunnels traffic, we use iptunnel_xmit for IPv4
connections. The equivalent of IPv6 would be ip6tunnel_xmit, but
unfortunately it's not public.
So instead of ip6tunnel_xmit, we'll use udp_tunnel6_xmit_skb.
This function receives two parameters besides the struct sock*, in6_addr
*saddr and in6_addr *daddr. If these addresses are not set, usually the
connection is a localhost connection.
On the other hand, this function is defined in the module
ip6_udp_tunnel. If this module is not loaded when the daemon starts,
we'll fail to intercept the connections.
Closes: #1250
- Changed the local host rule from using regexp to network operator
- Updated destination IP check from specific addresses to CIDR notation (127.0.0.0/8)
- Added new rule for IPv6 localhost connections (::1/128)
- Added nolog property to prevent logging of localhost traffic
- Preprend the chroot of a process to the path:
Even if a process is executed from a chroot (or a different mount
namespace), the kernel reports the path as it were from the host.
For chrooted processes, now we prepend the chroot to the path:
Instead of /usr/bin/curl -> /var/cache/pbuilder/usr/bin/curl
Note: if the process is emulated (with qemu for example), the
checksum will be of the emulator.
- For proceses launched from /proc, like /proc/self/exe or
/proc/<pid>/fd/<number>, we were replacing in the cmdline "/proc/*"
with the absolute path of the binary:
Path: /usr/bin/curl
Cmdline reported: /proc/<pid>/fd/<number> -L 1.1.1.1
Cmdline "fixed": /usr/bin/curl -L 1.1.1.1
Now we only do that for /proc/self/exe, and leave
/proc/<pid>/fd/<number> as is, since Path is already the absolute
path to the binary.
Path: /usr/bin/spotify
Cmdline reported: /proc/self/exe
Cmdline "fixed": /usr/bin/spotify
Path: /usr/bin/curl
Cmdline reported: /proc/<pid>/fd/<number> -L 1.1.1.1
Cmdline final: /proc/<pid>/fd/<number> -L 1.1.1.1
- better process interception on aarch64 and armhf.
- on armhf getting proc arguments is ignored due to an error, but we
were not marking the event as INCOMPLETE_ARGS, so we were not reading
the compete cmdline.
Up until now we've been using https://github.com/iovisor/gobpf/ for
intercepting events from the kernel, and it has worked very well.
Unfortunately it's deprecated since 2021 (iovisor/gobpf#304), which means
that some of the known issues and limitations won't be fixed.
After evaluating some options, I've migrated the code from gobpf to
github.com/cilium/ebpf.
More info: #1222, #1312
- Convert remote syslog to remote. There's no real difference between
both, and the code was the same.
Maybe we could limit the logging formats allowed.
- Remote logger: Added option to reopen the connection after n errors
trying to send messages.
tested on several distros with different kernels, as well as in a
private fork and this test doesn't fail.
So until we figure out why it's failing here, let's skip it for now.
- Fixed issue when configuring several loggers.
- Remote logger:
- open as many connections with the remote server as
specified in the Workers field.
- open and handle every connection in each own goroutine.
- get rid of the locks.
- Moved Info message to Trace.
- When applying a default action on a connection (because the daemon is
not connected to the GUI), log the connection details. It eases the
task of creating rules without a GUI.
- Minimize the risk of race conditions when we're prompting the user to
allow/deny a connection, while we're still reading proc's environ file.
(this was actually a leak).
- Preallocate the Env map with the expected environ vars.
Some use cases:
- Reject connections initiated by certain paths:
Deny all connections initiated by cron*:
/usr/sbin/cron
/usr/bin/curl
"action": "reject",
"operator: {
"type": "list",
"operand": "list",
"data": "",
"list": [
{
"type": "regexp",
"operand": "process.parent.path",
// /usr/bin/crond , /usr/bin/crontab, ...
"data": "^/usr/(s|)bin/cron"
}
]
}
- Reject or Allow connections of binaries launched by another app:
"action": "allow",
"operator": {
"type": "list",
"operand": "list",
"data": "",
"list": [
{
"type": "simple",
"operand": "process.parent.path",
"data": "/opt/spotify/bin/spotify"
},
{
"type": "simple",
"operand": "process.path",
"data": "/usr/bin/wget"
}
]
}
You can also combine multiple parent paths, to allow a command launched
from a specific chain of processes:
/usr/lib/systemd/systemd
/usr/sbin/cron
/bin/sh
/usr/bin/curl
The order is checked from the newest process to the oldest (curl -> sh
-> cron -> systemd)
The operand can be used with any of the existing types (simple, regexp,
etc).
Related: #406
Disabled rules were part of the active rules. The fields were not
evaluated, but we still went through the entire list.
Not adding them to the list of active rules improves matching time,
especially when there're a lot of disabled rules.
It mainly affected when matching rules that were non-priority or
ordered alphabetically, with action Allow.
- daemon: Allow to dump XDP sockets from kernel.
- ui: Added options to filter by RAW protocol and AF_XDP family.
- Bumped vishvananda/netlink version to v1.3.0.
- Updated go.mod and go.sum
Sometimes we may receive a connection event after the exit of a
process:
[exec] /bin/xxx, pid 1234
[exit] /bin/xxx, pid 1234
[new conn] pid 1234 -> process unknown (on exec event and no /proc entry)
In these scenarios, we delay the deletion from cache a little
bit, to keep the PID available for a longer time.