Re: SSH and reverse port forwarding

From: David Oberbeck (dgo@spambegone.microsynetics.com)
Date: 05/13/02


From: David Oberbeck <dgo@spambegone.microsynetics.com>
Date: Sun, 12 May 2002 21:57:33 -0600

In <abjk5r$ht$1@slb0.atl.mindspring.net>, Doug Moore wrote:

> I have a question. I am wondering if anyone else has run across this feature or am
> I just poking around in parts of the program that no one goes.
>
> Using the reverse port forwarding feature of the SSH client and server I connect to
> my remote SSH server with the command: SSH R6000:localhost:6000 user@machine.com
> What this does for the users who dont recognize the syntax is when I am connected
> to the remote machine it will listen on port 6000 for traffic. If it sees traffic
> it will forward that traffic back through the SSH tunnel and send the traffic the
> my machine on port 6000.
>
> The HUGH security flaw that I am seeing here and have tested is that anyone that is
> logged into that machine with the DISPLAY environment variable set to localhost:0.0
> or just :0.0, when they start up a xclient application that traffic will come
> across to my machine even though I am not the user who started the xclient
> application.
>
> I have tested this and it works. I logged into a friends machine with my account.
> I listened on port 6000 with reverse port forwarding. I asked my friend to login
> to the machine and set his DISPLAY to localhost:0.0. I then asked him to start
> xterm. About 15 seconds later a xterm window popped up on my screen as his user. I
> then asked him to login to the same machine with root account, set the display, and
> start a xterm window. Again 15 seconds later I had a xterm window on my screen as
> the root user.
>
> Is this a feature or a security flaw?
>
> Doug Moore
 
Greetings to the List,

   Firstly, it's very clear to me that the earlier two respondents
(Messrs Neil and Simon) to this thread (a) have not thought this
through, and (b) have not replicated the situation.

   I have confirmed this. It appears that if a malicious user sets up
port 6000 as a reverse forwarded port, and another user misconfigures
their DISPLAY variable, the malicious user could end up with the
mis-configured user's X session and app(s). If that user was root
(which, granted, is relatively unlikely that a SA would misconfigure
their DISPLAY environment variable, but still possible) the malicious
user now has a root prompt on that system.

   I am surprised that the X forwarding does not seem to check the
permissions of the individual doing the reverse forwarding.

   Is there a way to prevent this?

Regards,
        David

-- 

"Entropy Requires No Maintenance"



Relevant Pages

  • Re: Hardening a Solaris system.
    ... > I know files that execute with root permissions by normal users (e.g. ... > I've set up a web server, running Apache, so are thinking about what I ... thing to leave enabled in here might be a backup port. ... there are security steps here. ...
    (comp.unix.solaris)
  • Re: Hardening a Solaris system.
    ... > I know files that execute with root permissions by normal users (e.g. ... > I've set up a web server, running Apache, so are thinking about what I ... thing to leave enabled in here might be a backup port. ... there are security steps here. ...
    (comp.security.unix)
  • Re: Safe practices
    ... Assume I'm logged in to my Linux system as a normal user. ... System is stand-alone, non-networked, but connected to internet via ... Someone might try to get to you through a port used for other purposes ... Your 'su root' at your console:- You are in a different thread to the rest ...
    (alt.os.linux)
  • A new model for ports and kernel security?
    ... why do we have this requirement that only root ... made to a low port to be "secure". ... clearly it has outlived its usefulness as a "security" feature. ... So I would like to propose the following improvement to kernel security ...
    (Linux-Kernel)
  • Enforce SSH Login Delay
    ... ::ffff:211.171.191.106 port 11328 ssh2 ... Dec 10 13:18:28 turf sshd: Failed password for root from ...
    (comp.os.linux.misc)