-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prevent escaping lshell using sudo_noexec #122
Comments
👍 Amazing idea!! Thank you for sharing this! I've been wanting to work on adding noexec to prevent such commands to use the shell escape, but never thought of it this way. I will work on it to integrate it. I'll keep you posted. |
I am going to use the LD_PRELOAD for all the allowed commands, regardless of the fact that they allow shell escapes (e.g. vim, find) or not. I have a first patch that seems functional. I will commit it soon, it would be great if you could test it out. |
I have tested the patch on Debian and CentOS. It would be great if you could test it too. |
i am sorry but this is easily bypassed: |
Nice again @lberra ! I will take a look at your PR. Ideally, I would like to avoid adding a new variable. Some administrator might not know which command allows shell-escapes, and miss them. I'm looking into forcing the LD_PRELOAD as a global environment variable. This would make it available for all the commands on a command line. More to follow soon. :) |
if you want to set it global do something like
remember that setting it globally will break shell scripts we could invert the settings, making |
I have tested the following, and it seems to work:
I'll commit it in a minute, if you still have some time to test it out. :) |
This commit adds the possibility to prevent shell escapes by using the sudo_noexec.so shared-object. If sudo(8) is installed and sudo_noexec.so is available, it will be loaded before running every command, preventing it from running further commands itself.
@lberra I have forced the git push, to overwrite master, you might need to re-clone. Sorry for that. |
I'm not totally awake, lot's of --force. :) |
I wonder if it should be allowed at all. Wouldn't that just reopen the door for escapes? In which scenario do you think it would be helpful? |
setting LD_PRELOAD breaks shell scripts that execute external commands |
On Feb 6, 2016 14:43, "lberra" notifications@github.com wrote:
Very true. I went too fast on a solution. I will revert my changes, and |
Here is the plan. I prefer having the default command list to use "allowed" (instead of "allowed_noexec" in your PR). This will prevent from breaking the configuration with previous versions of lshell. Instead, I will be adding another variable to explicitly allow commands to use exec (e.g. shell scripts). Otherwise, it seems that you alias solution is the best way to achieve want you have described. To sum up, I will be integrating your PR, and working on top of it to introduce aliases for allowed commands, and a new variable called "allowed_shell_escape" for the exception list. |
Thank you so much for your help on this @lberra !! This is very much appreciated! |
Hello, |
@lmarkov there is currently no way to bypass the script without adding them to the There is actually a tiny bug preventing you from bypassing the standard noexec path. I will correct this now. If you clone the latest code, you will be able to set another I will add the possibility to disable this, with a big security warning. |
I commented all lines in def set_noexec(self): in file checkconfig.py. I think that this is solution for so far. |
at the moment it is possible to escape lshell if an allowed command can execute an arbitrary non allowed one:
example:
find ~ -name .lhistory -exec bash \;
(yes default config disallows ";" but it can be enabled)
i prevented this by creating an alias:
aliases : {'find':'LD_PRELOAD=/usr/lib/sudo/sudo_noexec.so find'}
but it would be cool having an option for this
which would preload the noexec library to the restricted program
The text was updated successfully, but these errors were encountered: