[sf-lug] user sudo to itself

Michael Paoli Michael.Paoli at cal.berkeley.edu
Fri Oct 14 22:03:02 PDT 2022

On 2022-10-11 22:43, Yong Tang wrote:
> Hi LUGers,
> I have a question about sudo log.
> In my workplace, users need to sudo to a user named "super" to
> escalate their privilege.  When I browsed the /var/log/secure, I found
> some entries like this below:
> ...:sudo:super: .... : USER=super: .....: /sbin/rm -rf /abc/efg: ......
> I can't figure out in what circumstances that an account like "super"
> sudo to itself.  Any help would be appreciated.

Well ... sudo ... if you allow ... or allow and don't disallow, then ... 
it can, so, let's see ...
First of all what would create a log entry looking like that ...
I'll use account test, rather than super ... notably I already have such 
an account,
and for which it is also suitably named, so ...
# SUDO_EDITOR=/usr/bin/ed visudo -f /etc/sudoers.d/test
test ALL=(ALL:ALL) NOPASSWD: /usr/bin/rm -rf /abc/efg
# sudo -l -U test | sed -ne '/may/,$p'
User test may run the following commands on tigger:
     (ALL : ALL) NOPASSWD: /usr/bin/rm -rf /abc/efg
# ls -ld /abc 2>>/dev/null || echo Nope.
# su - test
$ id
uid=1009(test) gid=1009(test) groups=1009(test),29(audio),44(video)
$ sudo -u test /usr/bin/rm -rf /abc/efg
$ echo "$?"
$ exit
# cd /var/log
# find . -type f ! -mtime +10 ! -size 0 ! -name \*.gz -exec fgrep -al 
/abc/efg \{\} \; 2>>/dev/null
# fgrep /abc/efg auth.log
Oct 15 04:50:09 tigger sudo:     test : TTY=pts/9 ; PWD=/home/t/test ; 
USER=test ; COMMAND=/usr/bin/rm -rf /abc/efg
So ... my log entry from that test looks pretty similar to yours.  What 
if anything is surprising?
Do you allow the permitted sudo command(s) to go to user(s) such as 
super, or what target user(s) exactly do
you allow the sudo commands to user as user(s)?  Sure, default is root, 
but one may specify otherwise ...
e.g. I have sudo commands that run not as user root, but group, or group 
and user bind.
What do you get for:
# sudo -l -U super
What relevant entry(/ies) do you have in sudoers(5)?

# SUDO_EDITOR=/usr/bin/ed visudo -f /etc/sudoers.d/test

More information about the sf-lug mailing list