LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-19-2017, 01:04 PM   #1
gabrielsousa
LQ Newbie
 
Registered: Jul 2015
Posts: 10

Rep: Reputation: Disabled
security risk on sudoers with shells


i'm denying all shells on sudoers
but, found an app/bin is like a exec/fork that using with sudo the user gain access to root , like this

$ sudo app_exec_fork /bin/bash

and gain access to root, its like i'm not denying the /bin/bash

any solution to this ?
 
Old 10-19-2017, 01:13 PM   #2
gabrielsousa
LQ Newbie
 
Registered: Jul 2015
Posts: 10

Original Poster
Rep: Reputation: Disabled
and how we prevent ?

cp /bin/bash /opt/myprog && sudo /opt/myprog
 
Old 10-19-2017, 02:02 PM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
There's little risk if you use sudo correctly: It is for whitelisting programs and their options.

Can you explain a little more about what you are really trying to do?
 
Old 10-19-2017, 02:11 PM   #4
gabrielsousa
LQ Newbie
 
Registered: Jul 2015
Posts: 10

Original Poster
Rep: Reputation: Disabled
my rules

Matching Defaults entries for adm-gsousa on host02:
!env_reset, !requiretty, !visiblepw, always_set_home

User adm-gsousa may run the following commands on host02:
(ALL) NOPASSWD: ALL, !/usr/bin/passwd root, !/bin/* /etc/sudoers*, !/bin/* * /etc/sudoers.d/*, !/usr/sbin/visudo, !/bin/su, !/sbin/runuser, !/bin/sh, !/bin/bash, !/bin/tcsh, !/bin/csh


i'm trying to deny the switch user to root
 
Old 10-19-2017, 10:20 PM   #5
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Quote:
Originally Posted by gabrielsousa View Post
i'm trying to deny the switch user to root
It does not work like that. You've already found the reason why blacklisting programs cannot work.

sudo works when you make a list of the few things you wish to allow an account to do as another user, usually root. Please check any of the three links above in that regard or refer to "man sudoers"

Which specific activities do you wish to allow the account "adm-gsousa" to do?
 
Old 10-20-2017, 04:03 AM   #6
gabrielsousa
LQ Newbie
 
Registered: Jul 2015
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
It does not work like that. You've already found the reason why blacklisting programs cannot work.

sudo works when you make a list of the few things you wish to allow an account to do as another user, usually root. Please check any of the three links above in that regard or refer to "man sudoers"

Which specific activities do you wish to allow the account "adm-gsousa" to do?
administrator tasks
 
Old 10-20-2017, 04:17 AM   #7
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Ok. Then list them program by program inside /etc/sudoers for that user. That's how sudo works.

For editors use sudoedit instead of launching an editor directly with sudo. Be sure to preface pagers (less, more, and so on) with NOEXEC to reduce the likelihood of shell escapes.
 
Old 10-20-2017, 09:21 AM   #8
gabrielsousa
LQ Newbie
 
Registered: Jul 2015
Posts: 10

Original Poster
Rep: Reputation: Disabled
add this rules... i know that, there workaround... but

Matching Defaults entries for adm-gsousa on this host:
!env_reset, !requiretty, !visiblepw, always_set_home

User adm-gsousa may run the following commands on this host:
(ALL) NOPASSWD: ALL, (ALL) !/usr/bin/passwd root, !/bin/* /etc/sudoers*, !/bin/* * /etc/sudoers.d/*, !/usr/sbin/visudo, !/bin/su, !/sbin/runuser, !/bin/sh, !/bin/bash, !/bin/tcsh, !/bin/csh, !/bin/* /bin/bash *, !/bin/* /bin/sh *,
!/bin/* /bin/tcsh *, !/bin/* /bin/csh *, !/*/*/* /bin/bash, !/*/*/* /bin/tcsh, !/*/*/* /bin/csh, !/*/*/* /bin/sh, !/*/* /bin/bash, !/*/* /bin/tcsh, !/*/* /bin/csh, !/*/* /bin/sh, !/* /bin/bash, !/* /bin/tcsh, !/* /bin/csh, !/*
/bin/sh, !/*/*/*/* /bin/bash, !/*/*/*/* /bin/tcsh, !/*/*/*/* /bin/csh, !/*/*/*/* /bin/sh
 
Old 10-20-2017, 09:41 AM   #9
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
You misunderstand, it looks like. No commands or patterns for commands may be preceeded with a negation. None. Please review any of the three links provided above. You've already pointed out how to work around negations. Negations don't and can't work for commands.

For example,

Code:
cp /bin/sh ./foo
sudo foo
Don't list the programs you don't want them to run. List the programs you do want them to run: Make a list of the programs which the account is allowed to use and put that list in sudoers.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is this a security risk? jim.thornton Linux - Security 1 01-18-2008 01:55 AM
Security Risk? N|k0N Linux - Security 7 10-02-2004 04:52 PM
is this a security risk? shanenin Linux - Security 8 11-02-2003 04:27 PM
security risk? Notfromkansas Linux - Security 12 04-04-2002 10:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 07:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration