目录

CVE-2022-22954 VMware Workspace ONE Access SSTI RCE 简单分析

简介

Workspace ONE Access 提供统一应用门户,通过门户可安全访问企业的所有应用,可用于单点登录。CVE-2022-22954 中,攻击者可构造恶意请求造成模板注入,执行任意代码,控制服务器。

漏洞版本

1
VMware Workspace ONE Access : 21.08.0.1,21.08.0.0,20.10.0.1,20.10.0.0

环境搭建

ova文件VMware直部署,在导入ova中Host Name(FQDN)需设置一个域名,可本地host文件自行设置,其余一律默认即可

漏洞分析

直接来看漏洞点,在customError.ftl

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/2e7187ac-3447-1c71-44f6-8a12e1623fd8.png

官方文档中,可以看到eval的存在会执行FTL表达式,官方也在提示会造成恶意注入

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/6cfb2739-acf7-d9e1-9034-05578a04ae9d.png

看一下这个jar包的构造属于springBoot,可通过Controller查找那个Controller会return到customError.ftl

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/4e71d714-7574-7d32-d68e-a78102b3eab8.png

com.vmware.endusercatalog.ui.web.UiErrorController#handleGenericError中,接受一个String errorMessage参数,并把它put到errorObj中,然后返回到customError.ftl中,中间没有对其进行任何操作

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/aab33348-8e16-c9f0-43ce-014ea0800797.png

接着往上回溯看那个函数调用handleGenericError,在handleUnauthorizedError中调用了两次handleGenericError,而在getErrorPage中又调用了handleUnauthorizedErrorhandleGenericError,也就是说继续往上回溯getErrorPage

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/2c930ac4-188b-62dd-1574-cf741a6176b6.png

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/371fc91f-e3e8-12ef-03c0-fbb0d1e342fb.png

接着找到了两个路由sendErrorsendUnhandledError,都接收到前端传进来的javax.servlet.error.message并赋值给errorMessage,此时javax.servlet.error.message不可控,继续去找可以赋值并且会返回给这两个路由的方法

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/120a33ce-ead2-71e2-83ad-e2579155d8b2.png

接着在UiApplicationExceptionResolver类中找到了resolveExceptionhandleAnyGenericException,在resolveException中会request.setAttribute("javax.servlet.error.message", errorJson);set值,然后返回到"/ui/view/error",接着又找到了handleAnyGenericException会去调用resolveException,并在((LocalizationParamValueException)ex).getArgs())中得到args值,而它还有一个注解@ExceptionHandler({Exception.class})表示会在被@RequestMapping注解的方法抛出异常时会执行此方法

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/6a351209-b09c-0ea5-fa61-52f9388ffd57.png

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/e8f674a8-3735-1751-54e8-b2f2eff8ba21.png

接下来就是想办法让其抛出异常,在启动类中有一个自动扫描包的注解,其中会扫描com.vmware.endusercatalog.auth下的包,里面有一个拦截器AuthContextPopulationInterceptor,会get到request中的deviceUdid参数值,然后通过build()new一个AuthContext对象

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/3d9aa0b6-5e61-1d66-2c9a-adad15d8a710.png

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/0477162a-1bca-80e1-0853-823f4dfabc39.png

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/580520e2-6aab-29c9-e9d9-28c7b99bdc34.png

AuthContext构造函数中,最后会抛出一个InvalidAuthContextException异常,而只要deviceId或者deviceType不为空即可触发异常然后执行handleAnyGenericException

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/63f4602d-d356-4852-ceb5-61d0d46e46ad.png

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/36707bc1-de4c-22b3-f274-340071742594.png

因为在拦截器中触发异常,因此url可以是类中定义的过的@RequestMapping注解

复现结果如下

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2513662/caf4584f-e264-ec53-256c-63769e2752ae.png

参考链接

  1. https://y4er.com/post/cve-2022-22954-vmware-workspace-one-access-server-side-template-injection-rce/