- Mastering Linux Security and Hardening
- Donald A. Tevault
- 243字
- 2021-07-02 19:19:22
Preventing users from using shell escapes
Certain programs, especially text editors and pagers, have a handy shell escape feature. This allows a user to run a shell command without having to exit the program first. For example, from the command mode of the Vi and Vim editors, someone could run the ls command by doing :!ls. Executing the command would look like this:
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
~
~
:!ls
The output would look like this:
[donnie@localhost default]$ sudo vim useradd
[sudo] password for donnie:
grub nss useradd
Press ENTER or type command to continue
grub nss useradd
Press ENTER or type command to continue
Now, imagine that you want Frank to be able to edit the sshd_config file and only that file. You might be tempted to add a line to your sudo configuration that would look like this:
frank ALL=(ALL) /bin/vim /etc/ssh/sshd_config
This looks like it would work, right? Well, it doesn't because once Frank has opened the sshd_config file with his sudo privilege, he can then use Vim's shell escape feature to perform other root-level commands, which would include being able to edit other configuration files. You can fix this problem by having Frank use sudoedit instead of vim:
frank ALL=(ALL) sudoedit /etc/ssh/sshd_config
sudoedit has no shell escape feature, so you can safely allow Frank to use it.
Other programs that have a shell escape feature include the following:
- emacs
- less
- view
- more
- API攻防:Web API安全指南
- 網(wǎng)絡(luò)安全技術(shù)及應(yīng)用(第3版)
- 黑客攻防與無(wú)線安全從新手到高手(超值版)
- Spring Security(Third Edition)
- Falco云原生安全:Falco原理、實(shí)踐與擴(kuò)展
- Digital Forensics with Kali Linux
- 網(wǎng)絡(luò)安全與攻防入門(mén)很輕松(實(shí)戰(zhàn)超值版)
- 信息安全導(dǎo)論(第2版)
- 無(wú)線傳感器網(wǎng)絡(luò)安全與加權(quán)復(fù)雜網(wǎng)絡(luò)抗毀性建模分析
- 編譯與反編譯技術(shù)實(shí)戰(zhàn)
- 網(wǎng)絡(luò)安全大數(shù)據(jù)分析與實(shí)戰(zhàn)
- 網(wǎng)絡(luò)服務(wù)安全與監(jiān)控
- 信息安全工程與實(shí)踐
- Hands-On Artificial Intelligence for Cybersecurity
- 企業(yè)數(shù)據(jù)安全防護(hù)指南