Skip to content

Commit c4d3840

Browse files
committed
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.
1 parent b301b46 commit c4d3840

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

plugins/sudoers/policy.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ parse_bool(const char *line, int varlen, int *flags, int fval)
8888
int
8989
sudoers_policy_deserialize_info(void *v)
9090
{
91+
const int edit_mask = MODE_EDIT|MODE_IGNORE_TICKET|MODE_NONINTERACTIVE;
9192
struct sudoers_open_info *info = v;
92-
char * const *cur;
9393
const char *p, *errstr, *groups = NULL;
9494
const char *remhost = NULL;
95+
char * const *cur;
9596
int flags = 0;
9697
debug_decl(sudoers_policy_deserialize_info, SUDOERS_DEBUG_PLUGIN);
9798

@@ -348,6 +349,12 @@ sudoers_policy_deserialize_info(void *v)
348349
#endif
349350
}
350351

352+
/* Sudo front-end should restrict mode flags for sudoedit. */
353+
if (ISSET(flags, MODE_EDIT) && (flags & edit_mask) != flags) {
354+
sudo_warnx(U_("invalid mode flags from sudo front end: 0x%x"), flags);
355+
goto bad;
356+
}
357+
351358
user_gid = (gid_t)-1;
352359
user_sid = (pid_t)-1;
353360
user_uid = (gid_t)-1;

0 commit comments

Comments
 (0)