Pentaho Business Analytics CVE-2021-31599命令執行等系列漏洞分析
漏洞信息
Pentaho Business Analytics商業分析解決方案提供現代化的、簡單和交互式的方式,使商業用戶可以訪問、挖掘和混合所有類型和大小的數據。由于先進的分析方案越來越多,從基本的報表到預測建模,用戶可以從多個維度分析和可視化數據,并且最大限度減小對IT的依賴。同時,實際的移動設計體驗使得用戶無論身處何地,都有很高的工作效率。
該軟件最近爆出存在未授權認證SQL注入等一系列漏洞,主要信息如下:
- CVE-2021-31599 (CVSS score: 9.9) - Remote Code Execution through Pentaho Report Bundles
- CVE-2021-31600 (CVSS score: 4.3) - Jackrabbit User Enumeration
- CVE-2021-31601 (CVSS score: 7.1) - Insufficient Access Control of Data Source Management
- CVE-2021-31602 (CVSS score: 5.3) - Authentication Bypass of Spring APIs
- CVE-2021-34684 (CVSS score: 9.8) - Unauthenticated SQL Injection
- CVE-2021-34685 (CVSS score: 2.7) - Bypass of Filename Extension Restrictions
可以從官網下載相關版本進行環境搭建,安裝完畢后默認管理員賬密為`admin:Password`,啟動軟件:

使用`start-pentaho-debug.bat`手動啟動服務可遠程進行調試,端口為8044。
CVE-2021-31602
`C:\Pentaho\server\pentaho-server\pentaho-solutions\system\applicationContext-spring-security.xml`定義了API接口的處理規則,注意到其中以`*require-cfg.js`結尾的接口可以以`Anonymous`身份訪問。

登錄頁面,許多js都是以`require-cfg.js`結尾,應該是為了考慮靜態文件訪問而添加了對應的規則。

找一個API請求,在URL后添加`js=require-cfg.js`,成功繞過認證。

列舉出一些API列表。
http://localhost:8080/pentaho/api/version/show?js=require-cfg.jshttp://localhost:8080/pentaho/api/version/softwareUpdates?js=require-cfg.jshttp://localhost:8080/pentaho/api/emailconfig/isValid?js=require-cfg.jshttp://localhost:8080/pentaho/api/authorization/action/isauthorized?js=require-cfg.jshttp://localhost:8080/pentaho/api/userroledao/userRoles?js=require-cfg.jshttp://localhost:8080/pentaho/api/system/locale?js=require-cfg.jshttp://localhost:8080/pentaho/api/system/timezones?js=require-cfg.jshttp://localhost:8080/pentaho/api/system/executableTypes?js=require-cfg.jshttp://localhost:8080/pentaho/api/theme/list?js=require-cfg.jshttp://localhost:8080/pentaho/api/theme/active?js=require-cfg.jshttp://localhost:8080/pentaho/api/userrolelist/users?js=require-cfg.jshttp://localhost:8080/pentaho/api/userrolelist/roles?js=require-cfg.jshttp://localhost:8080/pentaho/api/userrolelist/allRoles?js=require-cfg.jshttp://localhost:8080/pentaho/api/userrolelist/systemRoles?js=require-cfg.jshttp://localhost:8080/pentaho/api/userrolelist/extraRoles?js=require-cfg.jshttp://localhost:8080/pentaho/api/userrolelist/permission-users?js=require-cfg.jshttp://localhost:8080/pentaho/api/userrolelist/permission-roles?js=require-cfg.jshttp://localhost:8080/pentaho/api/scheduler/state?js=require-cfg.jshttp://localhost:8080/pentaho/api/scheduler/jobinfotest?js=require-cfg.jshttp://localhost:8080/pentaho/api/scheduler/blockout/blockoutjobs?js=require-cfg.jshttp://localhost:8080/pentaho/api/scheduler/blockout/hasblockouts?js=require-cfg.jshttp://localhost:8080/pentaho/api/scheduler/blockout/shouldFireNow?js=require-cfg.jshttp://localhost:8080/pentaho/api/scheduler/generatedContentForSchedule?js=require-cfg.jshttp://localhost:8080/pentaho/api/repos/executableTypes?js=require-cfg.jshttp://localhost:8080/pentaho/api/plugin-manager/overlays?js=require-cfg.jshttp://localhost:8080/pentaho/api/mantle/locale?js=require-cfg.jshttp://localhost:8080/pentaho/api/mantle/isAuthenticated?js=require-cfg.jshttp://localhost:8080/pentaho/api/mantle/getAdminContent?js=require-cfg.jshttp://localhost:8080/pentaho/api/mantle/settings?js=require-cfg.jshttp://localhost:8080/pentaho/api/mantle/registeredPlugins?js=require-cfg.jshttp://localhost:8080/pentaho/api/service/assignment?js=require-cfg.jshttp://localhost:8080/pentaho/api/repo/files/reservedCharacters?js=require-cfg.jshttp://localhost:8080/pentaho/api/repo/files/generatedContentForSchedule?js=require-cfg.jshttp://localhost:8080/pentaho/api/repo/files/canAdminister?js=require-cfg.jshttp://localhost:8080/pentaho/api/repo/files/reservedCharactersDisplay?js=require-cfg.jshttp://localhost:8080/pentaho/api/session/userName?js=require-cfg.jshttp://localhost:8080/pentaho/api/session/workspaceDirForUser/{user}?js=require-cfg.jshttp://localhost:8080/pentaho/api/session/setredirect?js=require-cfg.jshttp://localhost:8080/pentaho/api/session/userWorkspaceDir?js=require-cfg.js
CVE-2021-34684
`/pentaho/api/repos/dashboards/editor`接口可執行SQL語句。


CVE-2021-31599
使用`Pentaho Business Analytics`支持報表功能設計和保存功能,可以通過WEB上傳并編輯Report報表,名稱為`Pentaho Report`文件。

使用`\pentaho\design-tools\report-designer\report-designer.exe`程序可對PRPT文件進行設計,后綴名為PRPT。

打開`Pie.prpt`示例文件,雙擊餅圖找到Scripting設置項目。

支持的語法有`beanshell`、`groovy`等,這里使用beanshell,輸入語句。保存文件使用網頁打開。

命令被成功運行,權限為`Local Service`。

可以使用groovy語法直接獲取webshell。

CVE-2021-31600
用戶認證后可以獲取用戶列表,CVE-2021-31602無法繞過本接口。

CVE-2021-31601
用戶認證后可獲取用戶配置信息,CVE-2021-31602無法繞過本接口。

CVE-2021-34685
使用`UploadService`接口對文件上傳后綴名做了限制,但可以使用`filename.jsp.`繞過檢查,最后在`\server\pentaho-server\pentaho-solutions\system\metadata\csvfiles`目錄下寫入jsp文件,由于無法目錄穿越,漏洞影響有限。

小結
1、從實測效果來看,認證繞過漏洞適用的API范圍還是比較廣的,但針對某些核心業務接口在后續業務處理時會出錯,導致能執行的功能有限。以`報告文件`上傳接口為例,可以繞過檢查,但服務器在后續處理時由于定位不到用戶`ID`,只能報錯退出。

2、創建用戶接口不會返回401錯誤,但無法創建用戶。

3、默認`anonymousUser`在`jackrabbit`認證時出錯,不具備workspace訪問權限,這也導致很多接口無法正常執行功能。
