2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +00:00

3947 Commits

Author SHA1 Message Date
Todd C. Miller
9263e19f7e iolog_adjust_delay: avoid division by zero
Fixes a problem in sudoreplay where a speed factor of 0 or less
would result in a negative delay value that caused a hang during
playback.  Bug #1078.
2025-08-21 12:55:04 -06:00
Todd C. Miller
f73162df35 client_msg_cb: make warning match the function that failed 2025-07-24 07:37:29 -06:00
Todd C. Miller
26a1a7529a digest_matches: plug fd leak on snprinf() failure 2025-07-24 07:34:35 -06:00
Todd C. Miller
8e7e0e23fa ts_write: call lseek after fruncate on short write
We need to make sure the file position is reset to the old EOF on
error.
2025-07-21 07:41:11 -06:00
Todd C. Miller
1c254b3304 visudo: create temporary file as mod 0600 not 0700
This was due to a typo in the mode field when the temporary file
was created.  Noticed by Bjorn Baron of the sudo-rs project.
2025-07-08 07:58:54 -06:00
Todd C. Miller
bc88e5cbd3 Deprecate chroot support 2025-06-28 10:21:36 -06:00
Todd C. Miller
fdafc2ceb3 Revert pivot_root and go back to prepending the new root directory.
We cannot perform passwd/group lookups _after_ changing the root
directory.  This does mean that symbolic links in a path are not
currently handled properly when matching chroot()ed commands.

Fixes a local privilege escalation vulnerability where a user could
craft their own nsswitch.conf file to load a shared library of their
choosing and run arbitrary code.  CVE-2025-32463

Reported by Rich Mirch @ Stratascale Cyber Research Unit (CRU).
2025-06-28 10:21:32 -06:00
Todd C. Miller
d530367828 Only allow a remote host to be specified when listing privileges.
This fixes a bug where a user with sudoers privileges on a different
host could execute a command on the local host, even if the sudoers
file would not otherwise allow this.  CVE-2025-32462

Reported by Rich Mirch @ Stratascale Cyber Research Unit (CRU).
2025-06-28 10:21:28 -06:00
Rose
5fad16bda2 Properly check against errors against fwrite
fwrite is not the same as write; you have to explicitly compare against the length to detect errors, and sometimes number of items is mistaken for length.
2025-06-17 20:29:12 -06:00
Todd C. Miller
04a8117500 Updated translations from translationproject.org 2025-06-08 16:47:28 -06:00
Todd C. Miller
d861a00a67 Update .pot files for 1.9.17 2025-06-08 16:47:28 -06:00
Todd C. Miller
ee1383e311 Fix typo 2025-06-08 07:28:35 -06:00
Todd C. Miller
afd01d856b Add SUDO_TTY environment variable if the user has a tty
This can be used to find the user's original tty device when sudo
runs the command in its own pty.  GitHub issue #447.
2025-06-07 16:21:36 -06:00
Todd C. Miller
82ebb1eaa9 log_failure: only display "command not found" if running a command
If the user is not allowed to run a command, we try to give them a
more useful message than "Sorry, user foo may not run sudo on bar."
However, this should only be done when running, not listing, a
command.  Otherwise, it would be possible for a user with no sudo
privileges to use "sudo -l /path/to/some/command" to determine
whether an executable exists in a directory that they do not have
search access to.
2025-05-06 15:15:11 -06:00
Todd C. Miller
111fd83fb8 Use constant-time string compare for plain text password check.
Avoid potential password guessing based on timing attacks on
the strcmp() function.  Reported by Quarkslab.
2025-04-30 15:24:50 -06:00
Todd C. Miller
a294a8be00 check_user: refactor the "running as self" check into its own function 2025-04-30 13:54:36 -06:00
Todd C. Miller
28837b2af1 check_user: restrict the special case for running as the invoking user
The intent is to allow the user to run a command or edit a file as
themself without entering a password.  It should not apply to listing
a command via "sudo -l command".
2025-04-30 11:07:37 -06:00
Todd C. Miller
ce0ec8ddca Free existing contents of struct eventlog before overwriting.
In the unlikely event that there are duplicate keys in info_msgs,
free the old string before overwriting with the new one.
2025-03-31 20:11:34 -06:00
Todd C. Miller
fce45b2767 Make ignore_dot the default
Add --disable-ignore-dot to disable it and deprecate --with-ignore-dot.
2025-03-08 17:59:32 -07:00
Todd C. Miller
b0d94331c0 No longer need to define NSIG for cppcheck.
There is now a configure check that defines it as needed.
2025-02-11 08:42:57 -07:00
Todd C. Miller
43f16c1d24 regen 2025-02-08 09:12:34 -07:00
Todd C. Miller
a27b989c9c Check for negative return value of read, write and lseek instead of -1
The return values are used in ways that assume they are positive.
In practice, it is not possible to have a negative return value
other than -1 due to the size of the buffers being read from or
written to.  Also add overflow checks when updating the buffer len.
Quiets several coverity warnings.
2025-01-16 19:46:15 -07:00
Todd C. Miller
a3cd820d21 Move LOGIN_NAME_MAX compat define to login_max.c 2025-01-15 08:57:22 -07:00
Todd C. Miller
e3753309fe copy_string: use an end pointer to quiet a coverity warning
Instead of modifying the len parameter and using it for bounds
checking, compute the end of the source string and bound check on
that instead.  Also simplify the code slightly and enable debugging.
2025-01-15 08:45:59 -07:00
Todd C. Miller
af4634a1c1 expand_include: initialize dst_size to 1 to quiet coverity warning
This could only be an issue if the sudoers file was an empty string,
which is not possible.
2025-01-15 08:45:02 -07:00
Todd C. Miller
34a3c84de1 digest_matches: don't initialize digest_len to -1
This was done to quiet a coverity warning but newer coverity now
warns about this instead.
2025-01-15 08:44:23 -07:00
Todd C. Miller
405070d482 Add sudo_login_name_max() and sudo_host_name_max()
These convenience functions cache the value and handle any potenial
errors from sysconf().
2025-01-15 08:42:30 -07:00
Todd C. Miller
01b1410d61 Format T_TIMESPEC as "%d.%d" instead of "%.1f"
This fixes the display of the timeout values in the "sudo -V" output
on systems without a C99-compliant snprintf().  The snprintf()
replacement sudo ships with does not support floating point.
2025-01-11 14:38:16 -07:00
vayers
7c121ff834 Replace tab with space
A line in the sudoers file contains a tab where a space seems to be more
appropriate.
2025-01-11 14:11:56 -07:00
Todd C. Miller
4dbb07c19b The "ALL" command should not override a previous NOSETENV tag in a rule.
Command tags are inherited from previous Cmnds in a Cmnd_Spec_List.
There is a special case of the SETENV tag for the "ALL" command,
where SETENV is implied if no explicit SETENV or NOSETENV tag is
specified.  The code to inherit the SETENV tag didn't take into
account that an implied value for SETENV should also be overridden
by an explicit SETENV or NOSETENV tag in the previous Cmnd in the
Cmnd_Spec_List.
2024-12-20 18:02:43 -07:00
Todd C. Miller
de3b179a03 Don't need to undef _POSIX_HOST_NAME_MAX, it is not used. 2024-12-01 10:00:30 -07:00
Todd C. Miller
d5028a00c0 Use NODEV macro instead of explicit (dev_t)-1.
Also fix an assignment of dev_t to -1 that should be NODEV.
Bug #1074.
2024-11-28 11:26:00 -07:00
Todd C. Miller
f8987fc0bb Work around a bug in UBSan that is causing CI failures.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116834
2024-11-18 11:05:48 -07:00
Todd C. Miller
da20ccec08 Avoid multiple calls to sysonf() via the MAX macro.
The expansion of MAX would result in multiple calls to sysconf().
It is less error-prone to store the result of sysconf() in a long.
2024-11-17 09:46:38 -07:00
Todd C. Miller
3d85f2e98f Add some casts to quiet -Wconversion 2024-11-17 13:01:10 -07:00
Todd C. Miller
9613ef9445 Cast hook functions to sudo_hook_fn_t to fix C23 compile error.
The sudo plugin API defines sudo_hook_fn_t as a function with
unspecified arguments.  This is no longer supported in C23 so use
a variadic function for sudo_hook_fn_t instead.  Moving to a union
may be a better long-term fix.  GitHub issue #420.
2024-11-16 11:33:21 -07:00
Todd C. Miller
9c63ff0e1b Pass NULL, not false, to sudoers_format_default_line(). 2024-11-16 11:21:39 -07:00
Todd C. Miller
0f41cd717f pam_get_item() takes a void ** arg, not const void **, on Solaris 2024-11-11 20:08:13 -07:00
Todd C. Miller
116115229a Do not send mail for "sudo -nv" or "sudo -nl"
This avoids sending mail for users running "sudo -nv" or "sudo -nl"
even when mail_badpass or mail_always are enabled.  We already avoid
logging in that case but mailing was not disabled when that change
was made.  Bug #1072.
2024-10-29 09:05:09 -06:00
Todd C. Miller
17aa7688c9 sudo_pam_verify: move PAM_USER after getpass_error check
Move it into the PAM_SUCCESS case of the switch *pam_status switch.
2024-10-05 16:49:39 -06:00
Todd C. Miller
52c73b8f51 Fix indentation 2024-10-05 14:32:26 -06:00
Marco Trevisan (Treviño)
a68e821ef9 plugins/pam: Check the user didn't change during PAM transaction
PAM modules can change the user during their execution, in such case,
sudo would still use the user that has been provided giving potentially
access to another user with the credentials of another one.

So prevent this to happen, by ensuring that the final PAM user is
matching the one which started the transaction
2024-10-05 11:09:36 -06:00
Célestin Matte
05b5de538b Fix typo in sudoer file comment 2024-09-28 16:52:20 -06:00
Rose
77672d83c4 Put restrict qualifers in strvec_join function pointer 2024-09-21 14:08:13 -06:00
Andy Fiddaman
131e7e2de0 Allow --secure-path-value=no
This adds support for --with-secure-path-value=no to allow packagers
to ship the sudoers configuration file with the secure path
line commented out if required.
2024-09-21 14:03:24 -06:00
Todd C. Miller
0cbddb6939 alias_error: display the file and line info for the duplicate alias
Having the file and line of the previous alias definition should
make it easier to fix duplicate alias errors.
2024-09-13 11:56:09 -06:00
Ferdinand Bachmann
ce36f01def Add pam_silent setting to sudoers example config 2024-09-09 19:54:46 -06:00
Todd C. Miller
22b320645c Fix the date written used by the exit record in sudo-format log files
The change to always get the current time when building a struct
evlog in sudoers broke the data and time written for exit records.
This only affected file-based logs, not syslog.  GitHub issue #405.
2024-09-06 13:05:47 -06:00
Todd C. Miller
4751a4d2dd Make a ttydev parse error non-fatal for now
This is new for sudo 1.9.16 so we don't want to break sudo if there
ends up being a bug in formatting dev_t from the front-end.
2024-08-15 09:31:48 -06:00
Todd C. Miller
827fa8b76d Use sudo_strtonum() instead of strtoull().
Fixes building on systems that lack strtoull().  While dev_t is
unsigned on most systems, we can still use sudo_strtonum() here as
long as we allow the full range of values [LLONG_MIN,LLONG_MAX].
We don't use strtoul() here since some 32-bit systems have 64-bit
dev_t.
2024-08-13 12:43:10 -06:00