FreeBSD-SA-08:05.openssh - OpenSSH X11-forwarding privilege escalation

久々の SA、今回は OpenSSH ですね。

I.   Background

OpenSSH is an implementation of the SSH protocol suite, providing an
encrypted and authenticated transport for a variety of services,
including remote shell access.  The OpenSSH server daemon (sshd)
provides support for the X11 protocol by binding to a port on the
server and forwarding any connections which are made to that port.

II.  Problem Description

When logging in via SSH with X11-forwarding enabled, sshd(8) fails to
correctly handle the case where it fails to bind to an IPv4 port but
successfully binds to an IPv6 port.  In this case, applications which
use X11 will connect to the IPv4 port, even though it had not been
bound by sshd(8) and is therefore not being securely forwarded.

III. Impact

A malicious user could listen for X11 connections on a unused IPv4
port, e.g tcp port 6010.  When an unaware user logs in and sets up X11
fowarding the malicious user can capture all X11 data send over the
port, potentially disclosing sensitive information or allowing the
execution of commands with the privileges of the user using the
X11 forwarding.

NOTE WELL: FreeBSD ships with IPv6 enabled by default in the GENERIC
and SMP kernels, so users are vulnerable even they have not explicitly
enabled IPv6 networking.

IV.  Workaround

Disable support for IPv6 in the sshd(8) daemon by setting the option
"AddressFamily inet" in /etc/ssh/sshd_config.

Disable support for X11 forwarding in the sshd(8) daemon by setting
the option "X11Forwarding no" in /etc/ssh/sshd_config.


  • IPv6 を disabled する
  • X11Forwarding no にする