Commit Graph

37 Commits

Author SHA1 Message Date
Joris Vink 860e21aa50 linux: add faccessat2 to default seccomp rules. 2024-04-29 09:46:44 +02:00
Joris Vink 4e38d8a323 Allow clock_gettime64() if defined. 2023-03-01 17:11:27 +01:00
Joris Vink 369fc4fa01 Add newfstatat in common Kore seccomp whitelist. 2022-11-02 22:13:10 +01:00
Joris Vink 169a4e7c5d wrap 2 more syscalls in ifdefs. 2022-02-17 14:46:33 +01:00
Joris Vink 833ca646e7 i forgot, it's 2022. 2022-01-31 22:02:06 +01:00
Joris Vink f39919e98c Add readlinkat to seccomp whitelist. 2021-05-10 23:05:58 +02:00
Joris Vink cef5ac4003 bump copyright year. 2021-01-11 23:46:08 +01:00
Frederic Cambus af99a4d9e2 Conditionally allow syscalls required to run on arm.
Those syscalls do not exist on other Kore supported platforms, so we
must check that they exist before allowing them.
2020-09-17 17:41:03 +02:00
Frederic Cambus 28ea1b3c7e Add missing tests for SYS_mmap, fixes the build on arm. 2020-09-17 17:41:00 +02:00
Frederic Cambus 7290944bf3 Add support for logging seccomp violations on arm.
On ARM EABI, the syscall number can be read from register r7.
2020-09-16 23:07:45 +02:00
Frederic Cambus 60bc618c3f Allow the clock_nanosleep syscall, it is required for kore_accesslog().
glibc 2.31 calls clock_nanosleep in its nanosleep function.
2020-09-14 19:15:25 +02:00
Joris Vink b84c88a0e6 remove the yet wording. 2020-09-03 19:08:08 +02:00
Joris Vink 58247eec4a I don't support x86 on Linux, remove it.
Pointed out by entitled end user.
2020-09-03 19:05:43 +02:00
Joris Vink 6ba56bb8f6 adjust copyright years 2020-02-10 15:35:41 +01:00
Joris Vink 9d0aef0079 bump copyright 2020-02-10 14:47:33 +01:00
Joris Vink 7c78526e82 pull in ptrace.h 2019-11-13 15:56:36 +01:00
Joris Vink c78535aa5d Add acmev2 (RFC8555) support to Kore.
A new acme process is created that communicates with the acme servers.

This process does not hold any of your private keys (no account keys,
no domain keys etc).

Whenever the acme process requires a signed payload it will ask the keymgr
process to do the signing with the relevant keys.

This process is also sandboxed with pledge+unveil on OpenBSD and seccomp
syscall filtering on Linux.

The implementation only supports the tls-alpn-01 challenge. This means that
you do not need to open additional ports on your machine.

http-01 and dns-01 are currently not supported (no wildcard support).

A new configuration option "acme_provider" is available and can be set
to the acme server its directory. By default this will point to the
live letsencrypt environment:
    https://acme-v02.api.letsencrypt.org/directory

The acme process can be controlled via the following config options:
  - acme_root (where the acme process will chroot/chdir into).
  - acme_runas (the user the acme process will run as).

  If none are set, the values from 'root' and 'runas' are taken.

If you want to turn on acme for domains you do it as follows:

domain kore.io {
	acme yes
}

You do not need to specify certkey/certfile anymore, if they are present
still
they will be overwritten by the acme system.

The keymgr will store all certificates and keys under its root
(keymgr_root), the account key is stored as "/account-key.pem" and all
obtained certificates go under "certificates/<domain>/fullchain.pem" while
keys go under "certificates/<domain>/key.pem".

Kore will automatically renew certificates if they will expire in 7 days
or less.
2019-11-06 19:43:48 +01:00
Joris Vink b226b6ca89 Allow seccomp to work on arm64 and i386. 2019-11-05 13:12:43 +01:00
Joris Vink 8311c036d9 Add seccomp_tracing configuration option for linux.
If set to "yes" then Kore will trace its child processes and properly
notify you of seccomp violations while still allowing the syscalls.

This can be very useful when running Kore on new platforms that have
not been properly tested with seccomp, allowing me to adjust the default
policies as we move further.
2019-10-31 12:52:10 +01:00
Joris Vink f637d617aa Allow SECCOMP_KILL_POLICY to be overwritten at build. 2019-10-23 15:01:31 +02:00
Joris Vink 0eb11794f5 Do not add keymgr its msg fd if not started.
Reshuffles the keymgr_active flag to keymgr.c and let it be figured out
from inside kore_server_start() instead of the worker init code.
2019-10-07 10:31:35 +02:00
Joris Vink 11cc5d304f let kore_python_seccomp_hook() take the hook name 2019-10-04 11:28:14 +02:00
Joris Vink 8bbdaedf94 Allow configuring seccomp on Linux via the python api.
A new hook in the koreapp class is called right before seccomp
is enabled. This hook receives a Kore seccomp object which has
the following methods:

	seccomp.allow("syscall")
	seccomp.allow_arg("syscall", arg, value)
	seccomp.allow_flag("syscall", arg, flag)
	seccomp.allow_mask("syscall", arg, mask)

	seccomp.deny("syscall")
	seccomp.deny_arg("syscall", arg, value, errno=EACCES)
	seccomp.deny_flag("syscall", arg, flag, errno=EACCES)
	seccomp.deny_mask("syscall", arg, mask, errno=EACCES)

This allows you to finetune the seccomp filters for your application
from inside your koreapp.
2019-10-04 10:59:48 +02:00
Frederic Cambus 85981e22cc Allow the nanosleep syscall, it is used in kore_accesslog(). 2019-10-03 15:53:36 +02:00
Joris Vink 7350131232 Allow listening of tls/notls ports at the same time.
Before kore needed to be built with NOTLS=1 to be able to do non TLS
connections. This has been like this for years.

It is time to allow non TLS listeners without having to rebuild Kore.

This commit changes your configuration format and will break existing
applications their config.

Configurations now get listener {} contexts:

listen default {
	bind 127.0.0.1 8888
}

The above will create a listener on 127.0.0.1, port 8888 that will serve
TLS (still the default).

If you want to turn off TLS on that listener, specify "tls no" in that
context.

Domains now need to be attached to a listener:

Eg:
	domain * {
		attach	default
	}

For the Python API this kills kore.bind(), and kore.bind_unix(). They are
replaced with:

	kore.listen("name", ip=None, port=None, path=None, tls=True).
2019-09-27 12:27:04 +02:00
Joris Vink b7163f35ce allow readlink syscall 2019-09-26 16:29:45 +02:00
Joris Vink 296fe7a6d4 seccomp improvements.
More BPF helper macros, more helper for granular syscall checking.
Use these throughout kore where it makes sense.

The new helpers:

- KORE_SYSCALL_DENY_ARG(name, arg, value, errno):
	Deny the system call with errno if the argument matches value.

- KORE_SYSCALL_DENY_MASK(name, arg, mask, errno):
	Deny the system call with errno if the mask argument does not match
	the exact mask given.

- KORE_SYSCALL_DENY_WITH_FLAG(name, arg, flag, errno):
	Deny the system call with errno if the argument contains the
	given flag.

The reverse also exists:

- KORE_SYSCALL_ALLOW_ARG()
- KORE_SYSCALL_ALLOW_MASK()
- KORE_SYSCALL_ALLOW_WITH_FLAG()
2019-09-26 13:51:53 +02:00
Joris Vink c6c253305a swap sockets to use send/recv and update seccomp. 2019-09-26 09:53:51 +02:00
Joris Vink 0314521658 shuffle some stuff around 2019-09-26 09:28:12 +02:00
Joris Vink aafecb9485 Make sure filters from the hook are added first.
This allows user seccomp filters to be added before the kore ones which
means developers can override our own settings.
2019-09-26 09:22:33 +02:00
Joris Vink c1affbbd74 simplify bpf rule generation, add deny macro. 2019-09-25 23:41:43 +02:00
Joris Vink 61b8a9e90d fix tpyo 2019-09-25 16:14:58 +02:00
Joris Vink de97318a95 hide seccomp logs behind !quiet 2019-09-25 16:14:17 +02:00
Joris Vink 4bc39f19af add lstat to worker seccomp filter 2019-09-25 15:44:03 +02:00
Joris Vink 54ca865c11 add a few more syscalls for keymgr.
different platforms may do different things
2019-09-25 15:04:12 +02:00
Joris Vink 68e90507f4 properly seccomp keymgr 2019-09-25 14:41:09 +02:00
Joris Vink cd9971247c Add seccomp syscall filtering to kore.
With this commit all Kore processes (minus the parent) are running
under seccomp.

The worker processes get the bare minimum allowed syscalls while each module
like curl, pgsql, etc will add their own filters to allow what they require.

New API functions:
    int kore_seccomp_filter(const char *name, void *filter, size_t len);

    Adds a filter into the seccomp system (must be called before
    seccomp is enabled).

New helpful macro:
    define KORE_SYSCALL_ALLOW(name)

    Allow the syscall with a given name, should be used in
    a sock_filter data structure.

New hooks:
    void kore_seccomp_hook(void);

    Called before seccomp is enabled, allows developers to add their
    own BPF filters into seccomp.
2019-09-25 14:31:20 +02:00