c2dfb7
From 3d338556760632b9c8b646a719d56e02e3ad2088 Mon Sep 17 00:00:00 2001
c2dfb7
From: Lennart Poettering <lennart@poettering.net>
c2dfb7
Date: Wed, 20 Mar 2019 19:20:35 +0100
c2dfb7
Subject: [PATCH] analyze: check for RestrictSUIDSGID= in "systemd-analyze
c2dfb7
 security"
c2dfb7
c2dfb7
And let's give it a heigh weight, since it pretty much can be used for
c2dfb7
bad things only.
c2dfb7
c2dfb7
(cherry picked from commit 9d880b70ba5c6ca83c82952f4c90e86e56c7b70c)
c2dfb7
Related: #1687512
c2dfb7
---
c2dfb7
 src/analyze/analyze-security.c | 12 ++++++++++++
c2dfb7
 1 file changed, 12 insertions(+)
c2dfb7
c2dfb7
diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c
c2dfb7
index eec040d5c3..969101c57b 100644
c2dfb7
--- a/src/analyze/analyze-security.c
c2dfb7
+++ b/src/analyze/analyze-security.c
c2dfb7
@@ -69,6 +69,7 @@ struct security_info {
c2dfb7
 
c2dfb7
         uint64_t restrict_namespaces;
c2dfb7
         bool restrict_realtime;
c2dfb7
+        bool restrict_suid_sgid;
c2dfb7
 
c2dfb7
         char *root_directory;
c2dfb7
         char *root_image;
c2dfb7
@@ -1130,6 +1131,16 @@ static const struct security_assessor security_assessor_table[] = {
c2dfb7
                 .assess = assess_bool,
c2dfb7
                 .offset = offsetof(struct security_info, restrict_realtime),
c2dfb7
         },
c2dfb7
+        {
c2dfb7
+                .id = "RestrictSUIDSGID=",
c2dfb7
+                .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RestrictSUIDSGID=",
c2dfb7
+                .description_good = "SUID/SGID file creation by service is restricted",
c2dfb7
+                .description_bad = "Service may create SUID/SGID files",
c2dfb7
+                .weight = 1000,
c2dfb7
+                .range = 1,
c2dfb7
+                .assess = assess_bool,
c2dfb7
+                .offset = offsetof(struct security_info, restrict_suid_sgid),
c2dfb7
+        },
c2dfb7
         {
c2dfb7
                 .id = "RestrictNamespaces=~CLONE_NEWUSER",
c2dfb7
                 .url = "https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RestrictNamespaces=",
c2dfb7
@@ -1862,6 +1873,7 @@ static int acquire_security_info(sd_bus *bus, const char *name, struct security_
c2dfb7
                 { "RestrictAddressFamilies", "(bas)",   property_read_restrict_address_families, 0                                                         },
c2dfb7
                 { "RestrictNamespaces",      "t",       NULL,                                    offsetof(struct security_info, restrict_namespaces)       },
c2dfb7
                 { "RestrictRealtime",        "b",       NULL,                                    offsetof(struct security_info, restrict_realtime)         },
c2dfb7
+                { "RestrictSUIDSGID",        "b",       NULL,                                    offsetof(struct security_info, restrict_suid_sgid)        },
c2dfb7
                 { "RootDirectory",           "s",       NULL,                                    offsetof(struct security_info, root_directory)            },
c2dfb7
                 { "RootImage",               "s",       NULL,                                    offsetof(struct security_info, root_image)                },
c2dfb7
                 { "SupplementaryGroups",     "as",      NULL,                                    offsetof(struct security_info, supplementary_groups)      },