LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   slackware hardening tips -Su: authentication failure (https://www.linuxquestions.org/questions/slackware-14/slackware-hardening-tips-su-authentication-failure-4175471021/)

san2ban 07-26-2013 11:22 AM

slackware hardening tips -Su: authentication failure
 
Dear slackers

Followed below link
http://www.linuxquestions.org/questi...4/#comment5965

Now, I unable to su
Code:

bash-4.2$ su
Password:
su: Authentication failure
bash-4.2$

How to undo this?

business_kid 07-26-2013 11:47 AM

Have you joined the wheel group?

I don know why you did that to yourself BTW, but the easy answer is

Code:

usermod -aG  wheel  your_user

san2ban 07-27-2013 10:01 AM

Code:

bash-4.2# groups san2ban
san2ban : users wheel
bash-4.2#

Yes, I am in wheel
The reason I did this is because, when I used to do sudo, it used to say I am not in the sudoer's list, though I was in 'wheel' group. Hence, just thought that this (su hardened thread) might help in getting out of this situation
Code:

bash-4.2# cat /etc/sudoers
## sudoers file.
##
## This file MUST be edited with the 'visudo' command as root.
## Failure to use 'visudo' may result in syntax or file permission errors
## that prevent sudo from running.
##
## See the sudoers man page for the details on how to write a sudoers file.
##

##
## Host alias specification
##
## Groups of machines. These may include host names (optionally with wildcards),
## IP addresses, network numbers or netgroups.
# Host_Alias        WEBSERVERS = www1, www2, www3

##
## User alias specification
##
## Groups of users.  These may consist of user names, uids, Unix groups,
## or netgroups.
# User_Alias        ADMINS = millert, dowdy, mikef

##
## Cmnd alias specification
##
## Groups of commands.  Often used to group related commands together.
# Cmnd_Alias        PROCESSES = /usr/bin/nice, /bin/kill, /usr/bin/renice, \
#                            /usr/bin/pkill, /usr/bin/top

##
## Defaults specification
##
## You may wish to keep some of the following environment variables
## when running commands via sudo.
##
## Locale settings
# Defaults env_keep += "LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET"
##
## Run X applications through sudo; HOME is used to find the
## .Xauthority file.  Note that other programs use HOME to find 
## configuration files and this may lead to privilege escalation!
# Defaults env_keep += "HOME"
##
## X11 resource path settings
# Defaults env_keep += "XAPPLRESDIR XFILESEARCHPATH XUSERFILESEARCHPATH"
##
## Desktop path settings
# Defaults env_keep += "QTDIR KDEDIR"
##
## Allow sudo-run commands to inherit the callers' ConsoleKit session
# Defaults env_keep += "XDG_SESSION_COOKIE"
##
## Uncomment to enable special input methods.  Care should be taken as
## this may allow users to subvert the command being run via sudo.
# Defaults env_keep += "XMODIFIERS GTK_IM_MODULE QT_IM_MODULE QT_IM_SWITCHER"
##
## Uncomment to enable logging of a command's output, except for
## sudoreplay and reboot.  Use sudoreplay to play back logged sessions.
# Defaults log_output
# Defaults!/usr/bin/sudoreplay !log_output
# Defaults!/usr/local/bin/sudoreplay !log_output
# Defaults!/sbin/reboot !log_output

##
## Runas alias specification
##

##
## User privilege specification
##
root ALL=(ALL) ALL

## Uncomment to allow members of group wheel to execute any command
%wheel ALL=(ALL) ALL

## Same thing without a password
 #%wheel ALL=(ALL) NOPASSWD: ALL

## Uncomment to allow members of group sudo to execute any command
# %sudo        ALL=(ALL) ALL

## Uncomment to allow any user to run sudo if they know the password
## of the user they are running the command as (root by default).
# Defaults targetpw  # Ask for the password of the target user
# ALL ALL=(ALL) ALL  # WARNING: only use this together with 'Defaults targetpw'

## Read drop-in files from /etc/sudoers.d
## (the '#' here does not indicate a comment)
#includedir /etc/sudoers.d
bash-4.2#


business_kid 07-27-2013 11:38 AM

Just for the laugh, make a new luser with the wheel group as his default group
Code:

useradd -g wheel -G <whatever> -s /bin/bash [options & stuff]  luser
see if luser can su.

san2ban 07-28-2013 10:39 AM

Businesskid
Tried as you said. luser cannot su.

Is the article in he link correct? Has somebody checked and vetted it?

business_kid 07-28-2013 10:51 AM

There is some thing 'visudo'for editing sudoers.

As youŕe in slackware, slackware has sudo (probably in ~/a/ or ~/ap/) and you can simply

upgradepkg --reinstall

to overwrite it. You then rename the sudoers.new to sudoers, and youŕe back to vanilla.

BCarey 07-28-2013 11:11 AM

Using chown on the file (rather unexpectedely) changes its permissions from
Code:

-rws--x--x
to
Code:

-rwx--x--x
resulting in this behavior. You can fix this with
Code:

chmod 4711 /bin/su
. Edit: or if you want to turn of the global permissions then
Code:

chmod 4710 /bin/su
.

Brian

san2ban 08-01-2013 12:08 PM

Still, I cannot su
Code:

bash-4.2$ ls -l `which su`
-rws--x--x 1 root wheel 66800 Sep 14  2012 /bin/su
bash-4.2$ sudo ldd -v `which su`
Password:
        linux-vdso.so.1 (0x00007ffff1b75000)
        libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f33be275000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f33bdeb5000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f33be4ca000)

        Version information:
        /bin/su:
                libcrypt.so.1 (GLIBC_2.2.5) => /lib64/libcrypt.so.1
                libc.so.6 (GLIBC_2.3) => /lib64/libc.so.6
                libc.so.6 (GLIBC_2.14) => /lib64/libc.so.6
                libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
        /lib64/libcrypt.so.1:
                libc.so.6 (GLIBC_2.14) => /lib64/libc.so.6
                libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6
                libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
        /lib64/libc.so.6:
                ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
                ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
bash-4.2$ su
Password:
su: Authentication failure
bash-4.2$


business_kid 08-02-2013 09:16 AM

I'll bet it's the sudoers file. You've got it so hardened you can't use it :-P. In your honour, I have uploaded a sudoers file rigged the other way - total access. It's HERE

Please do us the favour of downloading it, and trying it. At least it checks whether my guess is correct. Feel free to delete it afterwards. It's something I thought about in 12.1 and have just copied ever since.

fatalfrrog 08-02-2013 09:53 AM

Other people are mentioning permission issues, but that shouldn't be it because you can actually execute su. Instead you are getting an auth failure. san2ban, are you typing your user's password or root's password when you su? You'll need to use root's password for su.

This hack that you did would make it to where you cannot even try to su (i.e. it wouldn't ask for a password) if you aren't part of the wheel group. Since it does ask for a password after issuing su, it would appear that this hack is not causing the issue.

san2ban 08-02-2013 11:27 AM

Code:

bash-4.2$ su
Password:
su: Authentication failure
bash-4.2$ slackpkg update
bash: slackpkg: command not found
bash-4.2$ cat /etc/sudoers
cat: /etc/sudoers: Permission denied
bash-4.2$ sudo cat /etc/sudoers
## sudoers file.
##
## This file MUST be edited with the 'visudo' command as root.
## Failure to use 'visudo' may result in syntax or file permission errors
## that prevent sudo from running.
##
## See the sudoers man page for the details on how to write a sudoers file.
##

##
## Host alias specification
##
## Groups of machines. These may include host names (optionally with wildcards),
## IP addresses, network numbers or netgroups.
# Host_Alias        WEBSERVERS = www1, www2, www3

##
## User alias specification
##
## Groups of users.  These may consist of user names, uids, Unix groups,
## or netgroups.
# User_Alias        ADMINS = millert, dowdy, mikef

##
## Cmnd alias specification
##
## Groups of commands.  Often used to group related commands together.
# Cmnd_Alias        PROCESSES = /usr/bin/nice, /bin/kill, /usr/bin/renice, \
#                            /usr/bin/pkill, /usr/bin/top

##
## Defaults specification
##
## You may wish to keep some of the following environment variables
## when running commands via sudo.
##
## Locale settings
# Defaults env_keep += "LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET"
##
## Run X applications through sudo; HOME is used to find the
## .Xauthority file.  Note that other programs use HOME to find 
## configuration files and this may lead to privilege escalation!
# Defaults env_keep += "HOME"
##
## X11 resource path settings
# Defaults env_keep += "XAPPLRESDIR XFILESEARCHPATH XUSERFILESEARCHPATH"
##
## Desktop path settings
# Defaults env_keep += "QTDIR KDEDIR"
##
## Allow sudo-run commands to inherit the callers' ConsoleKit session
# Defaults env_keep += "XDG_SESSION_COOKIE"
##
## Uncomment to enable special input methods.  Care should be taken as
## this may allow users to subvert the command being run via sudo.
# Defaults env_keep += "XMODIFIERS GTK_IM_MODULE QT_IM_MODULE QT_IM_SWITCHER"
##
## Uncomment to enable logging of a command's output, except for
## sudoreplay and reboot.  Use sudoreplay to play back logged sessions.
# Defaults log_output
# Defaults!/usr/bin/sudoreplay !log_output
# Defaults!/usr/local/bin/sudoreplay !log_output
# Defaults!/sbin/reboot !log_output

##
## Runas alias specification
##

##
## User privilege specification
##
root ALL=(ALL) ALL

## Uncomment to allow members of group wheel to execute any command
%wheel ALL=(ALL) ALL

## Same thing without a password
#%wheel ALL=(ALL) NOPASSWD: ALL
%users        ALL=(ALL)        NOPASSWD: ALL
## Uncomment to allow members of group sudo to execute any command
# %sudo        ALL=(ALL) ALL

## Uncomment to allow any user to run sudo if they know the password
## of the user they are running the command as (root by default).
# Defaults targetpw  # Ask for the password of the target user
# ALL ALL=(ALL) ALL  # WARNING: only use this together with 'Defaults targetpw'

## Read drop-in files from /etc/sudoers.d
## (the '#' here does not indicate a comment)
#includedir /etc/sudoers.d
bash-4.2$

Business_kid
I compared the file that you mentioned with my /etc/sudoers. Only %users All=All line was missing. I added that. Still I cannot su. I cannot update because of following
Code:

bash-4.2$ sudo slackpkg update
sudo: slackpkg: command not found
bash-4.2$
bash-4.2$ sudo slackpkg update
sudo: slackpkg: command not found
bash-4.2$ slackpkg update
bash: slackpkg: command not found
bash-4.2$

Due to above, somebody's suggestion of reinstalling sudo also cannot be done

fatalfrog
I confirm that I use root password when I su.

Except reinstall, I am ready to try anything that is suggested

fatalfrrog 08-02-2013 01:38 PM

Can you login as root at all? Do ctl+alt+f2 and try logging in as root.

Quote:

bash-4.2$ slackpkg update
bash: slackpkg: command not found
This is normal because slackpkg is not in your user's path. Try doing it with /usr/sbin/slackpkg (or /sbin/slackpkg...can't remember).

e5150 08-02-2013 02:38 PM

/etc/sudoers has nothing to do with `su`. What, if anything, is the content of your /etc/suauth?

(And note that if you've added yourself to the wheel group but have yet to log in again, then `groups <username>` will report you as a member of wheel, but running `groups` without any arguments will not. Group membership changes does not affect the running sessions.)

(Also note that "%users ALL=(ALL) NOPASSWD: ALL" in your sudoers file will allow any member of users to run anything as root without a password, once you've got all this sorted out you ought to reconsider whether this appropriate or not.)

business_kid 08-02-2013 03:24 PM

Yes, it's appropriate. All is me :-). It would be most inappropriate on a server.
/etc/suauth is original & untouched and I'm sure you have one of those.

san2ban 08-03-2013 11:38 AM

Code:

bash-4.2$ /usr/sbin/slackpkg update

Only root can install, upgrade, or remove packages.
Please log in as root or contact your system administrator.
bash-4.2$

I cannot login as root or su


All times are GMT -5. The time now is 09:02 AM.