Przeglądaj źródła

call setgroups() to avoid supplemental group leakage

Calling setgroups() between setgid() and setuid().

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
Yehuda Sadeh 10 lat temu
rodzic
commit
a3c460c209
1 zmienionych plików z 2 dodań i 0 usunięć
  1. 2 0
      src/civetweb.c

+ 2 - 0
src/civetweb.c

@@ -6651,6 +6651,8 @@ static int set_uid_option(struct mg_context *ctx)
             mg_cry(fc(ctx), "%s: unknown user [%s]", __func__, uid);
         } else if (setgid(pw->pw_gid) == -1) {
             mg_cry(fc(ctx), "%s: setgid(%s): %s", __func__, uid, strerror(errno));
+        } else if (setgroups(0, NULL)) {
+            mg_cry(fc(ctx), "%s: setgroups(): %s", __func__, strerror(errno));
         } else if (setuid(pw->pw_uid) == -1) {
             mg_cry(fc(ctx), "%s: setuid(%s): %s", __func__, uid, strerror(errno));
         } else {