CVE-2025-22232:Spring Cloud Config Server 可能不會使用客戶端傳送的 Vault 令牌

中等 | 2025 年 4 月 7 日 | CVE-2025-22232

描述

當 Spring Cloud Config Server 向 Vault 發出請求時,它可能不會使用客戶端透過 X-CONFIG-TOKEN 頭部發送的 Vault 令牌。

如果滿足以下條件,您的應用程式可能會受到影響:

  1. 如果您的 Spring Cloud Config Server 類路徑中包含 Spring Vault,並且
  2. 您正在使用 X-CONFIG-TOKEN 頭部向 Spring Cloud Config Server 傳送 Vault 令牌,以便 Config Server 在向 Vault 發出請求時使用,並且
  3. 您正在使用預設的 Spring Vault SessionManager 實現 LifecycleAwareSessionManager 或持久化 Vault 令牌的 SessionManager 實現,例如 SimpleSessionManager

在這種情況下,SessionManager 會持久化它檢索到的第一個令牌,並會繼續使用該令牌,即使客戶端向 Spring Cloud Config Server 發出的請求包含帶有不同值的 X-CONFIG-TOKEN 頭部。

受影響的 Spring 產品和版本

Spring Cloud Config

  • 2.2.1.RELEASE - 4.2.1

緩解措施

受影響版本的使用者應升級到相應的修復版本。

受影響版本 修復版本 可用性
4.2.x 4.2.2 OSS
4.1.x 4.1.6 OSS
4.0.x 4.0.10 商業
3.1.x 3.1.10 商業
3.0.x 4.1.6 OSS
2.2.x 4.1.6 OSS

注意:Spring Cloud Config 3.0.x 和 2.2.x 不再受開源或商業支援。建議這些版本的使用者升級到受支援的版本。

無需其他緩解措施。

如果您無法升級,您可以選擇以下任一方式:

  1. 如果不需要,從類路徑中移除 Spring Vault,或者
  2. 實現您自己的不持久化 Vault 令牌的 SessionManager,並在 @Configuration 類中使用該實現提供一個 bean。例如:

public class StatelessSessionManager implements SessionManager {

	private final ClientAuthentication clientAuthentication;

	private final ReentrantLock lock = new ReentrantLock();

	public StatelessSessionManager(ClientAuthentication clientAuthentication) {
		Assert.notNull(clientAuthentication, "ClientAuthentication must not be null");
		this.clientAuthentication = clientAuthentication;
	}

	public VaultToken getSessionToken() {
		this.lock.lock();
		try {
			return this.clientAuthentication.login();
		}
		finally {
			this.lock.unlock();
		}
	}

}

@Configuration
public class MySessionManagerConfiguration extends SpringVaultClientConfiguration {

	private final VaultEnvironmentProperties vaultProperties;

	public MySessionManagerConfiguration(VaultEnvironmentProperties vaultProperties, ConfigTokenProvider configTokenProvider, List authProviders) {
		super(vaultProperties, configTokenProvider, authProviders);
		this.vaultProperties = vaultProperties;
	}

	@Bean
	@Primary
	public SessionManager sessionManager() {
		if (vaultProperties.getAuthentication() == null && !StringUtils.hasText(vaultProperties.getToken())) {
			return new StatelessSessionManager(clientAuthentication());
		}
		return super.sessionManager();
	}
}

致謝

此漏洞由 Max Brauer 和 Mohammad Shamsi 發現並負責任地報告。

參考資料

領先一步

VMware 提供培訓和認證,助您加速進步。

瞭解更多

獲得支援

Tanzu Spring 提供 OpenJDK™、Spring 和 Apache Tomcat® 的支援和二進位制檔案,只需一份簡單的訂閱。

瞭解更多

即將舉行的活動

檢視 Spring 社群所有即將舉行的活動。

檢視所有