Spring Security 安全性建議

CVE-2023-34035:使用多個 Servlet 時,授權規則可能配置錯誤

| 2023 年 7 月 17 日 | CVE-2023-34035

描述

嚴重性很高,除非另有說明。

Spring Security 5.8 版本早於 5.8.56.0 版本早於 6.0.5,以及 6.1 版本早於 6.1.2 可能容易受到授權規則錯誤配置的影響,如果應用程式使用 requestMatchers(String)requestMatchers(HttpMethod, String) 以及多個 servlet,其中一個是 Spring MVC 的 DispatcherServlet。

DispatcherServlet 是一個 Spring MVC 元件,它將 HTTP 端點對應到 @Controller 註釋類別上的方法。)

具體來說,當以下所有條件都成立時,應用程式容易受到攻擊

  • Spring MVC 在類別路徑上
  • Spring Security 在單個應用程式中保護多個 servlet(其中一個是 Spring MVC 的 DispatcherServlet
  • 應用程式使用 requestMatchers(String)requestMatchers(HttpMethod, String)

如果以下任何一個條件成立,則應用程式不會受到攻擊

  • 應用程式的類別路徑上沒有 Spring MVC
  • 應用程式除了 Spring MVC 的 DispatcherServlet 之外,沒有保護任何 servlet
  • 應用程式不使用 requestMatchers(String)requestMatchers(HttpMethod, String)

受影響的 Spring 產品和版本

  • Spring Security 5.8.05.8.4
  • Spring Security 6.0.06.0.4
  • Spring Security 6.1.06.1.1

緩解措施

受影響版本的用戶應採取以下緩解措施。

第一

  • 5.8.x 用戶應升級到 5.8.5
  • 6.0.x 用戶應升級到 6.0.5
  • 6.1.x 用戶應升級到 6.1.2

第二,如果您使用多個 servlet 並且其中一個是 Spring MVC 的 DispatcherServlet,您可能會在啟動時看到以下錯誤訊息

This method cannot decide whether these patterns are Spring MVC patterns or not.
If this endpoint is a Spring MVC endpoint, please use `requestMatchers(MvcRequestMatcher)`;
otherwise, please use `requestMatchers(AntPathRequestMatcher)`.

有時這些額外的 servlet 並不需要。 例如,某些 servlet 容器會新增一個 DefaultServlet,而 DispatcherServlet 會有效地取代它。 在許多情況下,可以從容器的全局配置中刪除此類 servlet。

如果不需要額外的 servlet,請嘗試刪除它們,看看錯誤是否仍然存在。 如果仍然存在,請按照錯誤訊息中的指示進行操作。

有關如何解決錯誤訊息的幾個範例,請參閱以下緩解儲存庫

感謝

此問題由 Kudelski Security 的資深軟體工程師 Mouad Kondah 發現並負責地報告。

領先一步

VMware 提供培訓和認證,以加速您的進度。

瞭解更多

取得支援

Tanzu Spring 在一個簡單的訂閱中提供 OpenJDK™、Spring 和 Apache Tomcat® 的支援和二進位檔案。

瞭解更多

即將舉行的活動

查看 Spring 社群中所有即將舉行的活動。

檢視全部