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 社区所有即将举行的活动。

查看所有