Maybe you have a firewall in your company, only your PC can access the production server, only you have the root password in prod, and your company spend a lot of money in security, but you dare using xhost +.
This is a huge security hole, because it gives anyone access to your X resources, not only your display, but also your mouse and your keyboard, so anyone can read/modify/corrupt what you are typing/clicking. It is a bad habit to use xhost+. Even using xhost +localhost give access to your keyboard to anyone on localhost…
So what else could you use ?
The simplest is probably ssh tunnelling.
lsc@chltlxlsc:~> ssh -X oracle@localhost
Last login: Fri Max 2 10:24:09 2007 from localhost
oracle@chltlxlsc:~> xterm -e true && echo success
success
Another way to do this is to use X cookies.
lsc@chltlxlsc1:~> xauth extract ~/my-x-cookie $DISPLAY<
lsc@chltlxlsc1:~> setfacl -m u:oracle:r ~/my-x-cookie
lsc@chltlxlsc1:~> su - oracle -c "DISPLAY=$DISPLAY bash"
Password:
oracle@chltlxlsc1:~> xterm -e true && echo success
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified
xterm Xt error: Can't open display: :0.0
oracle@chltlxlsc1:~> xauth merge ~lsc/my-x-cookie
xauth: creating new authority file ~oracle/.Xauthority
oracle@chltlxlsc1:~> xterm -e true && echo success
success
No need to type all. Here is my alias
alias oracle='
xauth extract $HOME/my-x-cookie $DISPLAY;
setfacl -m u:oracle:r $HOME/my-x-cookie;
su - oracle -c "export DISPLAY=$DISPLAY;
xauth merge $HOME/my-x-cookie;
bash"'
Tuesday, January 1, 2008
xhost + is a huge security hole
Published By Ahmed Soliman at 10:37 AM
Labels: Installation, Linux, Security
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment