Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
No build reason found for SLE-Module-HPC:x86_64
SUSE:SLE-15-SP2:GA
sudo
sudo-CVE-2023-22809.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File sudo-CVE-2023-22809.patch of Package sudo
diff --git a/plugins/sudoers/editor.c b/plugins/sudoers/editor.c index ec8e7b0..bee9bc1 100644 --- a/plugins/sudoers/editor.c +++ b/plugins/sudoers/editor.c @@ -54,7 +54,7 @@ resolve_editor(const char *ed, size_t edlen, int nfiles, char **files, const char *cp, *ep, *tmp; const char *edend = ed + edlen; struct stat user_editor_sb; - int nargc; + int nargc = 0; debug_decl(resolve_editor, SUDOERS_DEBUG_UTIL) /* @@ -103,6 +103,21 @@ resolve_editor(const char *ed, size_t edlen, int nfiles, char **files, free(nargv); debug_return_str(NULL); } + + /* + * We use "--" to separate the editor and arguments from the files + * to edit. The editor arguments themselves may not contain "--". + */ + if (strcmp(nargv[nargc], "--") == 0) { + sudo_warnx(U_("ignoring editor: %.*s"), (int)edlen, ed); + sudo_warnx("%s", U_("editor arguments may not contain \"--\"")); + errno = EINVAL; + free(editor_path); + while (nargc--) + free(nargv[nargc]); + free(nargv); + debug_return_str(NULL); + } } if (nfiles != 0) { nargv[nargc++] = "--"; diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index 5f10653..c702878 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -588,19 +588,29 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], /* Note: must call audit before uid change. */ if (ISSET(sudo_mode, MODE_EDIT)) { int edit_argc; - const char *env_editor; + const char *env_editor = NULL; free(safe_cmnd); safe_cmnd = find_editor(NewArgc - 1, NewArgv + 1, &edit_argc, &edit_argv, NULL, &env_editor, false); if (safe_cmnd == NULL) { - if (errno != ENOENT) - goto done; + switch (errno) { + case ENOENT: audit_failure(NewArgc, NewArgv, N_("%s: command not found"), - env_editor ? env_editor : def_editor); + env_editor ? env_editor : def_editor); sudo_warnx(U_("%s: command not found"), - env_editor ? env_editor : def_editor); + env_editor ? env_editor : def_editor); goto bad; + case EINVAL: + if (def_env_editor && env_editor != NULL) { + /* User tried to do something funny with the editor. */ + log_warningx(SLOG_NO_STDERR|SLOG_SEND_MAIL, + "invalid user-specified editor: %s", env_editor); + goto bad; + } + default: + goto done; + } } if (audit_success(edit_argc, edit_argv) != 0 && !def_ignore_audit_errors) goto done; diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index 50dda59..00cfe53 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -306,7 +306,7 @@ static char * get_editor(int *editor_argc, char ***editor_argv) { char *editor_path = NULL, **whitelist = NULL; - const char *env_editor; + const char *env_editor = NULL; static char *files[] = { "+1", "sudoers" }; unsigned int whitelist_len = 0; debug_decl(get_editor, SUDOERS_DEBUG_UTIL) @@ -340,7 +340,11 @@ get_editor(int *editor_argc, char ***editor_argv) if (editor_path == NULL) { if (def_env_editor && env_editor != NULL) { /* We are honoring $EDITOR so this is a fatal error. */ - sudo_fatalx(U_("specified editor (%s) doesn't exist"), env_editor); + if (errno == ENOENT) { + sudo_warnx(U_("specified editor (%s) doesn't exist"), + env_editor); + } + exit(EXIT_FAILURE); } sudo_fatalx(U_("no editor found (editor path = %s)"), def_editor); }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor