【最新漏洞預警】CVE-2021-35232 Solarwinds Web Help Desk一個雞肋的HQL注入漏洞
漏洞信息
Solarwinds Web Help Desk 12.7.7 Hotfix 1以前版本存在一個硬編碼用戶憑證,導致能夠本地執行任意 Hibernate 查詢語句。漏洞編號為CVE-2021-35232,在特定模式下有可能被遠程利用的可能性。

環境搭建
下載12.7.6版本,安裝完成后訪問登錄頁面:

跳過郵箱設置,輸入用戶和密碼:

登錄web控制臺:

安裝后版本為12.7.6.8432:

在wrapper.conf中添加debug參數即可開啟遠程調試:

漏洞分析
抓包分析:

請求格式為`/helpdesk/WebObjects/HelpDesk.woa`。路由規則使用`Spring`和私有代碼控制,由于是硬編碼問題,審計JSP代碼時找到了一個固定的用戶名和密碼:

全路徑搜索該字符串,在`ConstantAndSettings`中定義了`Production`和`Development`兩組硬編碼用戶密碼:

以及其他的引用位置,主要包括`RestClient`、`RouteController`和`Authentication Manager`:
λ grep -R "dev-C4F8025E7" ././helpdesk/WEB-INF/jsp/test/orionIntegrationTest.jsp: var auth = {loginName:'helpdeskIntegrationUser', password:'dev-C4F8025E7'};./helpdesk/WEB-INF/jsp/test/orionIntegrationTest.jsp: var auth = {loginName:'helpdeskIntegrationUser', password:'dev-C4F8025E7'};./helpdesk/WEB-INF/lib/whd-core/com/macsdesign/whd/rest/controllers/BasicAuthRouteController$1.class./helpdesk/WEB-INF/lib/whd-core/com/solarwinds/whd/service/impl/auth/HelpdeskIntegrationAuthenticationManager.class
λ grep -R helpdesk91114AD77B4CDCD9E18771057190C08B ././helpdesk/WEB-INF/lib/whd-core/com/macsdesign/whd/rest/controllers/BasicAuthRouteController$1.class./helpdesk/WEB-INF/lib/whd-core/com/solarwinds/whd/rest/RestClient.class./helpdesk/WEB-INF/lib/whd-core/com/solarwinds/whd/service/impl/auth/ClusterNodeAuthenticationManager.class./helpdesk/WEB-INF/lib/whd-core/com/solarwinds/whd/service/impl/auth/HelpdeskIntegrationAuthenticationManager.class./helpdesk/WEB-INF/lib/whd-core/com/solarwinds/whd/service/impl/ClusterLicenseServiceImpl$RestClient.class

在`whd-web.jar/whd-security.xml`中定位到引用的路由:

`AssetReportController`定義了`/rawQL`接口執行HQL語句:

`getStringHQLResult`執行HQL語句:

回到`HelpdeskIntegrationAuthenticationManager`,其讀取`Production`和`Development`模式下固定密碼作為認證憑據:

注意到里邊有一個遠程地址檢查的語句,這里先跳過進行本地測試,添加Basic-Auth頭。拷貝一個控制臺POST請求,發送后出現403:

經過分析,原因是接口需要添加`X-XSRF-TOKEN`字段, 語句成功執行但報錯:

鏈接postgresql嵌入式數據庫,數據庫、用戶、密碼均為`whd`,可以查看數據:

構造語句讀取用戶密碼:

遠程HQL注入嘗試
經測試`/helpdesk/assetReport/rawHQL`遠程訪問返回404,原因是`HelpdeskIntegrationAuthenticationManager`對遠程地址進行檢查:

`request.getRemoteAddress`讀取數據,在反向代理模式下可以繞過檢查:

小結
這是一個比較雞肋HQL注入漏洞,本地可以無條件執行。由于對源地址進行檢查導致遠程無法直接利用,但在反向代理模式下存在利用的可能。除了`assetReport`,其他接口也有可能存在問題。此外,執行HQL的語句還可能存在一定的限制。
