Add intercept_verify sudoers option to control execve(2) argument checking.

This commit is contained in:
Todd C. Miller
2022-07-29 15:22:27 -06:00
parent b80b012de0
commit 3ce19efca9
10 changed files with 99 additions and 32 deletions

View File

@@ -667,6 +667,10 @@ struct sudo_defs_types sudo_defs_table[] = {
"intercept_type", T_TUPLE,
N_("The mechanism used by the intercept and log_subcmds options: %s"),
def_data_intercept_type,
}, {
"intercept_verify", T_FLAG,
N_("Whether to verify the command and arguments after execution"),
NULL,
}, {
"apparmor_profile", T_STR,
N_("AppArmor profile to use in the new security context: %s"),

View File

@@ -308,7 +308,9 @@
#define def_passprompt_regex (sudo_defs_table[I_PASSPROMPT_REGEX].sd_un.list)
#define I_INTERCEPT_TYPE 153
#define def_intercept_type (sudo_defs_table[I_INTERCEPT_TYPE].sd_un.tuple)
#define I_APPARMOR_PROFILE 154
#define I_INTERCEPT_VERIFY 154
#define def_intercept_verify (sudo_defs_table[I_INTERCEPT_VERIFY].sd_un.flag)
#define I_APPARMOR_PROFILE 155
#define def_apparmor_profile (sudo_defs_table[I_APPARMOR_PROFILE].sd_un.str)
enum def_tuple {

View File

@@ -479,6 +479,9 @@ intercept_type
T_TUPLE
"The mechanism used by the intercept and log_subcmds options: %s"
dso trace
intercept_verify
T_FLAG
"Whether to verify the command and arguments after execution"
apparmor_profile
T_STR
"AppArmor profile to use in the new security context: %s"

View File

@@ -549,6 +549,7 @@ init_defaults(void)
if ((def_rlimit_core = strdup("0,0")) == NULL)
goto oom;
def_intercept_type = dso;
def_intercept_verify = true;
def_netgroup_tuple = false;
def_sudoedit_checkdir = true;
def_iolog_mode = S_IRUSR|S_IWUSR;

View File

@@ -636,7 +636,7 @@ sudoers_policy_store_result(bool accepted, char *argv[], char *envp[],
}
/* Increase the length of command_info as needed, it is *not* checked. */
command_info = calloc(71, sizeof(char *));
command_info = calloc(72, sizeof(char *));
if (command_info == NULL)
goto oom;
@@ -812,6 +812,10 @@ sudoers_policy_store_result(bool accepted, char *argv[], char *envp[],
if ((command_info[info_len++] = strdup("use_ptrace=true")) == NULL)
goto oom;
}
if (def_intercept_verify) {
if ((command_info[info_len++] = strdup("intercept_verify=true")) == NULL)
goto oom;
}
if (def_noexec) {
if ((command_info[info_len++] = strdup("noexec=true")) == NULL)
goto oom;