summaryrefslogtreecommitdiffstats
path: root/debian/patches/Add-sudoedit-flag-checks-in-plugin-that-are-consiste.patch
blob: 0fd3071207bc9445dcc0d3fd3b7a5b4485e85f6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From 9f8d2f158166512511aac5e32928dcf6c65005c3 Mon Sep 17 00:00:00 2001
From: "Todd C. Miller" <Todd.Miller@sudo.ws>
Date: Wed, 20 Jan 2021 09:03:17 +0100
Subject: [PATCH 2/5] Add sudoedit flag checks in plugin that are consistent
 with front-end.

Don't assume the sudo front-end is sending reasonable mode flags.
These checks need to be kept consistent between the sudo front-end
and the sudoers plugin.

[Salvatore Bonaccorso: Backport to 1.8.27: Context changes]
---
 plugins/sudoers/policy.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--- a/plugins/sudoers/policy.c
+++ b/plugins/sudoers/policy.c
@@ -98,10 +98,11 @@ parse_bool(const char *line, int varlen,
 int
 sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
 {
+    const int edit_mask = MODE_EDIT|MODE_IGNORE_TICKET|MODE_NONINTERACTIVE;
     struct sudoers_policy_open_info *info = v;
-    char * const *cur;
     const char *p, *errstr, *groups = NULL;
     const char *remhost = NULL;
+    char * const *cur;
     bool uid_set = false, gid_set = false;
     int flags = 0;
     debug_decl(sudoers_policy_deserialize_info, SUDOERS_DEBUG_PLUGIN)
@@ -331,6 +332,12 @@ sudoers_policy_deserialize_info(void *v,
 #endif
     }
 
+    /* Sudo front-end should restrict mode flags for sudoedit. */
+    if (ISSET(flags, MODE_EDIT) && (flags & edit_mask) != flags) {
+	sudo_warnx(U_("invalid mode flags from sudo front end: 0x%x"), flags);
+	goto bad;
+    }
+
     user_umask = (mode_t)-1;
     for (cur = info->user_info; *cur != NULL; cur++) {
 	if (MATCHES(*cur, "user=")) {