HALF ECHO LEARN / REFERENCE COLLECTION

v262.2

src/analyze/analyze-security.c

124,777 bytesGit mode 100644Download original fileLGPL-2.1-or-later

Git blob: 3289ae8f47f753b1bf609aed4c5a9040bd9fa2e9

Lines 1–1000 of 2,984

/* SPDX-License-Identifier: LGPL-2.1-or-later */
 
#include <linux/capability.h>
 
#include "sd-bus.h"
#include "sd-json.h"
 
#include "alloc-util.h"
#include "analyze-verify-util.h"
#include "analyze.h"
#include "analyze-security.h"
#include "bus-error.h"
#include "bus-locator.h"
#include "bus-map-properties.h"
#include "bus-unit-util.h"
#include "bus-util.h"
#include "capability-util.h"
#include "copy.h"
#include "env-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-table.h"
#include "in-addr-prefix-util.h"
#include "manager.h"
#include "mkdir.h"
#include "nulstr-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "portable-util.h"
#include "pretty-print.h"
#include "seccomp-util.h"
#include "service.h"
#include "set.h"
#include "stdio-util.h"
#include "string-util.h"
#include "strv.h"
#include "unit-def.h"
#include "unit-name.h"
#include "unit-serialize.h"
 
typedef struct SecurityInfo {
        char *id;
        char *type;
        char *load_state;
        char *fragment_path;
        bool default_dependencies;
 
        uint64_t ambient_capabilities;
        uint64_t capability_bounding_set;
 
        char *user;
        char **supplementary_groups;
        bool dynamic_user;
 
        bool ip_address_deny_all;
        bool ip_address_allow_localhost;
        bool ip_address_allow_other;
 
        bool ip_filters_custom_ingress;
        bool ip_filters_custom_egress;
 
        char *keyring_mode;
        char *protect_proc;
        char *proc_subset;
        bool lock_personality;
        bool memory_deny_write_execute;
        bool no_new_privileges;
        char *notify_access;
        bool protect_hostname;
 
        bool private_devices;
        bool private_mounts;
        bool private_network;
        bool private_tmp;
        bool private_users;
 
        bool protect_control_groups;
        bool protect_kernel_modules;
        bool protect_kernel_tunables;
        bool protect_kernel_logs;
        bool protect_clock;
 
        char *protect_home;
        char *protect_system;
 
        bool remove_ipc;
 
        bool restrict_address_family_inet;
        bool restrict_address_family_unix;
        bool restrict_address_family_netlink;
        bool restrict_address_family_packet;
        bool restrict_address_family_other;
 
        unsigned long long restrict_namespaces;
        bool restrict_realtime;
        bool restrict_suid_sgid;
 
        char *root_directory;
        char *root_image;
 
        bool delegate;
        char *device_policy;
        char **device_allow;
 
        Set *system_call_architectures;
 
        bool system_call_filter_allow_list;
        Set *system_call_filter;
 
        mode_t _umask;
 
        RuntimeScope runtime_scope;
} SecurityInfo;
 
struct security_assessor {
        const char *id;
        const char *json_field;
        const char *description_good;
        const char *description_bad;
        const char *description_na;
        const char *url;
        uint64_t weight;
        uint64_t range;
        int (*assess)(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description);
        size_t offset;
        uint64_t parameter;
        bool default_dependencies_only;
};
 
static SecurityInfo *security_info_new(void) {
        SecurityInfo *info = new(SecurityInfo, 1);
        if (!info)
                return NULL;
 
        *info = (SecurityInfo) {
                .default_dependencies = true,
                .capability_bounding_set = CAP_MASK_ALL,
                .restrict_namespaces = UINT64_MAX,
                ._umask = 0002,
        };
 
        return info;
}
 
static SecurityInfo *security_info_free(SecurityInfo *i) {
        if (!i)
                return NULL;
 
        free(i->id);
        free(i->type);
        free(i->load_state);
        free(i->fragment_path);
 
        free(i->user);
 
        free(i->protect_home);
        free(i->protect_system);
 
        free(i->root_directory);
        free(i->root_image);
 
        free(i->keyring_mode);
        free(i->protect_proc);
        free(i->proc_subset);
        free(i->notify_access);
 
        free(i->device_policy);
        strv_free(i->device_allow);
 
        strv_free(i->supplementary_groups);
        set_free(i->system_call_architectures);
        set_free(i->system_call_filter);
 
        return mfree(i);
}
 
DEFINE_TRIVIAL_CLEANUP_FUNC(SecurityInfo*, security_info_free);
 
static bool security_info_runs_privileged(const SecurityInfo *i)  {
        assert(i);
 
        /* For the common --user case the manager runs as a regular user and cannot switch
         * UID, so user-scope services never end up privileged. We deliberately do not
         * handle root-owned user managers (user@0.service) here: in that narrow case the
         * service really is privileged and will be mis-classified. */
        if (i->runtime_scope == RUNTIME_SCOPE_USER)
                return false;
 
        if (STRPTR_IN_SET(i->user, "0", "root"))
                return true;
 
        if (i->dynamic_user)
                return false;
 
        return isempty(i->user);
}
 
static int assess_bool(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        const bool *b = ASSERT_PTR(data);
 
        assert(ret_badness);
        assert(ret_description);
 
        *ret_badness = a->parameter ? *b : !*b;
        *ret_description = NULL;
 
        return 0;
}
 
static int assess_user(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        const char *d;
        uint64_t b;
        int r;
 
        assert(ret_badness);
        assert(ret_description);
 
        if (streq_ptr(info->user, NOBODY_USER_NAME)) {
                d = "Service runs under as '" NOBODY_USER_NAME "' user, which should not be used for services";
                b = 9;
        } else if (info->dynamic_user && !STR_IN_SET(info->user, "0", "root")) {
                d = "Service runs under a transient non-root user identity";
                b = 0;
        } else if (info->user && !STR_IN_SET(info->user, "0", "root", "")) {
                d = "Service runs under a static non-root user identity";
                b = 0;
        } else if (info->runtime_scope == RUNTIME_SCOPE_USER) {
                /* Same caveat as security_info_runs_privileged(): root-owned user
                 * managers (user@0.service) will be reported as non-root here, which is
                 * incorrect but matches the heuristic. */
                d = "Service runs under the calling user's identity";
                b = 0;
        } else {
                *ret_badness = 10;
                *ret_description = NULL;
                return 0;
        }
 
        r = strdup_to(ret_description, d);
        if (r < 0)
                return r;
 
        *ret_badness = b;
        return 0;
}
 
static int assess_protect_home(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        const char *description;
        uint64_t badness;
        int r;
 
        assert(ret_badness);
        assert(ret_description);
 
        badness = 10;
        description = "Service has full access to home directories";
 
        r = parse_boolean(info->protect_home);
        if (r < 0) {
                if (streq_ptr(info->protect_home, "read-only")) {
                        badness = 5;
                        description = "Service has read-only access to home directories";
                } else if (streq_ptr(info->protect_home, "tmpfs")) {
                        badness = 1;
                        description = "Service has access to fake empty home directories";
                }
        } else if (r > 0) {
                badness = 0;
                description = "Service has no access to home directories";
        }
 
        r = strdup_to(ret_description, description);
        if (r < 0)
                return r;
 
        *ret_badness = badness;
        return 0;
}
 
static int assess_protect_system(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        const char *description;
        uint64_t badness;
        int r;
 
        assert(ret_badness);
        assert(ret_description);
 
        badness = 10;
        description = "Service has full access to the OS file hierarchy";
 
        r = parse_boolean(info->protect_system);
        if (r < 0) {
                if (streq_ptr(info->protect_system, "full")) {
                        badness = 3;
                        description = "Service has very limited write access to the OS file hierarchy";
                } else if (streq_ptr(info->protect_system, "strict")) {
                        badness = 0;
                        description = "Service has strict read-only access to the OS file hierarchy";
                }
        } else if (r > 0) {
                badness = 5;
                description = "Service has limited write access to the OS file hierarchy";
        }
 
        r = strdup_to(ret_description, description);
        if (r < 0)
                return r;
 
        *ret_badness = badness;
        return 0;
}
 
static int assess_root_directory(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        assert(ret_badness);
        assert(ret_description);
 
        *ret_badness =
                empty_or_root(info->root_directory) &&
                empty_or_root(info->root_image);
        *ret_description = NULL;
 
        return 0;
}
 
static int assess_capability_bounding_set(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        assert(ret_badness);
        assert(ret_description);
 
        *ret_badness = !!(info->capability_bounding_set & a->parameter);
        *ret_description = NULL;
 
        return 0;
}
 
static int assess_umask(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        const char *d;
        uint64_t b;
        int r;
 
        assert(ret_badness);
        assert(ret_description);
 
        if (!FLAGS_SET(info->_umask, 0002)) {
                d = "Files created by service are world-writable by default";
                b = 10;
        } else if (!FLAGS_SET(info->_umask, 0004)) {
                d = "Files created by service are world-readable by default";
                b = 5;
        } else if (!FLAGS_SET(info->_umask, 0020)) {
                d = "Files created by service are group-writable by default";
                b = 2;
        } else if (!FLAGS_SET(info->_umask, 0040)) {
                d = "Files created by service are group-readable by default";
                b = 1;
        } else {
                d = "Files created by service are accessible only by service's own user by default";
                b = 0;
        }
 
        r = strdup_to(ret_description, d);
        if (r < 0)
                return r;
 
        *ret_badness = b;
        return 0;
}
 
static int assess_keyring_mode(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        assert(ret_badness);
        assert(ret_description);
 
        *ret_badness = !streq_ptr(info->keyring_mode, "private");
        *ret_description = NULL;
 
        return 0;
}
 
static int assess_protect_proc(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        assert(ret_badness);
        assert(ret_description);
 
        if (streq_ptr(info->protect_proc, "noaccess"))
                *ret_badness = 1;
        else if (STRPTR_IN_SET(info->protect_proc, "invisible", "ptraceable"))
                *ret_badness = 0;
        else
                *ret_badness = 3;
 
        *ret_description = NULL;
 
        return 0;
}
 
static int assess_proc_subset(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        assert(ret_badness);
        assert(ret_description);
 
        *ret_badness = !streq_ptr(info->proc_subset, "pid");
        *ret_description = NULL;
 
        return 0;
}
 
static int assess_notify_access(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        assert(ret_badness);
        assert(ret_description);
 
        *ret_badness = streq_ptr(info->notify_access, "all");
        *ret_description = NULL;
 
        return 0;
}
 
static int assess_remove_ipc(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        assert(ret_badness);
        assert(ret_description);
 
        if (info->runtime_scope == RUNTIME_SCOPE_USER) {
                *ret_badness = UINT64_MAX;
                return strdup_to(ret_description,
                                 "RemoveIPC= has no effect on per-user services");
        }
 
        if (security_info_runs_privileged(info))
                *ret_badness = UINT64_MAX;
        else
                *ret_badness = !info->remove_ipc;
 
        *ret_description = NULL;
        return 0;
}
 
static int assess_supplementary_groups(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        assert(ret_badness);
        assert(ret_description);
 
        if (security_info_runs_privileged(info))
                *ret_badness = UINT64_MAX;
        else
                *ret_badness = !strv_isempty(info->supplementary_groups);
 
        *ret_description = NULL;
        return 0;
}
 
static int assess_restrict_namespaces(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        assert(ret_badness);
        assert(ret_description);
 
        *ret_badness = !!(info->restrict_namespaces & a->parameter);
        *ret_description = NULL;
 
        return 0;
}
 
#if HAVE_SECCOMP
 
static int assess_system_call_architectures(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        const char *d;
        uint64_t b;
        int r;
 
        assert(ret_badness);
        assert(ret_description);
 
        if (set_isempty(info->system_call_architectures)) {
                b = 10;
                d = "Service may execute system calls with all ABIs";
        } else if (set_contains(info->system_call_architectures, "native") &&
                   set_size(info->system_call_architectures) == 1) {
                b = 0;
                d = "Service may execute system calls only with native ABI";
        } else {
                b = 8;
                d = "Service may execute system calls with multiple ABIs";
        }
 
        r = strdup_to(ret_description, d);
        if (r < 0)
                return r;
 
        *ret_badness = b;
        return 0;
}
 
static bool syscall_names_in_filter(Set *s, bool allow_list, const SyscallFilterSet *f, const char **ret_offending_syscall) {
        assert(ret_offending_syscall);
 
        NULSTR_FOREACH(syscall, f->value) {
                if (syscall[0] == '@') {
                        const SyscallFilterSet *g;
 
                        assert_se(g = syscall_filter_set_find(syscall));
                        if (syscall_names_in_filter(s, allow_list, g, ret_offending_syscall))
                                return true; /* bad! */
 
                        continue;
                }
 
                /* Let's see if the system call actually exists on this platform, before complaining */
                if (sym_seccomp_syscall_resolve_name(syscall) < 0)
                        continue;
 
                if (set_contains(s, syscall) == allow_list) {
                        log_debug("Offending syscall filter item: %s", syscall);
                        *ret_offending_syscall = syscall;
                        return true; /* bad! */
                }
        }
 
        *ret_offending_syscall = NULL;
        return false;
}
 
static int assess_system_call_filter(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        assert(a);
        assert(info);
        assert(ret_badness);
        assert(ret_description);
 
        assert(a->parameter < _SYSCALL_FILTER_SET_MAX);
        const SyscallFilterSet *f = syscall_filter_sets + a->parameter;
 
        char *d;
        uint64_t b;
        int r;
 
        r = dlopen_libseccomp(LOG_DEBUG);
        if (r < 0) {
                *ret_badness = UINT64_MAX;
                *ret_description = NULL;
                return r;
        }
 
        if (!info->system_call_filter_allow_list && set_isempty(info->system_call_filter)) {
                r = strdup_to(&d, "Service does not filter system calls");
                b = 10;
        } else {
                bool bad;
                const char *offender = NULL;
 
                log_debug("Analyzing system call filter, checking against: %s", f->name);
                bad = syscall_names_in_filter(info->system_call_filter, info->system_call_filter_allow_list, f, &offender);
                log_debug("Result: %s", bad ? "bad" : "good");
 
                if (info->system_call_filter_allow_list) {
                        if (bad) {
                                r = asprintf(&d, "System call allow list defined for service, and %s is included "
                                             "(e.g. %s is allowed)",
                                             f->name, offender);
                                b = 9;
                        } else {
                                r = asprintf(&d, "System call allow list defined for service, and %s is not included",
                                             f->name);
                                b = 0;
                        }
                } else {
                        if (bad) {
                                r = asprintf(&d, "System call deny list defined for service, and %s is not included "
                                             "(e.g. %s is allowed)",
                                             f->name, offender);
                                b = 10;
                        } else {
                                r = asprintf(&d, "System call deny list defined for service, and %s is included",
                                             f->name);
                                b = 0;
                        }
                }
        }
        if (r < 0)
                return log_oom();
 
        *ret_description = d;
        *ret_badness = b;
 
        return 0;
}
 
#endif
 
static int assess_ip_address_allow(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        const char *d;
        uint64_t b;
        int r;
 
        assert(info);
        assert(ret_badness);
        assert(ret_description);
 
        if (info->ip_filters_custom_ingress || info->ip_filters_custom_egress) {
                d = "Service defines custom ingress/egress IP filters with BPF programs";
                b = 0;
        } else if (!info->ip_address_deny_all) {
                d = "Service does not define an IP address allow list";
                b = 10;
        } else if (info->ip_address_allow_other) {
                d = "Service defines IP address allow list with non-localhost entries";
                b = 5;
        } else if (info->ip_address_allow_localhost) {
                d = "Service defines IP address allow list with only localhost entries";
                b = 2;
        } else {
                d = "Service blocks all IP address ranges";
                b = 0;
        }
 
        r = strdup_to(ret_description, d);
        if (r < 0)
                return r;
 
        *ret_badness = b;
        return 0;
}
 
static int assess_device_allow(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        char *d;
        uint64_t b;
 
        assert(info);
        assert(ret_badness);
        assert(ret_description);
 
        if (STRPTR_IN_SET(info->device_policy, "strict", "closed")) {
 
                if (!strv_isempty(info->device_allow)) {
                        _cleanup_free_ char *join = NULL;
 
                        join = strv_join(info->device_allow, " ");
                        if (!join)
                                return log_oom();
 
                        d = strjoin("Service has a device ACL with some special devices: ", join);
                        b = 5;
                } else {
                        d = strdup("Service has a minimal device ACL");
                        b = 0;
                }
        } else {
                d = strdup("Service has no device ACL");
                b = 10;
        }
 
        if (!d)
                return log_oom();
 
        *ret_badness = b;
        *ret_description = d;
 
        return 0;
}
 
static int assess_ambient_capabilities(
                const struct security_assessor *a,
                const SecurityInfo *info,
                const void *data,
                uint64_t *ret_badness,
                char **ret_description) {
 
        assert(ret_badness);
        assert(ret_description);
 
        *ret_badness = info->ambient_capabilities != 0;
        *ret_description = NULL;
 
        return 0;
}
 
static const struct security_assessor security_assessor_table[] = {
        {
                .id = "User=/DynamicUser=",
                .json_field = "UserOrDynamicUser",
                .description_bad = "Service runs as root user",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#User=",
                .weight = 2000,
                .range = 10,
                .assess = assess_user,
        },
        {
                .id = "SupplementaryGroups=",
                .json_field = "SupplementaryGroups",
                .description_good = "Service has no supplementary groups",
                .description_bad = "Service runs with supplementary groups",
                .description_na = "Service runs as root, option does not matter",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#SupplementaryGroups=",
                .weight = 200,
                .range = 1,
                .assess = assess_supplementary_groups,
        },
        {
                .id = "PrivateDevices=",
                .json_field = "PrivateDevices",
                .description_good = "Service has no access to hardware devices",
                .description_bad = "Service potentially has access to hardware devices",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#PrivateDevices=",
                .weight = 1000,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, private_devices),
        },
        {
                .id = "PrivateMounts=",
                .json_field = "PrivateMounts",
                .description_good = "Service cannot install system mounts",
                .description_bad = "Service may install system mounts",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#PrivateMounts=",
                .weight = 1000,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, private_mounts),
        },
        {
                .id = "PrivateNetwork=",
                .json_field = "PrivateNetwork",
                .description_good = "Service has no access to the host's network",
                .description_bad = "Service has access to the host's network",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#PrivateNetwork=",
                .weight = 2500,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, private_network),
        },
        {
                .id = "PrivateTmp=",
                .json_field = "PrivateTmp",
                .description_good = "Service has no access to other software's temporary files",
                .description_bad = "Service has access to other software's temporary files",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#PrivateTmp=",
                .weight = 1000,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, private_tmp),
                .default_dependencies_only = true,
        },
        {
                .id = "PrivateUsers=",
                .json_field = "PrivateUsers",
                .description_good = "Service does not have access to other users",
                .description_bad = "Service has access to other users",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#PrivateUsers=",
                .weight = 1000,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, private_users),
        },
        {
                .id = "ProtectControlGroups=",
                .json_field = "ProtectControlGroups",
                .description_good = "Service cannot modify the control group file system",
                .description_bad = "Service may modify the control group file system",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ProtectControlGroups=",
                .weight = 1000,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, protect_control_groups),
        },
        {
                .id = "ProtectKernelModules=",
                .json_field = "ProtectKernelModules",
                .description_good = "Service cannot load or read kernel modules",
                .description_bad = "Service may load or read kernel modules",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ProtectKernelModules=",
                .weight = 1000,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, protect_kernel_modules),
        },
        {
                .id = "ProtectKernelTunables=",
                .json_field = "ProtectKernelTunables",
                .description_good = "Service cannot alter kernel tunables (/proc/sys, …)",
                .description_bad = "Service may alter kernel tunables",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ProtectKernelTunables=",
                .weight = 1000,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, protect_kernel_tunables),
        },
        {
                .id = "ProtectKernelLogs=",
                .json_field = "ProtectKernelLogs",
                .description_good = "Service cannot read from or write to the kernel log ring buffer",
                .description_bad = "Service may read from or write to the kernel log ring buffer",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ProtectKernelLogs=",
                .weight = 1000,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, protect_kernel_logs),
        },
        {
                .id = "ProtectClock=",
                .json_field = "ProtectClock",
                .description_good = "Service cannot write to the hardware clock or system clock",
                .description_bad = "Service may write to the hardware clock or system clock",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ProtectClock=",
                .weight = 1000,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, protect_clock),
        },
        {
                .id = "ProtectHome=",
                .json_field = "ProtectHome",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ProtectHome=",
                .weight = 1000,
                .range = 10,
                .assess = assess_protect_home,
                .default_dependencies_only = true,
        },
        {
                .id = "ProtectHostname=",
                .json_field = "ProtectHostname",
                .description_good = "Service cannot change system host/domainname",
                .description_bad = "Service may change system host/domainname",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ProtectHostname=",
                .weight = 50,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, protect_hostname),
        },
        {
                .id = "ProtectSystem=",
                .json_field = "ProtectSystem",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ProtectSystem=",
                .weight = 1000,
                .range = 10,
                .assess = assess_protect_system,
                .default_dependencies_only = true,
        },
        {
                .id = "RootDirectory=/RootImage=",
                .json_field = "RootDirectoryOrRootImage",
                .description_good = "Service has its own root directory/image",
                .description_bad = "Service runs within the host's root directory",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RootDirectory=",
                .weight = 200,
                .range = 1,
                .assess = assess_root_directory,
                .default_dependencies_only = true,
        },
        {
                .id = "LockPersonality=",
                .json_field = "LockPersonality",
                .description_good = "Service cannot change ABI personality",
                .description_bad = "Service may change ABI personality",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#LockPersonality=",
                .weight = 100,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, lock_personality),
        },
        {
                .id = "MemoryDenyWriteExecute=",
                .json_field = "MemoryDenyWriteExecute",
                .description_good = "Service cannot create writable executable memory mappings",
                .description_bad = "Service may create writable executable memory mappings",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#MemoryDenyWriteExecute=",
                .weight = 100,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, memory_deny_write_execute),
        },
        {
                .id = "NoNewPrivileges=",
                .json_field = "NoNewPrivileges",
                .description_good = "Service processes cannot acquire new privileges",
                .description_bad = "Service processes may acquire new privileges",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#NoNewPrivileges=",
                .weight = 1000,
                .range = 1,
                .assess = assess_bool,
                .offset = offsetof(SecurityInfo, no_new_privileges),
        },
        {
                .id = "CapabilityBoundingSet=~CAP_SYS_ADMIN",
                .json_field = "CapabilityBoundingSet_CAP_SYS_ADMIN",
                .description_good = "Service has no administrator privileges",
                .description_bad = "Service has administrator privileges",
                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#CapabilityBoundingSet=",
                .weight = 1500,
                .range = 1,
                .assess = assess_capability_bounding_set,
                .parameter = UINT64_C(1) << CAP_SYS_ADMIN,
        },
        {
                .id = "CapabilityBoundingSet=~CAP_SET(UID|GID|PCAP)",
                .json_field = "CapabilityBoundingSet_CAP_SET_UID_GID_PCAP",
                .description_good = "Service cannot change UID/GID identities/capabilities",